Suggestion: Only syntax highlight range
See original GitHub issueIt’s not uncommon to see presentations or code images where most of the code is de-coloured / not syntax highlighted, and only a specific range or set of ranges are highlighted.
I’ve worked out a possible solution.
CodeMirror supports marking a range of text with a class. https://codemirror.net/doc/manual.html#api_marker
The CSS can then be added to make ALL text grey (or a themes comment colour?), only keeping the syntax highlighting for a specific section.
The CSS would look something like…
:not(.colourise) > span {
color: gray !important;
}
Applying the class of colourise
to a presentation span, then results in the attached screenshot result.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9 (5 by maintainers)
Top Results From Across the Web
What Is Syntax Highlighting? - MakeUseOf
It typically highlights keywords, string literals, and other syntactic elements. Syntax highlighting can also draw attention to syntax errors.
Read more >python - Syntax Highlighting in Cocoa TextView? Experiences ...
I would suggest taking a look at the source code to Smultron. It has very nice syntax highlighting. It uses a subclass of...
Read more >Extension:SyntaxHighlight - MediaWiki
The SyntaxHighlight extension, formerly known as SyntaxHighlight_GeSHi, provides rich formatting of source code using the <syntaxhighlight> tag.
Read more >A case against syntax highlighting - Linus Åkesson
Syntax highlighting is a standard feature of most modern text editors and development environments. The basic idea is to exaggerate the visual ...
Read more >Syntax Highlight Guide | Visual Studio Code Extension API
Syntax highlighting determines the color and style of source code displayed in the Visual Studio Code editor. It is responsible for colorizing keywords...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a lesser known feature, but we already have support for highlighting/selecting lines. You have to turn on “Line numbers” in the settings, but then by clicking on the line numbers you can (de)select certain lines to highlight them. If you click, and then Shift-click another line, that will batch select a group of lines.
We also want to use opacity in order to ensure that deselection always looks good, no matter what the theme is.
I wish I had time @mfix22! Appreciate you working on this!