git.iko.soy/typeable/pandoc
on master help sign in
Restored and undeprecated gladtex for HTML math.

- Added `GladTeX` constructor to `Text.Pandoc.Options.HTMLMathMethod` [API change, reverts removal in v2.2] - Restored and undeprecated `--gladtex` option, removed in v2.2. Closes #4607.

commitb7356d3ddf788d83b41b1100d718087bd83a7506 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 9 May 2018, 11:29 (8 years ago) parentd3be567
5 files changed+67−7
MANUAL.txt+12 man/pandoc.1+40−6 src/Text/Pandoc/App.hs+6 src/Text/Pandoc/Options.hs+1 src/Text/Pandoc/Writers/HTML.hs+8−1
MANUAL.txt+12
@@ -1217,9 +1217,21 @@ of the following options.
12171217 not specified, a link to the KaTeX CDN will be inserted. Note that this
12181218 option does not imply `--katex`.
12191219
1220+`--gladtex`
1221+
1222+: Enclose TeX math in `<eq>` tags in HTML output. The resulting HTML
1223+ can then be processed by [GladTeX] to produce images of the typeset
1224+ formulas and an HTML file with links to these images.
1225+ So, the procedure is:
1226+
1227+ pandoc -s --gladtex input.md -o myfile.htex
1228+ gladtex -d myfile-images myfile.htex
1229+ # produces myfile.html and images in myfile-images
1230+
12201231[MathML]: http://www.w3.org/Math/
12211232[MathJax]: https://www.mathjax.org
12221233[KaTeX]: https://github.com/Khan/KaTeX
1234+[GladTeX]: http://humenda.github.io/GladTeX/
12231235
12241236Options for wrapper scripts
12251237---------------------------
man/pandoc.1+40−6
@@ -647,8 +647,7 @@ a specified full or relative path (executable or non\-executable)
647647.B \f[C]\-M\f[] \f[I]KEY\f[][\f[C]=\f[]\f[I]VAL\f[]], \f[C]\-\-metadata=\f[]\f[I]KEY\f[][\f[C]:\f[]\f[I]VAL\f[]]
648648Set the metadata field \f[I]KEY\f[] to the value \f[I]VAL\f[].
649649A value specified on the command line overrides a value specified in the
650−document using [YAML metadata
651−blocks][Extension:\f[C]yaml_metadata_block\f[]].
650+document using YAML metadata blocks.
652651Values will be parsed as YAML boolean or string values.
653652If no value is specified, the value will be treated as Boolean true.
654653Like \f[C]\-\-variable\f[], \f[C]\-\-metadata\f[] causes template
@@ -727,6 +726,8 @@ Produce output with an appropriate header and footer (e.g.
727726a standalone HTML, LaTeX, TEI, or RTF file, not a fragment).
728727This option is set automatically for \f[C]pdf\f[], \f[C]epub\f[],
729728\f[C]epub3\f[], \f[C]fb2\f[], \f[C]docx\f[], and \f[C]odt\f[] output.
729+For \f[C]native\f[] output, this option causes metadata to be included;
730+otherwise, metadata is suppressed.
730731.RS
731732.RE
732733.TP
@@ -1413,6 +1414,22 @@ inserted.
14131414Note that this option does not imply \f[C]\-\-katex\f[].
14141415.RS
14151416.RE
1417+.TP
1418+.B \f[C]\-\-gladtex\f[]
1419+Enclose TeX math in \f[C]<eq>\f[] tags in HTML output.
1420+The resulting HTML can then be processed by GladTeX to produce images of
1421+the typeset formulas and an HTML file with links to these images.
1422+So, the procedure is:
1423+.RS
1424+.IP
1425+.nf
1426+\f[C]
1427+pandoc\ \-s\ \-\-gladtex\ input.md\ \-o\ myfile.htex
1428+gladtex\ \-d\ myfile\-images\ myfile.htex
1429+#\ produces\ myfile.html\ and\ images\ in\ myfile\-images
1430+\f[]
1431+.fi
1432+.RE
14161433.SS Options for wrapper scripts
14171434.TP
14181435.B \f[C]\-\-dump\-args\f[]
@@ -1489,9 +1506,8 @@ arbitrary information at any point in the file.
14891506They may be set at the command line using the \f[C]\-V/\-\-variable\f[]
14901507option.
14911508If a variable is not set, pandoc will look for the key in the
1492−document\[aq]s metadata \[en] which can be set using either [YAML
1493−metadata blocks][Extension:\f[C]yaml_metadata_block\f[]] or with the
1494−\f[C]\-\-metadata\f[] option.
1509+document\[aq]s metadata \[en] which can be set using either YAML
1510+metadata blocks or with the \f[C]\-\-metadata\f[] option.
14951511.SS Variables set by pandoc
14961512.PP
14971513Some variables are set automatically by pandoc.
@@ -2081,7 +2097,25 @@ $endif$
20812097.fi
20822098.PP
20832099This will include \f[C]X\f[] in the template if \f[C]variable\f[] has a
2084−non\-null value; otherwise it will include \f[C]Y\f[].
2100+truthy value; otherwise it will include \f[C]Y\f[].
2101+Here a truthy value is any of the following:
2102+.IP \[bu] 2
2103+a string that is not entirely white space,
2104+.IP \[bu] 2
2105+a non\-empty array where the first value is truthy,
2106+.IP \[bu] 2
2107+any number (including zero),
2108+.IP \[bu] 2
2109+any object,
2110+.IP \[bu] 2
2111+the boolean \f[C]true\f[] (to specify the boolean \f[C]true\f[] value
2112+using YAML metadata or the \f[C]\-\-metadata\f[] flag, use \f[C]y\f[],
2113+\f[C]Y\f[], \f[C]yes\f[], \f[C]Yes\f[], \f[C]YES\f[], \f[C]true\f[],
2114+\f[C]True\f[], \f[C]TRUE\f[], \f[C]on\f[], \f[C]On\f[], or \f[C]ON\f[];
2115+with the \f[C]\-\-variable\f[] flag, simply omit a value for the
2116+variable, e.g.
2117+\f[C]\-\-variable\ draft\f[]).
2118+.PP
20852119\f[C]X\f[] and \f[C]Y\f[] are placeholders for any valid template text,
20862120and may include interpolated variables or other conditionals.
20872121The \f[C]$else$\f[] section may be omitted.
src/Text/Pandoc/App.hs+6
@@ -1403,6 +1403,12 @@ options =
14031403 "URL")
14041404 "" -- Use KaTeX for HTML Math
14051405
1406+ , Option "" ["gladtex"]
1407+ (NoArg
1408+ (\opt ->
1409+ return opt { optHTMLMathMethod = GladTeX }))
1410+ "" -- "Use gladtex for HTML math"
1411+
14061412 , Option "" ["abbreviations"]
14071413 (ReqArg
14081414 (\arg opt -> return opt { optAbbreviations = Just arg })
src/Text/Pandoc/Options.hs+1
@@ -107,6 +107,7 @@ data EPUBVersion = EPUB2 | EPUB3 deriving (Eq, Show, Read, Data, Typeable, Gener
107107
108108data HTMLMathMethod = PlainMath
109109 | WebTeX String -- url of TeX->image script.
110+ | GladTeX
110111 | MathML
111112 | MathJax String -- url of MathJax.js
112113 | KaTeX String -- url of KaTeX files
src/Text/Pandoc/Writers/HTML.hs+8−1
@@ -58,7 +58,7 @@ import qualified Data.Text.Lazy as TL
5858import Network.HTTP (urlEncode)
5959import Network.URI (URI (..), parseURIReference, unEscapeString)
6060import Numeric (showHex)
61−import Text.Blaze.Internal (customLeaf, MarkupM(Empty))
61+import Text.Blaze.Internal (customLeaf, customParent, MarkupM(Empty))
6262#if MIN_VERSION_blaze_markup(0,6,3)
6363#else
6464import Text.Blaze.Internal (preEscapedString, preEscapedText)
@@ -1029,6 +1029,13 @@ inlineToHtml opts inline = do
10291029 return $ case t of
10301030 InlineMath -> m
10311031 DisplayMath -> brtag >> m >> brtag
1032+ GladTeX ->
1033+ return $
1034+ customParent (textTag "eq") !
1035+ customAttribute "env"
1036+ (toValue $ if t == InlineMath
1037+ then ("math" :: Text)
1038+ else "displaymath") $ strToHtml str
10321039 MathML -> do
10331040 let conf = useShortEmptyTags (const False)
10341041 defaultConfigPP