What is a tool that will highlight syntax using only HTML with class attributes?

I am looking for a command line tool (or a Perl module or VIM script or something else) that will take some input files (like XML or JavaScript files) and format them in HTML. I specifically want my output to not contain such things as <span style="color: red">or <font color=red>according to a specific color scheme, instead it should use CSS class names to mark up the various syntax parts of the file.

For example, if I had this file as input:

function f(x) {
  return x + 1;
}

the type of output I would like:

<pre><span class=keyword>function</span> <span class=ident>f</span><span class=punc>{</span>
  <span class=keyword>return</span> <span class=ident>x</span> <span class=op>+</span> <span class=numliteral>1</span><span class=punc>;</span>
<span class=punc>}</span></pre>

Does anyone know about such a tool?

- VIM 2html.vim script, class= " (," "," "," " ..) .

,

+3
3

, , Vim :TOhtml,

:let html_use_css = 1

:

function f(x) {
    return x + 1;
}

:

<pre>
<span class="Identifier">function</span> f(<span class="">x</span><span class="javaScriptParens">)</span><span class=""> </span><span class="Identifier">{</span>
  <span class="Statement">return</span><span class=""> x + </span>1<span class="">;</span>
<span class="Identifier">}</span>
</pre>
+1

Source: https://habr.com/ru/post/1731508/


All Articles