summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/modules/mkiv/x-lmx-html.mkiv
blob: 3195ef40e40d0cd114a780c80abccaf595bb65be (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
%D \module
%D   [       file=x-lmx-html,
%D        version=2018.03.10,
%D          title=\CONTEXT\ Modules,
%D       subtitle=Simple LMX HTML rendering (from text fields),
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D This is old code that we used in several places so it qualifies as a
%D proper module. It is means for generating simple \HTML\ from filled
%D in forms. It's not a general purpose \HTML\ rendering.

\startmodule[lmx-html]

\startxmlsetups lmx:html:setup
    \xmlsetsetup{#1}{*}{lmx:html:*}
    \xmlflush{#1}
\stopxmlsetups

\startxmlsetups lmx:html:ul
    \startitemize[packed]
        \xmlflush{#1}
    \stopitemize
\stopxmlsetups

\startxmlsetups lmx:html:ol
    \startitemize[packed,n]
        \xmlflush{#1}
    \stopitemize
\stopxmlsetups

\startxmlsetups lmx:html:li
    \startitem
        \xmlflush{#1}
    \stopitem
\stopxmlsetups

\startxmlsetups lmx:html:p
    \xmlflush{#1}\par
\stopxmlsetups

\startxmlsetups lmx:html:br
    \par
\stopxmlsetups

\startxmlsetups lmx:html:a
    \dontleavehmode
    \begingroup
    \tttf
    \xmldoifelsetext {#1} {.} {
        \goto{\hyphenatedurl{\xmlflush{#1}}}[url(\xmlatt{#1}{href})]
    } {
        \goto{\hyphenatedurl{\xmlatt{#1}{href}}}[url(\xmlatt{#1}{href})]
    }
    \endgroup
\stopxmlsetups

\startxmlsetups lmx:html:em
    \dontleavehmode
    \begingroup\em\xmlflush{#1}\endgroup
\stopxmlsetups

\startxmlsetups lmx:html:b
    \dontleavehmode
    \begingroup\bf\xmlflush{#1}\endgroup
\stopxmlsetups

\startxmlsetups lmx:html:i
    \dontleavehmode
    \begingroup\it\xmlflush{#1}\endgroup
\stopxmlsetups

\startxmlsetups lmx:html:strong
    \dontleavehmode
    \begingroup\bf\xmlflush{#1}\endgroup
\stopxmlsetups

\startxmlsetups lmx:html:tt
    \dontleavehmode
    \begingroup\tt\xmlflush{#1}\endgroup
\stopxmlsetups

% \startxmlsetups lmx:html:span
%     \dontleavehmode
%     \ctxcommand{doifelse(string.find([[ \xmlatt{#1}{style} ]],"underline"))} {
%         \underbar{\xmlflush{#1}}
%     } {
%         \xmlflush{#1}
%     }
% \stopxmlsetups

\xmlmapvalue{text-decoration}{underline}{\directsetbar{underbar}}
\xmlmapvalue{text-decoration}{overline} {\directsetbar{overbar}}

\startxmlsetups lmx:html:span
    \dontleavehmode
    \begingroup
    \xmlcssmappedstylevalue{#1}{text-decoration}{text-decoration}
    \xmlflush{#1}
    \endgroup
\stopxmlsetups

\startxmlsetups lmx:html:html
    \xmlflush{#1}% should not be needed but we self tag .. needs checking
\stopxmlsetups

\startluacode
    local texfinalizers = xml.finalizers.tex

    function texfinalizers.html(collected,setup)
        texfinalizers.xml(collected,"html",setup)
    end
\stopluacode

% \xmlfilter{...}{/.../html()}

\stopmodule