最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Jupyter notebook color different parentheses by different colors - Stack Overflow

programmeradmin2浏览0评论

I can see the matching parenthesis hightlights green when I hover around them, but is it possible to add additional color syntax to them so that the matching parenthesis have different colors.

  • Is there any nbextension for that?
  • Is there a way to add some code to custom.js that will make it happen.

Example code:

# create new features
df = (df
 .withColumn(("rooms_per_hh", F.round(col('total_rooms') / col('households'), 2)))
 .withColumn(("pop_per_hh", F.round(col('pop') / col('households'), 2)))
 .withColumn(("bedrooms_per_rooms", F.round(col('total_bedrooms') / col('total_rooms'), 2)))
     )

I like to see different colors for different parentheses here.

Related links:
- Changing jupyter's matching parenthesis color
- Replace / remove highlighting in Jupyter Notebook with custom theme

Required output:

I can see the matching parenthesis hightlights green when I hover around them, but is it possible to add additional color syntax to them so that the matching parenthesis have different colors.

  • Is there any nbextension for that?
  • Is there a way to add some code to custom.js that will make it happen.

Example code:

# create new features
df = (df
 .withColumn(("rooms_per_hh", F.round(col('total_rooms') / col('households'), 2)))
 .withColumn(("pop_per_hh", F.round(col('pop') / col('households'), 2)))
 .withColumn(("bedrooms_per_rooms", F.round(col('total_bedrooms') / col('total_rooms'), 2)))
     )

I like to see different colors for different parentheses here.

Related links:
- Changing jupyter's matching parenthesis color
- Replace / remove highlighting in Jupyter Notebook with custom theme

Required output:

Share Improve this question asked Sep 29, 2019 at 15:34 BhishanPoudelBhishanPoudel 17.2k25 gold badges120 silver badges188 bronze badges 5
  • You want every single pair of matching brackets to be styled differently, or just the active matching brackets? – Souleste Commented Oct 2, 2019 at 16:35
  • @Souleste all the matching brackets in the cell like in vim editor plugin rainbow parenthesis github./luochen1990/rainbow – BhishanPoudel Commented Oct 3, 2019 at 3:50
  • Do you want a "Bracket Pair Colorizer" for Python?? – spYder Commented Oct 4, 2019 at 13:17
  • 1 @spYder Yes, similar to RAINBOW PARENTHESIS in vim. – BhishanPoudel Commented Oct 4, 2019 at 15:07
  • Then isn't an option to run the notebooks in VSCode ( w/ the Rainbow or BPC extensios running ) ??? You get the different colours that you want + you run .ipynb – spYder Commented Oct 4, 2019 at 16:31
Add a ment  | 

2 Answers 2

Reset to default 3 +25

I think you can use jupyter-notebook-themes Google Chrome and add .cm-s-ipython .CodeMirror-matchingbracket { color: black !important;} or some thing else to change coloring of inner parenthesis.

Then you can add it to your Chrome as a custom extension.

You can run the jupyter in VSCode, using the Bracket Pair Colorizer ( or Rainbow Brackets ) And will give you something like this :

You import the .ipynb file, have the "Run Cell" mand + can import the Color extensions.... It's not perfect ( not really using "Jupyter" ) but it works...

发布评论

评论列表(0)

  1. 暂无评论