Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic syntax highlighting

I'm in search of a tool which will allow me to customize dynamic syntax highlight rules :

Examples of static syntax highlighting (most IDEs already do this).

  1. Highlight all occurences of the word int as red.

  2. Highlight all strings (enclosed in ") in blue.

Examples of DYNAMIC syntax highlighting

  1. Given a string of txt that appears > twice, I want it highlighted purple.

  2. If I click on a block of text, I would like all blocks of txt on the same file highlighted green.

I'm assuming that someone may have built such a highlighter before, but I can't find anything on the web. Any feedback on how:

  1. I can extend an existing project (ideally, I'd like this to be an IDE plugin) to customize my dynamic requirements?

  2. In case 1 is not in existence, any templating languages that might be maximally effective for this sort of project ? i.e. any frameworks that highlight text on the fly, dynamically, while enabling editing - that are easily extended.

like image 297
jayunit100 Avatar asked Apr 07 '12 10:04

jayunit100


People also ask

What is syntax highlighting style?

Syntax highlighting determines the color and style of source code displayed in the Visual Studio Code editor. It is responsible for colorizing keywords like if or for in JavaScript differently than strings and comments and variable names.

How do you highlight syntax?

Syntax highlighting is a feature of text editors that are used for programming, scripting, or markup languages, such as HTML. The feature displays text, especially source code, in different colours and fonts according to the category of terms.

How do you use Prism syntax highlighter?

Go to the Prism project homepage (https://prismjs.com/), then to the download page as before, and generate a script file selecting only the coding languages you are interested in; don't reselect any plugins. Then download the JavaScript file. Remember: do not download the CSS file, only the prism. js file.

What is syntax highlighting in Wordpress?

Syntax highlighting is a styling format commonly used to display code. It adds line numbers and colors to highlight code patterns which makes it easy to understand. Here is an example of a code snippet with some syntax highlighting. Notice the line numbers and colors used to highlight different elements in the code: 1.


1 Answers

Emacs (www.gnu.org/s/emacs/) should be able to do this.

Emacs is extremely customizable; you code (e)Lisp functions to make it do what you want. Many of Emacs's language-specific modes do "fixed" highlighting of keywords; you should be able to hijack that machinery and make the highlighting dynamic as interests you. Huge libraries of eLisp code for such modes is available from GNU.

like image 151
Ira Baxter Avatar answered Oct 09 '22 19:10

Ira Baxter