sos-notebook icon indicating copy to clipboard operation
sos-notebook copied to clipboard

Indentation interferes with syntax highlighting

Open gaow opened this issue 6 years ago • 4 comments
trafficstars

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.

gaow avatar Oct 03 '19 17:10 gaow

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.

BoPeng avatar Oct 04 '19 03:10 BoPeng

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.

gaow avatar Oct 04 '19 03:10 gaow

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

image

BoPeng avatar Oct 04 '19 03:10 BoPeng

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.

BoPeng avatar Oct 04 '19 15:10 BoPeng