summaryrefslogtreecommitdiff
path: root/support/TeX4ht/source/tex4ht-jats.tex
blob: 61a087788fb971242092c07e09ddc6a5a2624c77 (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
% $Id: tex4ht-jats.tex 269 2020-03-03 23:06:07Z karl $
% compile 3 times: latex tex4ht-jats
%           or   xhlatex tex4ht-jats "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{jats}                   
   \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}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Basic information}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

JATS support in TeX4ht is based on HTML and MathML configurations. 
Unsupported elements will be converted using make4ht DOM filters. 
Filters will be used also for the document structure, as JATS wants some
elements in the back (bibliography, etc.)

Only basic structures will be configured by hand in this configuration 
file.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Package configurations}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Basic system}

\<configure jats tex4ht\><<<
\special{t4ht.xml}
|<xml structure|>
|<document structure|>
|<basic hyperlinks|>
|<basic fonts|>
|<basic jats mathml|>
>>>

\<configure jats latex\><<<
|<latex fonts|>
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Classes}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<configure jats article\><<<
|<latex sections|>
>>>

\<configure jats book\><<<
|<latex chapters|>
|<latex sections|>
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Packages}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<configure jats url\><<<
|<url links|>
>>>

\<configure jats hyperref\><<<
|<hyperref links|>
>>>

\<xml structure\><<<
\Configure{VERSION}{\HCode{<?xml version="1.0" encoding="UTF-8"?>\Hnewline}}

% select JATS version
\NewConfigure{DtdVersion}{1}
\Configure{DtdVersion}{1.3}

\Configure{DOCTYPE}{\HCode{<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v\a:DtdVersion\space 20130915//EN" "http://jats.nlm.nih.gov/archiving/\a:DtdVersion/JATS-archivearticle1-mathml3.dtd">\Hnewline}}

% XML configuratins
\edef\html:xmlns{}
\NewConfigure{xmlns}[2]{\concat:config\html:xmlns{xmlns:#1="#2"\Hnewline}}
\Configure{xmlns}{xlink}{http://www.w3.org/1999/xlink}
\Configure{xmlns}{mml}{http://www.w3.org/1998/Math/MathML}

\Configure{HTML}{\HCode{<article dtd-version="\a:DtdVersion" \html:xmlns>\Hnewline}}{\HCode{\Hnewline</article>}}
\Configure{@HEAD}{}
\Configure{HEAD}{\HCode{<front>}}{\HCode{</front>}}
% Add header structure
% Journal info in <journal-meta>. It needs to be provided fully from the user configuration
\NewConfigure{JournalMeta}{1}
% basic article meta can be reconstructed from \title and \author
% 
% Title needs to be placed at the correct place by DOM filter
\Configure{TITLE}{\HCode{<article-title>}}{\HCode{</article-title>}}
\NewConfigure{ArticleMeta}{1}
  \Configure{ArticleMeta}{
  \HCode{<article-meta>}%
    % title from \title command is placed by make4ht DOM filter. If you want more complex title, 
    % use \Configure{TitleGroup}
    \a:TitleGroup%
    \JATS:Contributors%
  \HCode{</article-meta>}%
}
% enable to configure contributors
\def\JATS:Contributors{}
\NewConfigure{Contributor}[1]{\concat:config\JATS:Contributors{#1}}
\NewConfigure{TitleGroup}{1}

% insert metas into document header
\Configure{@HEAD}{\a:JournalMeta}
\Configure{@HEAD}{\a:ArticleMeta}
>>>

\<document structure\><<<
\Configure{HtmlPar}
  {\EndP\HCode{|<show input line no|><p \csname a:!P\endcsname>}}
  {\EndP\HCode{|<show input line no|><p \csname a:!P\endcsname>}}
  {\Tg</p>}%
  {\Tg</p>}%
>>>

\<show input line no\><<<
<!--l. \the\inputlineno-->%
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Hyperlinks}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\<basic hyperlinks\><<<
\Configure{Link}{xref}{rid=}{id=}{\empty}   
\LinkCommand\ExternalLink{ext-link,xlink:href,id}
>>>


\<url links\><<<
\Configure{url}%
     {\tmp:toks{#1}\ExternalLink[\noexpand\the\tmp:toks]{}{}{\let\UrlBigBreaks\empty
                         \let\UrlBreaks\empty #1}\EndExternalLink}
>>>

\<hyperref links\><<<
>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Math}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MathML in JATS must use the mml: prefix

\<basic jats mathml\><<<
\Configure{mathml}{mml:}
>>>

Inline and display math should use different elements for their
inclusion. We need to keep stack of the opened elements, as 
math can be nested.

For some reason, this configuration is called too early, resulting
in compilation error. We thus use AtBeginDocument to postpone it.

\<basic jats mathml\><<<
\edef\math:type:inline{display="inline" }

\ifdefined\AtBeginDocument
\AtBeginDocument{
  \Configure{DviMathML}{%
    \ifx\a:@math\math:type:inline%
    \PushStack\math:types{inline-formula}%
    \HCode{<inline-formula>}%
    \else%
    \HCode{<disp-formula>}%
    \PushStack\math:types{disp-formula}%
    \fi%
  }{\PopStack\math:types\:temp\HCode{</\:temp>}}%
}%
\fi

>>>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Fonts}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

JATS doesn't support any attributes for fonts, so the information
about font name and size is lost.

\<basic fonts\><<<
\Configure{htf}{0}{+}{<italic}{}{}{}{}{>}{</italic>}
\Configure{htf}{4}{+}{<sc}{}{}{}{}{>}{</sc>}
\Configure{htf}{6}{+}{<underline}{}{}{}{}{>}{</underline>}
>>>

\<latex fonts\><<<
\Configure{textit}{\Protect\HCode{<italic>}\NoFonts}{\EndNoFonts\Protect\Tg</italic>}
\Configure{textbf}{\Protect\HCode{<bold>}\NoFonts}{\EndNoFonts\Protect\Tg</bold>}
\Configure{textsc}{\Protect\HCode{<sc>}\NoFonts}{\EndNoFonts\Protect\Tg</sc>}
\Configure{textrm}{\Protect\HCode{<roman>}\NoFonts}
                    {\EndNoFonts\Protect\HCode{</roman>}}
\Configure{textup}{\Protect\HCode{<span class="textup">}\NoFonts}
                    {\EndNoFonts\Protect\HCode{</span>}}  
\Configure{textsf}{\Protect\HCode{<sans-serif>}\NoFonts}
                    {\EndNoFonts\Protect\HCode{</sans-serif>}}  
\Configure{textsl}{\Protect\HCode{<italic>}\NoFonts}
                    {\EndNoFonts\Protect\HCode{</italic>}}
\Configure{texttt}{\Protect\HCode{<monospace>}\NoFonts}
                    {\EndNoFonts\Protect\HCode{</monospace>}}
\Configure{emph}{\Protect\HCode{<italic>}\NoFonts}
                    {\EndNoFonts\Protect\HCode{</italic>}}

\Configure{underline}
   {\HCode{<underline>}\:gobble}
   {\HCode{</underline>}}

\Configure{textsuperscript}
  {\HCode{<sup>}}
  {\HCode{</sup>}}

\Configure{textsubscript}
  {\HCode{<sub>}}
  {\HCode{</sub>}}
>>>



\<latex chapters\><<<
\Configure{chapter}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
   {\TitleMark\HCode{<title>}\space\HtmlParOff}
   {\HCode{</title>}\HtmlParOn \ShowPar\par}

\ConfigureMark{chapter}
   {\if@mainmatter
       \HCode{<label>}\chaptername\ \thechapter\HCode{</label>}\fi}

\Configure{likechapter}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
   {\HCode{<title>}\space\HtmlParOff}
   {\HCode{</title>}\HtmlParOn \ShowPar\par}

\Configure{appendix}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
   {\TitleMark\HCode{<title>}\space\HtmlParOff}
   {\HCode{</title>}\HtmlParOn \ShowPar\par}

\ConfigureMark{appendix}{\HCode{<label>}%
   \appendixname\ \thechapter\HCode{</label>}}
>>>

\<latex sections\><<<

\Configure{section}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
   {\TitleMark\HCode{<title>}\space\HtmlParOff}
   {\HCode{</title>}\HtmlParOn \ShowPar\par}

\ConfigureMark{section}
   {\ifnum \c:secnumdepth>\c@secnumdepth \expandafter\:gobble
    \else
       \HCode{<label>}\@seccntformat{section}%
       \HCode{</label>}\fi }

\Configure{likesection}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
   {\HCode{<title>}\space\HtmlParOff}
   {\HCode{</title>}\HtmlParOn \ShowPar\par}

\Configure{subsection}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
   {\TitleMark\HCode{<title>}\space\HtmlParOff}
   {\HCode{</title>}\HtmlParOn \ShowPar\par}

\ConfigureMark{subsection}
   {\ifnum \c:secnumdepth>\c@secnumdepth \expandafter\:gobble
    \else
       \HCode{<label>}\@seccntformat{section}%
       \HCode{</label>}\fi }

\Configure{likesubsection}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
   {\HCode{<title>}\space\HtmlParOff}
   {\HCode{</title>}\HtmlParOn \ShowPar\par}

\Configure{subsubsection}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
   {\TitleMark\HCode{<title>}\space\HtmlParOff}
   {\HCode{</title>}\HtmlParOn \ShowPar\par}

\ConfigureMark{subsubsection}
   {\ifnum \c:secnumdepth>\c@secnumdepth \expandafter\:gobble
    \else
       \HCode{<label>}\@seccntformat{section}%
       \HCode{</label>}\fi }

\Configure{likesubsubsection}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
   {\HCode{<title>}\space\HtmlParOff}
   {\HCode{</title>}\HtmlParOn \ShowPar\par}

\Configure{paragraph}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
   {\HCode{<title>}\space\HtmlParOff}
   {\HCode{</title>}\HtmlParOn \ShowPar\par}


\Configure{likeparagraph}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
   {\HCode{<title>}\space\HtmlParOff}
   {\HCode{</title>}\HtmlParOn \ShowPar\par}
>>>


\endinput