vatlab / sos-notebook

Multi-language Jupyter Notebook
http://vatlab.github.io/SoS
BSD 3-Clause "New" or "Revised" License
175 stars 17 forks source link

Indentation interferes with syntax highlighting #275

Open gaow opened 5 years ago

gaow commented 5 years ago

I"m using report action to dump some utility functions, see below:

2019-10-03-12-02-30_scrot

Not sure how hard it is but it would be real nice to add some argument in report action to specify syntax highlight type.

BoPeng commented 5 years ago

Are we treating them as plain text now? I would strongly suggest against an additional frontend-only parameter. It could be implemented by checking the file extension of output parameter, but this is pretty difficult to do (doable, but we have to drop support for complex cases such as variable and expression), and will not be of high priority.

gaow commented 5 years ago

Are we treating them as plain text now?

Well, rather we treat them as 'comments'. Maybe as plain text would be better that treating them as comments as you can see above.

BoPeng commented 5 years ago

It appears to be the way markdown texts are highlighted, related to indentation and comments

image

BoPeng commented 5 years ago

I think the essential problem is that many syntax highlighters are indentation aware. For example, the Python syntax highlighter will work differently if the block of python code indents by 2 or 4, and the markdown highlighter also works this way.

The solution here would be calculating the level of indentation and removing block level indentation before applying the syntax highlighter. I am not sure how it can be done though.