-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathximera.cfg
174 lines (136 loc) · 6.52 KB
/
ximera.cfg
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
\usepackage{verbatim}
\usepackage{fancyvrb}
\Preamble{xhtml}
\DeclareGraphicsExtensions{.jpg,.png,.gif,.svg}
% We don't want to translate font suggestions with ugly wrappers like
% <span class="cmti-10"> for italic text
\NoFonts
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Include the "jax"ed newcommands
% Remove commands that use @
\immediate\write18{sed -i "/@/d" \jobname.jax}
% Replace ##1 with #1 and so forth
\immediate\write18{sed -i "s/\string#\string#\string\\([0-9]\string\\)/\string#\string\\1/g" \jobname.jax}
\Configure{BVerbatimInput}{}{}{}{}
\Configure{verbatiminput}{}{}{}{}
% Instead of a nonbreaking space, use a standard space
\makeatletter
\def\FV@Space{\space}
\makeatother
% Include the mathjax newcommands in a math/tex script right at the beginning of the body
\Configure{BODY}{%
\HCode{<body>\Hnewline}%
\Tg<div class="preamble">%
\Tg<script type="math/tex">%
\BVerbatimInput{\jobname.jax}%
\Tg</script>%
% and load the sagetex file if it was generated
\IfFileExists{\jobname.sagetex.sout}{\Tg<script type="math/tex">%
\BVerbatimInput{\jobname.sagetex.sout}%
\Tg</script>}{}%
\IfFileExists{\jobname.ids}{\HCode{<script type="text/javascript">\Hnewline}%
\BVerbatimInput{\jobname.ids}%
\HCode{</script>\Hnewline}%
\Tg</div>%
}{}
}{%
\HCode{</body>\Hnewline}%
}
% Don't output xml version tag
\Configure{VERSION}{}
% Output HTML5 doctype instead of the default for HTML4
\Configure{DOCTYPE}{\HCode{<!doctype html>\Hnewline}}
% Custom page opening
\Configure{HTML}{\HCode{<html lang="en">\Hnewline}}{\HCode{\Hnewline</html>}}
%\Configure{HTML}{}{}
% Reset <head>, aka delete all default boilerplate; alternatively set up new content
\Configure{@HEAD}{\HCode{<meta charset="UTF-8" />\Hnewline}}
\Configure{@HEAD}{\HCode{<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/\string~gurari/TeX4ht/)" />\Hnewline}}
\Configure{@HEAD}{\HCode{<meta name="ximera" content="version 0.0.1" />\Hnewline}}
\Configure{@HEAD}{\HCode{<link href="http://ximera.osu.edu/public/static/base.min.css" rel="stylesheet" media="screen"/>\Hnewline}}
\Configure{@HEAD}{\HCode{<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>\Hnewline}}
\Configure{@HEAD}{\HCode{<script data-module="script" data-main="http://ximera.osu.edu/public/javascripts/app.min" src="http://ximera.osu.edu/components/requirejs/require.js"></script>\Hnewline}}
% Translate \textbf, \textit and \texttt directives into <b>, <em> and <code>
\Configure{textbf}{\ifvmode\ShowPar\fi\HCode{<strong>}}{\HCode{</strong>}}
\Configure{textit}{\ifvmode\ShowPar\fi\HCode{<em>}}{\HCode{</em>}}
\Configure{texttt}{\ifvmode\ShowPar\fi\HCode{<code>}}{\HCode{</code>}}
\Configure{emph}{\ifvmode\ShowPar\fi\HCode{<em>}}{\HCode{</em>}}
% Translate verbatim and lstlisting blocks into <pre> elements
\ConfigureEnv{verbatim}{\HCode{<pre>}}{\HCode{</pre>}}{}{}
\ConfigureEnv{lstlisting}{\HCode{<pre>}}{\HCode{</pre>}}{}{}
% Should I avoid setting `indent`/`noindent` classes on paragraphs? I am not sure yet.
% \Configure{HtmlPar}
% {\EndP\Tg<p>}
% {\EndP\Tg<p>}
% {\HCode{</p>\Hnewline}}
% {\HCode{</p>\Hnewline}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Outcomes
% These can appear in either the preamble or in problem-environments;
% with pdflatex, we produce the .oc file which includes ALL the
% outcomes; in the tex4ht world, we just produce spans for the
% specific outcomes.
\renewcommand{\outcome}[1]{
\Configure{@HEAD}{\HCode{<meta name="learning-outcome" content="#1"/>\Hnewline}}
}
% Sometimes there are no outcomes at all
\IfFileExists{\jobname.oc}{\input{\jobname.oc}}{}
\renewcommand{\outcome}[1]{%
\HCode{<span class="learning-outcome">#1</span>}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Now I just need to add a \newcommand command which outputs the appropriate newcommands to MathJax; then this should be "good enough" for our purposes.
\newtoks\eqtoks
\def\AltMath#1${\eqtoks{#1}%
\HCode{<script type="math/tex"> <![CDATA[\Hnewline\the\eqtoks\Hnewline ]]>\Hnewline</script>}$}
\Configure{$}{}{}{\expandafter\AltMath}
\def\AltlMathI#1\){\eqtoks{#1}%
\HCode{<script type="math/tex"> <![CDATA[\Hnewline\the\eqtoks\Hnewline ]]>\Hnewline</script>}\)}
\Configure{()}{\AltlMathI}{}
\def\AltlDisplay#1\]{\eqtoks{#1}%
\HCode{<script type="math/tex; mode=display"> <![CDATA[\Hnewline\the\eqtoks\Hnewline ]]>\Hnewline</script>}\]}
\Configure{[]}{\AltlDisplay}{}
\def\AltlDisplayI#1$${\eqtoks{#1}%
\HCode{<script type="math/tex; mode=display"> <![CDATA[\Hnewline\the\eqtoks\Hnewline ]]>\Hnewline</script>}$$}
\Configure{$$}{}{}{\expandafter\AltlDisplayI}
\begin{document}
% Need to turn off htmlpar too, as expained in http://tex.stackexchange.com/questions/204930/vertical-spaces-in-htlatex-scriptenv
\newcommand\VerbMath[1]{%
\renewenvironment{#1}{\NoFonts}{\EndNoFonts}
\ScriptEnv{#1}{\ifvmode \IgnorePar\fi \EndP\HCode{<script type="math/tex; mode=display"><![CDATA[\Hnewline \string\begin{#1}\Hnewline}\HtmlParOff}{\HtmlParOn\HCode{\string\end{#1}\Hnewline]]>\Hnewline</script>}}
}
\makeatletter
\Configure{graphics*}
{svg}{
{\Configure{Needs}{File: \Gin@base.svg}\Needs{}}
\Picture[\csname a:GraphicsAlt\endcsname]{\csname Gin@base\endcsname.svg \csname a:Gin-dim\endcsname}%
}
\makeatother
% The abstract has been stored in \theabstract and should be emitted as a div, but confusingly I guess <div class="abstract"> is defined somewhere deeper inside tex4ht, so actually the code below is unnecessary.
\let\abstract\relax
\let\endabstract\relax
%\renewenvironment{abstract}{\ifvmode \IgnorePar\fi \EndP\HCode{<div class="abstract">}}{\HCode{</div>}}
%\ConfigureEnv{abstract}{}{}{}{}
%\ConfigureEnv{abstract}{\ifvmode \IgnorePar\fi \EndP\HCode{<div class="abstract">}}{\theabstract\HCode{</div>}}{}{}
% Get rid of the title block
%\Configure{maketitle}{}{}
\VerbMath{equation}
\VerbMath{equation*}
\VerbMath{align}
\VerbMath{align*}
\VerbMath{alignat}
\VerbMath{alignat*}
\VerbMath{eqnarray}
\VerbMath{eqnarray*}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This is a hack to kill includegraphics commands in \documentclass{standalone} files
\ifcsname ifstandalone\endcsname
\ifstandalone
\renewcommand\includegraphics[2][]{}
\fi
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph commands emit spans
\renewcommand{\paragraph}[1]{\HCode{<span class="paragraphHead">}#1\HCode{</span>}\par\IgnorePar}
\renewcommand{\subparagraph}[1]{\HCode{<span class="subparagraphHead">}#1\HCode{</span>}\par\IgnorePar}
\EndPreamble