summaryrefslogtreecommitdiff
path: root/support/TeX4ht/source/tex4ht-html5.tex
blob: 72dc22a75300fe9fbad13fe793440a0faed06ff8 (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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
% $Id: tex4ht-html5.tex 1062 2022-01-23 15:51:43Z karl $
% compile 3 times: latex tex4ht-moz
%           or   xhlatex tex4ht-moz "html,3,sections+"
%
% Copyright 2009-2022 TeX Users Group
% Copyright 2000-2009 Eitan M. Gurari
% Released under LPPL 1.3c+.
% See tex4ht-cpright.tex for license text.

%%%%%%%%%%%%%%%%%% load style files %%%%%%%%%%%%%%%%%%%%%%%%%%

\ifx \HTML\UnDef
   \def\HTML{html5}                   
   \def\CONFIG{\jobname}
   \def\MAKETITLE{\author{Eitan M. Gurari}}         
   \def\next{\input mktex4ht.4ht  \endinput}
   \expandafter\next
\fi

\input{common.tex}
\input{tex4ht-cpright.tex}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Preamble}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<html5\><<<
% html5.4ht (|version), generated from |jobname.tex
% Copyright 2016-2022 TeX Users Group
|<TeX4ht copywrite|>
>>>

  



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Basic configurations}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{HTML5 structure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\<configure html5 tex4ht\><<<
|<patch charset|>
\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html lang="\Get:Language" xml:lang="\Get:Language" \html:xmlns>\Hnewline}}{\HCode{\Hnewline</html>}}
\Configure{@HEAD}{}
\Configure{@HEAD}{\HCode{<meta \use:charset />\Hnewline}}
\Configure{@HEAD}{\HCode{<meta name="generator" content="TeX4ht
(https://tug.org/tex4ht/)" />\Hnewline}}
\Configure{@HEAD}{\HCode{<meta name="viewport" content="width=device-width,initial-scale=1" />\Hnewline}}
\Configure{@HEAD}{\HCode{<link
             rel="stylesheet" type="text/css"
                      href="\expandafter\csname aa:CssFile\endcsname" />\Hnewline}}
\Configure{@HEAD}
   {\HCode{<meta name="src"
                 content="\jobname.tex"\xml:empty>\Hnewline}} 
\:CheckOption{timestamp}\if:Option
\Configure{@HEAD}
   {\HCode{<meta name="date"
                 content="\:today"\xml:empty>\Hnewline}} 
\else
  \Log:Note{To print a timestamp, use the command line option timestamp}
\fi
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Language and charset setting}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Charset can be set using charset=charsetcode option for tex4ht.sty. It is saved in \verb|\a:charset| macro. 
If charset oprion isn't used, \verb|\A:charset| is used instead. Bot of these macros store the charset information
in charset=name form. We need to add quotes around name in html5, thus the following macro.

\<patch charset\><<<

\def\:charset:quotes#1=#2.{
  #1="#2"%
}
\def\use:charset{%
  \expandafter\ifx\csname a:charset\endcsname\relax%
    \expandafter\expandafter\expandafter\:charset:quotes\csname A:charset\endcsname.
  \else%
    \expandafter\expandafter\expandafter\:charset:quotes\csname a:charset\endcsname.
  \fi
}
>>>


We can interfere the document language from \verb|\bbl@main@language| macro. It
is supported by both Babel and Polyglossia.

\<configure html5 tex4ht\><<<
\def\Declare:Language#1#2{%
\expandafter\gdef\csname rfclang#1\endcsname{#2}%
}
\def\Get:Language{%
\ifx\bbl@main@language\@undefined en-US%  
\else%
\expandafter\ifdefined\csname rfclang\bbl@main@language\endcsname \csname rfclang\bbl@main@language\endcsname\fi%
\fi%
}

\Declare:Language{UKenglish}{en}
\Declare:Language{USenglish}{en}
\Declare:Language{latex}{en}
\Declare:Language{acadian}{fr}
\Declare:Language{albanian}{sq}
\Declare:Language{american}{en}
\Declare:Language{amharic}{am}
\Declare:Language{arabic}{ar}
\Declare:Language{armenian}{hy}
\Declare:Language{australian}{en}
\Declare:Language{austrian}{de}
\Declare:Language{basque}{eu}
\Declare:Language{bengali}{bn}
\Declare:Language{brazilian}{pt}
\Declare:Language{brazil}{pt}
\Declare:Language{breton}{br}
\Declare:Language{british}{en}
\Declare:Language{bulgarian}{bg}
\Declare:Language{canadian}{en}
\Declare:Language{canadien}{fr}
\Declare:Language{catalan}{ca}
\Declare:Language{croatian}{hr}
\Declare:Language{czech}{cs}
\Declare:Language{danish}{da}
\Declare:Language{divehi}{dv}
\Declare:Language{dutch}{nl}
\Declare:Language{english}{en}
\Declare:Language{esperanto}{eo}
\Declare:Language{estonian}{et}
\Declare:Language{finnish}{f\/i}
\Declare:Language{francais}{fr}
\Declare:Language{french}{fr}
\Declare:Language{galician}{gl}
\Declare:Language{germanb}{de}
\Declare:Language{german}{de}
\Declare:Language{greek}{el}
\Declare:Language{hebrew}{he}
\Declare:Language{hindi}{hi}
\Declare:Language{hungarian}{hu}
\Declare:Language{icelandic}{is}
\Declare:Language{interlingua}{ia}
\Declare:Language{irish}{ga}
\Declare:Language{italian}{it}
\Declare:Language{kannada}{kn}
\Declare:Language{khmer}{km}
\Declare:Language{korean}{ko}
\Declare:Language{lao}{lo}
\Declare:Language{latin}{la}
\Declare:Language{latvian}{lv}
\Declare:Language{lithuanian}{lt}
\Declare:Language{lowersorbian}{dsb}
\Declare:Language{magyar}{hu}
\Declare:Language{malayalam}{ml}
\Declare:Language{marathi}{mr}
\Declare:Language{naustrian}{de}
\Declare:Language{newzealand}{en}
\Declare:Language{ngerman}{de}
\Declare:Language{norsk}{no}
\Declare:Language{norwegiannynorsk}{nn}
\Declare:Language{nynorsk}{no}
\Declare:Language{occitan}{oc}
\Declare:Language{oldchurchslavonic}{cu}
\Declare:Language{persian}{fa}
\Declare:Language{polish}{pl}
\Declare:Language{polutonikogreek}{el}
\Declare:Language{portuges}{pt}
\Declare:Language{portuguese}{pt}
\Declare:Language{romanian}{ro}
\Declare:Language{romansh}{rm}
\Declare:Language{russian}{ru}
\Declare:Language{samin}{se}
\Declare:Language{sanskrit}{sa}
\Declare:Language{scottish}{gd}
\Declare:Language{serbian}{sr}
\Declare:Language{serbo-croatian}{sh}
\Declare:Language{slovak}{sk}
\Declare:Language{slovene}{sl}
\Declare:Language{slovenian}{sl}
\Declare:Language{spanish}{es}
\Declare:Language{swedish}{sv}
\Declare:Language{tamil}{ta}
\Declare:Language{telugu}{te}
\Declare:Language{thai}{th}
\Declare:Language{tibetan}{bo}
\Declare:Language{turkish}{tr}
\Declare:Language{turkmen}{tk}
\Declare:Language{ukrainian}{uk}
\Declare:Language{uppersorbian}{hsb}
\Declare:Language{urdu}{ur}
\Declare:Language{vietnamese}{vi}
\Declare:Language{welsh}{cy}
>>>

Support for xml name spaces. It must be configured after
\verb|\begin{document}| in the configuration file.

\<configure html5 tex4ht\><<<
\edef\html:xmlns{}
\NewConfigure{xmlns}[2]{%
  \ifx\relax#2\relax%
    \edef\html:xmlns{}%
  \else%
    \edef\html:xmlns{\html:xmlns xmlns\ifx\relax#1\relax\else :#1\fi="#2"}%
  \fi%
}
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{LaTeX and classes configurations}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\section{LaTeX}

\<configure html5 latex\><<<
|<tabular fixes|>
>>>

\section{Article, book and report classes}
\<configure html5 article\><<<
|<article,report,book|>
|<article,report|>
>>>

\<configure html5 book\><<<
|<article,report,book|>
>>>

\<configure html5 report\><<<
|<article,report,book|>
|<article,report|>
>>>

Shared configurations for base LaTeX classes.

\<article,report,book\><<<
|<figcaption|>
>>>

Configurations that are shared only for article and report

\<article,report\><<<
|<abstract|>
>>>


\section{Configurations for Koma Script}

\<configure html5 scrartcl\><<<
|<scr article,report,book|>
>>>

\<configure html5 scrbook\><<<
|<scr article,report,book|>
>>>

\<configure html5 scrreprt\><<<
|<scr article,report,book|>
>>>

\<scr article,report,book\><<<
|<figcaption|>
>>>

\section{Configurations for AMS classes}

\<configure html5 amsart\><<<
|<ams art,proc,book|>
>>>

\<configure html5 amsproc\><<<
|<ams art,proc,book|>
>>>

\<configure html5 amsbook\><<<
|<ams art,proc,book|>
>>>


\<ams art,proc,book\><<<
|<figcaption|>
>>>

\section{Configurations for Memoir}

\<configure html5 memoir\><<<
|<figcaption|>
|<abstract|>
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Packages configuration}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Logical structure configurations}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Tables}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

cellspacing and cellpading attributes are prohibited in html5

\<tabular fixes\><<<
\Configure{halignTB<>}{tabular}{\HCode{id="TBL-\TableNo"  class="tabular"\Hnewline \GROUPS\Hnewline
   }<>\HAlign}
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Figures}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Configure HTML5 figures. Floats are converted as captions too.

\<figcaption\><<<
\Configure{float}
   {\ifOption{refcaption}{}{\csname par\endcsname\ShowPar \leavevmode}}
     {\:xhtml{\IgnorePar\EndP}\HCode{<figure class="float"\Hnewline>}}
   {\ifvmode \IgnorePar \fi\EndP
     \HCode{</figure>}\csname par\endcsname\ShowPar}

\ConfigureEnv{figure}
{\:xhtml{\IgnorePar\EndP}\HCode{<figure class="figure">\Hnewline}%
    \bgroup \Configure{float}{\ShowPar}{}{}%    
   }
   {\egroup
   \:xhtml{\IgnorePar\EndP}\HCode{</figure>}|<try env inline par|>\par}
   {}{}

\Css{figure.float, div.figure {margin-left: auto; margin-right: auto;}}
\Css{figure.figure {text-align:center;}}

\Configure{caption}{\:xhtml{\IgnorePar\EndP}\HCode{<figcaption class="caption" ><span class="id">}}
   {: } {\HCode{</span><span \Hnewline class="content">}}
   {\HCode{</span></figcaption>}\HCode{<!--tex4ht:label?:
   \cur:th\:currentlabel\space-->}%
}
\Css{figcaption.caption {text-indent:-2em; margin-left:3em; margin-right:1em;
                  text-align:center;}}
\Css{figcaption.caption span.id{font-weight: bold; white-space: nowrap; }}
\Css{p + figcaption, img + figcaption{margin-top: 1em;}}
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Abstracts}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



\<abstract\><<<
\ConfigureEnv{abstract}
{\ifvmode\IgnorePar\fi\EndP\HCode{<section role="doc-abstract" class="abstract">\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\HCode{</section>}\par}{}{}

\Css{.abstract{margin:1em;}}
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Utilities}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<try env inline par\><<<
\ShowPar 
>>>

\endinput