x-lmx-html.mkiv /size: 2896 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [       file=x-lmx-html,
3%D        version=2018.03.10,
4%D          title=\CONTEXT\ Modules,
5%D       subtitle=Simple LMX HTML rendering (from text fields),
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14%D This is old code that we used in several places so it qualifies as a
15%D proper module. It is means for generating simple \HTML\ from filled
16%D in forms. It's not a general purpose \HTML\ rendering.
17
18\startmodule[lmx-html]
19
20\startxmlsetups lmx:html:setup
21    \xmlsetsetup{#1}{*}{lmx:html:*}
22    \xmlflush{#1}
23\stopxmlsetups
24
25\startxmlsetups lmx:html:ul
26    \startitemize[packed]
27        \xmlflush{#1}
28    \stopitemize
29\stopxmlsetups
30
31\startxmlsetups lmx:html:ol
32    \startitemize[packed,n]
33        \xmlflush{#1}
34    \stopitemize
35\stopxmlsetups
36
37\startxmlsetups lmx:html:li
38    \startitem
39        \xmlflush{#1}
40    \stopitem
41\stopxmlsetups
42
43\startxmlsetups lmx:html:p
44    \xmlflush{#1}\par
45\stopxmlsetups
46
47\startxmlsetups lmx:html:br
48    \par
49\stopxmlsetups
50
51\startxmlsetups lmx:html:a
52    \dontleavehmode
53    \begingroup
54    \tttf
55    \xmldoifelsetext {#1} {.} {
56        \goto{\hyphenatedurl{\xmlflush{#1}}}[url(\xmlatt{#1}{href})]
57    } {
58        \goto{\hyphenatedurl{\xmlatt{#1}{href}}}[url(\xmlatt{#1}{href})]
59    }
60    \endgroup
61\stopxmlsetups
62
63\startxmlsetups lmx:html:em
64    \dontleavehmode
65    \begingroup\em\xmlflush{#1}\endgroup
66\stopxmlsetups
67
68\startxmlsetups lmx:html:b
69    \dontleavehmode
70    \begingroup\bf\xmlflush{#1}\endgroup
71\stopxmlsetups
72
73\startxmlsetups lmx:html:i
74    \dontleavehmode
75    \begingroup\it\xmlflush{#1}\endgroup
76\stopxmlsetups
77
78\startxmlsetups lmx:html:strong
79    \dontleavehmode
80    \begingroup\bf\xmlflush{#1}\endgroup
81\stopxmlsetups
82
83\startxmlsetups lmx:html:tt
84    \dontleavehmode
85    \begingroup\tt\xmlflush{#1}\endgroup
86\stopxmlsetups
87
88% \startxmlsetups lmx:html:span
89%     \dontleavehmode
90%     \ctxcommand{doifelse(string.find([[ \xmlatt{#1}{style} ]],"underline"))} {
91%         \underbar{\xmlflush{#1}}
92%     } {
93%         \xmlflush{#1}
94%     }
95% \stopxmlsetups
96
97\xmlmapvalue{text-decoration}{underline}{\directsetbar{underbar}}
98\xmlmapvalue{text-decoration}{overline} {\directsetbar{overbar}}
99
100\startxmlsetups lmx:html:span
101    \dontleavehmode
102    \begingroup
103    \xmlcssmappedstylevalue{#1}{text-decoration}{text-decoration}
104    \xmlflush{#1}
105    \endgroup
106\stopxmlsetups
107
108\startxmlsetups lmx:html:html
109    \xmlflush{#1}% should not be needed but we self tag .. needs checking
110\stopxmlsetups
111
112\startluacode
113    local texfinalizers = xml.finalizers.tex
114
115    function texfinalizers.html(collected,setup)
116        texfinalizers.xml(collected,"html",setup)
117    end
118\stopluacode
119
120% \xmlfilter{...}{/.../html()}
121
122\stopmodule
123