blob: 79c94d1999be624d37913d02d42008a9b0e0d1ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
%% This is part of the OpTeX project, see http://petr.olsak.net/optex
\_codedecl\_hisyntaxhtml {Syntax highlighting for html or xml sources <2022-05-12>}
\_newtoks\_hisyntaxhtml \_newtoks\_hicolorshtml
\_global\_hicolorshtml={% colors in html codes
\_hicolor A \Cyan % <, > and parameters
\_hicolor T \Red % tag names
\_hicolor C \Green % comments
\_hicolor E \Blue % HTML entities
\_hicolor S \Magenta % strings in parameters
}
\_global\_hisyntaxhtml={
\_the\_hicolorshtml
\_replfromto{<!--}{-->}{\x C{<!--#1-->}}
\_replthis{<}{\y{_hitaghtml}}
\_replthis{\_string&}{\y{_hientityhtml}}
}
\_bgroup \_lccode`\~=`\ \_lowercase{\_egroup
\_gdef\_hitaghtml#1>{\_hitaghtmlA#1~>}
\_gdef\_hitaghtmlA#1~#2>}{\z A{<}\z T{#1}\_def\_tmpb{#2^}%
\_if^\_tmpb
\_else \_space
\_replthis{\ ^}{}\_replfromto{"}{"}{\_histringhtml{"##1"}}\z A{\_tmpb}\_fi
\z A{>}%
}
\_gdef\_histringhtml#1{\_visiblesp \z S{#1}}
\_gdef\_hientityhtml#1;{\z E{\}}
\_endcode %------------------------------------------------
2022-05-12 \_hitaghtmlA #1~#2: bug fixed
2020-04-03 released
|