git.iko.soy/typeable/pandoc
on master help sign in
Added Text.Pandoc.Readers.TeXMath and changed default handling of math.

+ Text.Pandoc.Readers.TeXMath exports readTeXMath, which reads raw TeX math and outputs a string of pandoc inlines that tries to render it as far as possible, lapsing into literal TeX when needed. + Added Text.Pandoc.Readers.TeXMath to pandoc.cabal + ghc66 version. + Modified writers so that readTeXMath is used for default HTMl output in HTML, S5, RTF, Docbook. + Updated README with information about how math is rendered in all formats. + Updated test suite. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1129 788f1e2b-df1e-0410-8736-df70ead52e1b

commitd1832da9e104d61aa6ee0161aefeabf4aef9bbd2 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSun 2 Dec 2007, 00:36 (19 years ago) parent8e872f9
16 files changed+408−57
README+16−8 Text/Pandoc/Readers/TeXMath.hs+218 Text/Pandoc/Writers/Docbook.hs+2−1 Text/Pandoc/Writers/HTML.hs+10−9 Text/Pandoc/Writers/Man.hs+3−2 Text/Pandoc/Writers/RST.hs+2−5 Text/Pandoc/Writers/RTF.hs+2−1 pandoc.cabal+1 pandoc.cabal.ghc66+1 tests/s5.basic.html+27−1 tests/s5.fragment.html+27−1 tests/s5.inserts.html+27−1 tests/writer.docbook+7−7 tests/writer.html+51−7 tests/writer.man+7−7 tests/writer.rtf+7−7
README+16−8
@@ -846,12 +846,23 @@ closing $ must have a character immediately to its left. Thus,
846846you need to enclose text in literal $ characters, backslash-escape
847847them and they won't be treated as math delimiters.
848848
849−TeX math will be printed in all output formats. In Markdown, LaTeX, and
850−ConTeXt output, it will appear between $ characters, so that it may be
851−treated as math. In HTML and S5 output, there are four possible ways
852−to display math:
849+TeX math will be printed in all output formats. In Markdown,
850+reStructuredText, LaTeX, and ConTeXt output, it will appear verbatim
851+between $ characters.
853852
854−1. The default is to display TeX math verbatim.
853+In groff man output, it will be rendered verbatim without $'s.
854+
855+In RTF and Docbook output, it will be rendered, as far as possible,
856+using unicode characters, and will otherwise appear verbatim. Unknown
857+commands and symbols, and commands that cannot be dealt with this way
858+(like `\frac`), will be rendered verbatim. So the results may be a mix
859+of raw TeX code and properly rendered unicode math.
860+
861+In HTML and S5 output, the way math is rendered will depend on the
862+command-line options selected:
863+
864+1. The default is to render TeX math as far as possible using unicode
865+ characters, as with RTF and Docbook output.
855866
8568672. If the `--asciimathml` option is used, TeX math will be displayed
857868 between $ characters, as in LaTeX, and the [ASCIIMathML] script will
@@ -877,9 +888,6 @@ to display math:
877888 gladtex -d myfile-images myfile.htex # produces myfile.html
878889 # and images in myfile-images
879890
880−In other output formats, TeX math will appear verbatim, with no enclosing
881−$'s.
882−
883891Inline TeX
884892----------
885893
Text/Pandoc/Readers/TeXMath.hsnew file+218
@@ -0,0 +1,218 @@
1+{-
2+Copyright (C) 2007 John MacFarlane <jgm@berkeley.edu>
3+
4+This program is free software; you can redistribute it and/or modify
5+it under the terms of the GNU General Public License as published by
6+the Free Software Foundation; either version 2 of the License, or
7+(at your option) any later version.
8+
9+This program is distributed in the hope that it will be useful,
10+but WITHOUT ANY WARRANTY; without even the implied warranty of
11+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+GNU General Public License for more details.
13+
14+You should have received a copy of the GNU General Public License
15+along with this program; if not, write to the Free Software
16+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17+-}
18+
19+{- |
20+ Module : Text.Pandoc.Readers.TeXMath
21+ Copyright : Copyright (C) 2007 John MacFarlane
22+ License : GNU GPL, version 2 or above
23+
24+ Maintainer : John MacFarlane <jgm@berkeley.edu>
25+ Stability : alpha
26+ Portability : portable
27+
28+Conversion of TeX math to a list of 'Pandoc' inline elements.
29+-}
30+module Text.Pandoc.Readers.TeXMath (
31+ readTeXMath
32+ ) where
33+
34+import Text.ParserCombinators.Parsec
35+import Text.Pandoc.UTF8
36+import Text.Pandoc.Definition
37+import Text.Pandoc.Shared
38+
39+-- | Converts a string of raw TeX math to a list of 'Pandoc' inlines.
40+readTeXMath :: String -> [Inline]
41+readTeXMath inp = case parse teXMath "input" inp of
42+ Left err -> error $ "\nError:\n" ++ show err
43+ Right res -> res
44+
45+teXMath = manyTill mathPart eof >>= return . concat
46+
47+mathPart = whitespace <|> superscript <|> subscript <|> symbol <|>
48+ argument <|> plain <|> misc
49+
50+whitespace = many1 space >> return []
51+
52+symbol = try $ do
53+ char '\\'
54+ res <- many1 letter
55+ case lookup res teXsymbols of
56+ Just m -> return [Str m]
57+ Nothing -> return [Str $ "\\" ++ res]
58+
59+argument = try $ do
60+ char '{'
61+ res <- many mathPart
62+ char '}'
63+ return $ if null res
64+ then [Str " "]
65+ else [Str "{"] ++ concat res ++ [Str "}"]
66+
67+plain = do
68+ res <- many1 alphaNum
69+ return $ [Emph [Str res]]
70+
71+misc = do
72+ res <- noneOf "{}\\"
73+ return [Str [res]]
74+
75+scriptArg = try $ do
76+ (try (do{char '{'; r <- many mathPart; char '}'; return $ concat r}))
77+ <|> symbol
78+ <|> (do{c <- (letter <|> digit); return [Str [c]]})
79+
80+superscript = try $ do
81+ char '^'
82+ arg <- scriptArg
83+ return [Superscript arg]
84+
85+subscript = try $ do
86+ char '_'
87+ arg <- scriptArg
88+ return [Subscript arg]
89+
90+withThinSpace str = "\x2009" ++ str ++ "\x2009"
91+
92+teXsymbols =
93+ [("alpha","\x3B1")
94+ ,("beta", "\x3B2")
95+ ,("chi", "\x3C7")
96+ ,("delta", "\x3B4")
97+ ,("Delta", "\x394")
98+ ,("epsilon", "\x3B5")
99+ ,("varepsilon", "\x25B")
100+ ,("eta", "\x3B7")
101+ ,("gamma", "\x3B3")
102+ ,("Gamma", "\x393")
103+ ,("iota", "\x3B9")
104+ ,("kappa", "\x3BA")
105+ ,("lambda", "\x3BB")
106+ ,("Lambda", "\x39B")
107+ ,("mu", "\x3BC")
108+ ,("nu", "\x3BD")
109+ ,("omega", "\x3C9")
110+ ,("Omega", "\x3A9")
111+ ,("phi", "\x3C6")
112+ ,("varphi", "\x3D5")
113+ ,("Phi", "\x3A6")
114+ ,("pi", "\x3C0")
115+ ,("Pi", "\x3A0")
116+ ,("psi", "\x3C8")
117+ ,("Psi", "\x3A8")
118+ ,("rho", "\x3C1")
119+ ,("sigma", "\x3C3")
120+ ,("Sigma", "\x3A3")
121+ ,("tau", "\x3C4")
122+ ,("theta", "\x3B8")
123+ ,("vartheta", "\x3D1")
124+ ,("Theta", "\x398")
125+ ,("upsilon", "\x3C5")
126+ ,("xi", "\x3BE")
127+ ,("Xi", "\x39E")
128+ ,("zeta", "\x3B6")
129+ ,("ne", "\x2260")
130+ ,("lt", withThinSpace "<")
131+ ,("le", withThinSpace "\x2264")
132+ ,("leq", withThinSpace "\x2264")
133+ ,("ge", withThinSpace "\x2265")
134+ ,("geq", withThinSpace "\x2265")
135+ ,("prec", withThinSpace "\x227A")
136+ ,("succ", withThinSpace "\x227B")
137+ ,("preceq", withThinSpace "\x2AAF")
138+ ,("succeq", withThinSpace "\x2AB0")
139+ ,("in", withThinSpace "\x2208")
140+ ,("notin", withThinSpace "\x2209")
141+ ,("subset", withThinSpace "\x2282")
142+ ,("supset", withThinSpace "\x2283")
143+ ,("subseteq", withThinSpace "\x2286")
144+ ,("supseteq", withThinSpace "\x2287")
145+ ,("equiv", withThinSpace "\x2261")
146+ ,("cong", withThinSpace "\x2245")
147+ ,("approx", withThinSpace "\x2248")
148+ ,("propto", withThinSpace "\x221D")
149+ ,("cdot", withThinSpace "\x22C5")
150+ ,("star", withThinSpace "\x22C6")
151+ ,("backslash", "\\")
152+ ,("times", withThinSpace "\x00D7")
153+ ,("divide", withThinSpace "\x00F7")
154+ ,("circ", withThinSpace "\x2218")
155+ ,("oplus", withThinSpace "\x2295")
156+ ,("otimes", withThinSpace "\x2297")
157+ ,("odot", withThinSpace "\x2299")
158+ ,("sum", "\x2211")
159+ ,("prod", "\x220F")
160+ ,("wedge", withThinSpace "\x2227")
161+ ,("bigwedge", withThinSpace "\x22C0")
162+ ,("vee", withThinSpace "\x2228")
163+ ,("bigvee", withThinSpace "\x22C1")
164+ ,("cap", withThinSpace "\x2229")
165+ ,("bigcap", withThinSpace "\x22C2")
166+ ,("cup", withThinSpace "\x222A")
167+ ,("bigcup", withThinSpace "\x22C3")
168+ ,("neg", "\x00AC")
169+ ,("implies", withThinSpace "\x21D2")
170+ ,("iff", withThinSpace "\x21D4")
171+ ,("forall", "\x2200")
172+ ,("exists", "\x2203")
173+ ,("bot", "\x22A5")
174+ ,("top", "\x22A4")
175+ ,("vdash", "\x22A2")
176+ ,("models", withThinSpace "\x22A8")
177+ ,("uparrow", "\x2191")
178+ ,("downarrow", "\x2193")
179+ ,("rightarrow", withThinSpace "\x2192")
180+ ,("to", withThinSpace "\x2192")
181+ ,("rightarrowtail", "\x21A3")
182+ ,("twoheadrightarrow", withThinSpace "\x21A0")
183+ ,("twoheadrightarrowtail", withThinSpace "\x2916")
184+ ,("mapsto", withThinSpace "\x21A6")
185+ ,("leftarrow", withThinSpace "\x2190")
186+ ,("leftrightarrow", withThinSpace "\x2194")
187+ ,("Rightarrow", withThinSpace "\x21D2")
188+ ,("Leftarrow", withThinSpace "\x21D0")
189+ ,("Leftrightarrow", withThinSpace "\x21D4")
190+ ,("partial", "\x2202")
191+ ,("nabla", "\x2207")
192+ ,("pm", "\x00B1")
193+ ,("emptyset", "\x2205")
194+ ,("infty", "\x221E")
195+ ,("aleph", "\x2135")
196+ ,("ldots", "...")
197+ ,("therefore", "\x2234")
198+ ,("angle", "\x2220")
199+ ,("quad", "\x00A0\x00A0")
200+ ,("cdots", "\x22EF")
201+ ,("vdots", "\x22EE")
202+ ,("ddots", "\x22F1")
203+ ,("diamond", "\x22C4")
204+ ,("Box", "\x25A1")
205+ ,("lfloor", "\x230A")
206+ ,("rfloor", "\x230B")
207+ ,("lceiling", "\x2308")
208+ ,("rceiling", "\x2309")
209+ ,("langle", "\x2329")
210+ ,("rangle", "\x232A")
211+ ,("{", "{")
212+ ,("}", "}")
213+ ,("[", "[")
214+ ,("]", "]")
215+ ,("|", "|")
216+ ,("||", "||")
217+ ]
218+
Text/Pandoc/Writers/Docbook.hs+2−1
@@ -30,6 +30,7 @@ Conversion of 'Pandoc' documents to Docbook XML.
3030module Text.Pandoc.Writers.Docbook ( writeDocbook) where
3131import Text.Pandoc.Definition
3232import Text.Pandoc.Shared
33+import Text.Pandoc.Readers.TeXMath
3334import Data.List ( isPrefixOf, drop )
3435import Text.PrettyPrint.HughesPJ hiding ( Str )
3536
@@ -274,7 +275,7 @@ inlineToDocbook opts EmDash = text "&#8212;"
274275inlineToDocbook opts EnDash = text "&#8211;"
275276inlineToDocbook opts (Code str) =
276277 inTagsSimple "literal" $ text (escapeStringForXML str)
277−inlineToDocbook opts (Math str) = inlineToDocbook opts (Code str)
278+inlineToDocbook opts (Math str) = inlinesToDocbook opts $ readTeXMath str
278279inlineToDocbook opts (TeX str) = empty
279280inlineToDocbook opts (HtmlInline str) = empty
280281inlineToDocbook opts LineBreak = text $ "<literallayout></literallayout>"
Text/Pandoc/Writers/HTML.hs+10−9
@@ -32,6 +32,7 @@ import Text.Pandoc.Definition
3232import Text.Pandoc.ASCIIMathML
3333import Text.Pandoc.CharacterReferences ( decodeCharacterReferences )
3434import Text.Pandoc.Shared
35+import Text.Pandoc.Readers.TeXMath
3536import Text.Regex ( mkRegex, matchRegex )
3637import Numeric ( showHex )
3738import Data.Char ( ord, toLower )
@@ -401,16 +402,16 @@ inlineToHtml opts inline =
401402 in do contents <- inlineListToHtml opts lst
402403 return $ leftQuote +++ contents +++ rightQuote
403404 (Math str) -> modify (\st -> st {stMath = True}) >>
404− (return $ case writerHTMLMathMethod opts of
405− ASCIIMathML _ ->
406− stringToHtml ("$" ++ str ++ "$")
407− MimeTeX url ->
408− image ! [src (url ++ "?" ++ str),
405+ (case writerHTMLMathMethod opts of
406+ ASCIIMathML _ ->
407+ return $ stringToHtml ("$" ++ str ++ "$")
408+ MimeTeX url ->
409+ return $ image ! [src (url ++ "?" ++ str),
409410 alt str, title str]
410− GladTeX ->
411− tag "eq" << str
412− PlainMath ->
413− stringToHtml str)
411+ GladTeX ->
412+ return $ tag "eq" << str
413+ PlainMath ->
414+ inlineListToHtml opts (readTeXMath str))
414415 (TeX str) -> return noHtml
415416 (HtmlInline str) -> return $ primHtml str
416417 (Link [Code str] (src,tit)) | "mailto:" `isPrefixOf` src ->
Text/Pandoc/Writers/Man.hs+3−2
@@ -30,7 +30,8 @@ Conversion of 'Pandoc' documents to groff man page format.
3030-}
3131module Text.Pandoc.Writers.Man ( writeMan) where
3232import Text.Pandoc.Definition
33−import Text.Pandoc.Shared
33+import Text.Pandoc.Shared
34+import Text.Pandoc.Readers.TeXMath
3435import Text.Printf ( printf )
3536import Data.List ( isPrefixOf, drop, nub, intersperse )
3637import Text.PrettyPrint.HughesPJ hiding ( Str )
@@ -268,7 +269,7 @@ inlineToMan opts Ellipses = return $ text "\\&..."
268269inlineToMan opts (Code str) =
269270 return $ text $ "\\f[B]" ++ escapeCode str ++ "\\f[]"
270271inlineToMan opts (Str str) = return $ text $ escapeString str
271−inlineToMan opts (Math str) = return $ text $ escapeCode str
272+inlineToMan opts (Math str) = inlineToMan opts (Code str)
272273inlineToMan opts (TeX str) = return empty
273274inlineToMan opts (HtmlInline str) = return $ text $ escapeCode str
274275inlineToMan opts (LineBreak) = return $ text "\n.PD 0\n.P\n.PD\n"
Text/Pandoc/Writers/RST.hs+2−5
@@ -32,6 +32,7 @@ reStructuredText: <http://docutils.sourceforge.net/rst.html>
3232module Text.Pandoc.Writers.RST ( writeRST) where
3333import Text.Pandoc.Definition
3434import Text.Pandoc.Shared
35+import Text.Pandoc.Readers.TeXMath
3536import Text.Pandoc.Blocks
3637import Data.List ( isPrefixOf, isSuffixOf, drop, intersperse )
3738import Text.PrettyPrint.HughesPJ hiding ( Str )
@@ -151,10 +152,6 @@ blockToRST :: WriterOptions -- ^ Options
151152 -> State WriterState Doc
152153blockToRST opts Null = return empty
153154blockToRST opts (Plain inlines) = wrappedRST opts inlines
154−blockToRST opts (Para [Math str]) =
155− let str' = if "\n" `isSuffixOf` str then str ++ "\n" else str ++ "\n\n" in
156− return $ hang (text "\n.. raw:: latex\n") 3 $ text "\\[" <>
157− (vcat $ map text (lines str')) <> text "\\]"
158155blockToRST opts (Para inlines) = do
159156 contents <- wrappedRST opts inlines
160157 return $ contents <> text "\n"
@@ -286,7 +283,7 @@ inlineToRST opts Apostrophe = return $ char '\''
286283inlineToRST opts Ellipses = return $ text "..."
287284inlineToRST opts (Code str) = return $ text $ "``" ++ str ++ "``"
288285inlineToRST opts (Str str) = return $ text $ escapeString str
289−inlineToRST opts (Math str) = return $ char '$' <> text str <> char '$'
286+inlineToRST opts (Math str) = return $ text $ "$" ++ str ++ "$"
290287inlineToRST opts (TeX str) = return empty
291288inlineToRST opts (HtmlInline str) = return empty
292289inlineToRST opts (LineBreak) = return $ char ' ' -- RST doesn't have linebreaks
Text/Pandoc/Writers/RTF.hs+2−1
@@ -30,6 +30,7 @@ Conversion of 'Pandoc' documents to RTF (rich text format).
3030module Text.Pandoc.Writers.RTF ( writeRTF ) where
3131import Text.Pandoc.Definition
3232import Text.Pandoc.Shared
33+import Text.Pandoc.Readers.TeXMath
3334import Text.Regex ( matchRegexAll, mkRegex )
3435import Data.List ( isSuffixOf )
3536import Data.Char ( ord )
@@ -272,7 +273,7 @@ inlineToRTF EmDash = "\\u8212-"
272273inlineToRTF EnDash = "\\u8211-"
273274inlineToRTF (Code str) = "{\\f1 " ++ (codeStringToRTF str) ++ "} "
274275inlineToRTF (Str str) = stringToRTF str
275−inlineToRTF (Math str) = latexToRTF str
276+inlineToRTF (Math str) = inlineListToRTF $ readTeXMath str
276277inlineToRTF (TeX str) = ""
277278inlineToRTF (HtmlInline str) = ""
278279inlineToRTF (LineBreak) = "\\line "
pandoc.cabal+1
@@ -54,6 +54,7 @@ Library
5454 Text.Pandoc.Readers.LaTeX,
5555 Text.Pandoc.Readers.Markdown,
5656 Text.Pandoc.Readers.RST,
57+ Text.Pandoc.Readers.TeXMath,
5758 Text.Pandoc.Writers.DefaultHeaders,
5859 Text.Pandoc.Writers.Docbook,
5960 Text.Pandoc.Writers.HTML,
pandoc.cabal.ghc66+1
@@ -44,6 +44,7 @@ Exposed-Modules: Text.Pandoc,
4444 Text.Pandoc.Readers.LaTeX,
4545 Text.Pandoc.Readers.Markdown,
4646 Text.Pandoc.Readers.RST,
47+ Text.Pandoc.Readers.TeXMath,
4748 Text.Pandoc.Writers.DefaultHeaders,
4849 Text.Pandoc.Writers.Docbook,
4950 Text.Pandoc.Writers.HTML,
tests/s5.basic.html+27−1
@@ -780,7 +780,33 @@ window.onresize = function(){setTimeout('fontScale()', 50);}</script>
780780 >Math</h1
781781 ><ul
782782 ><li
783− >\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</li
783+ >\frac{<em
784+ >d</em
785+ >}{<em
786+ >dx</em
787+ >}<em
788+ >f</em
789+ >(<em
790+ >x</em
791+ >)=\lim<sub
792+ ><em
793+ >h</em
794+ >&#8201;&#8594;&#8201;<em
795+ >0</em
796+ ></sub
797+ >\frac{<em
798+ >f</em
799+ >(<em
800+ >x</em
801+ >+<em
802+ >h</em
803+ >)-<em
804+ >f</em
805+ >(<em
806+ >x</em
807+ >)}{<em
808+ >h</em
809+ >}</li
784810 ></ul
785811 ></div>
786812</div>
tests/s5.fragment.html+27−1
@@ -10,6 +10,32 @@
1010>Math</h1
1111><ul
1212><li
13− >\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</li
13+ >\frac{<em
14+ >d</em
15+ >}{<em
16+ >dx</em
17+ >}<em
18+ >f</em
19+ >(<em
20+ >x</em
21+ >)=\lim<sub
22+ ><em
23+ >h</em
24+ >&#8201;&#8594;&#8201;<em
25+ >0</em
26+ ></sub
27+ >\frac{<em
28+ >f</em
29+ >(<em
30+ >x</em
31+ >+<em
32+ >h</em
33+ >)-<em
34+ >f</em
35+ >(<em
36+ >x</em
37+ >)}{<em
38+ >h</em
39+ >}</li
1440 ></ul
1541>
tests/s5.inserts.html+27−1
@@ -27,7 +27,33 @@ STUFF INSERTED
2727 >Math</h1
2828 ><ul
2929 ><li
30− >\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</li
30+ >\frac{<em
31+ >d</em
32+ >}{<em
33+ >dx</em
34+ >}<em
35+ >f</em
36+ >(<em
37+ >x</em
38+ >)=\lim<sub
39+ ><em
40+ >h</em
41+ >&#8201;&#8594;&#8201;<em
42+ >0</em
43+ ></sub
44+ >\frac{<em
45+ >f</em
46+ >(<em
47+ >x</em
48+ >+<em
49+ >h</em
50+ >)-<em
51+ >f</em
52+ >(<em
53+ >x</em
54+ >)}{<em
55+ >h</em
56+ >}</li
3157 ></ul
3258 >STUFF INSERTED
3359</body
tests/writer.docbook+7−7
@@ -891,38 +891,38 @@ These should not be escaped: \$ \\ \&gt; \[ \{
891891 </listitem>
892892 <listitem>
893893 <para>
894− <literal>2+2=4</literal>
894+ <emphasis>2</emphasis>+<emphasis>2</emphasis>=<emphasis>4</emphasis>
895895 </para>
896896 </listitem>
897897 <listitem>
898898 <para>
899− <literal>x \in y</literal>
899+ <emphasis>x</emphasis> ∈ <emphasis>y</emphasis>
900900 </para>
901901 </listitem>
902902 <listitem>
903903 <para>
904− <literal>\alpha \wedge \omega</literal>
904+ α ∧ ω
905905 </para>
906906 </listitem>
907907 <listitem>
908908 <para>
909− <literal>223</literal>
909+ <emphasis>223</emphasis>
910910 </para>
911911 </listitem>
912912 <listitem>
913913 <para>
914− <literal>p</literal>-Tree
914+ <emphasis>p</emphasis>-Tree
915915 </para>
916916 </listitem>
917917 <listitem>
918918 <para>
919− <literal>\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</literal>
919+ \frac{<emphasis>d</emphasis>}{<emphasis>dx</emphasis>}<emphasis>f</emphasis>(<emphasis>x</emphasis>)=\lim<subscript><emphasis>h</emphasis> → <emphasis>0</emphasis></subscript>\frac{<emphasis>f</emphasis>(<emphasis>x</emphasis>+<emphasis>h</emphasis>)-<emphasis>f</emphasis>(<emphasis>x</emphasis>)}{<emphasis>h</emphasis>}
920920 </para>
921921 </listitem>
922922 <listitem>
923923 <para>
924924 Here's one that has a line break in it:
925− <literal>\alpha + \omega \times x^2</literal>.
925+ α+ω × <emphasis>x</emphasis><superscript>2</superscript>.
926926 </para>
927927 </listitem>
928928 </itemizedlist>
tests/writer.html+51−7
@@ -762,19 +762,63 @@ Blah
762762 ><li
763763 ></li
764764 ><li
765− >2+2=4</li
765+ ><em
766+ >2</em
767+ >+<em
768+ >2</em
769+ >=<em
770+ >4</em
771+ ></li
766772 ><li
767− >x \in y</li
773+ ><em
774+ >x</em
775+ >&#8201;&#8712;&#8201;<em
776+ >y</em
777+ ></li
768778 ><li
769− >\alpha \wedge \omega</li
779+ >&#945;&#8201;&#8743;&#8201;&#969;</li
770780 ><li
771− >223</li
781+ ><em
782+ >223</em
783+ ></li
772784 ><li
773− >p-Tree</li
785+ ><em
786+ >p</em
787+ >-Tree</li
774788 ><li
775− >\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</li
789+ >\frac{<em
790+ >d</em
791+ >}{<em
792+ >dx</em
793+ >}<em
794+ >f</em
795+ >(<em
796+ >x</em
797+ >)=\lim<sub
798+ ><em
799+ >h</em
800+ >&#8201;&#8594;&#8201;<em
801+ >0</em
802+ ></sub
803+ >\frac{<em
804+ >f</em
805+ >(<em
806+ >x</em
807+ >+<em
808+ >h</em
809+ >)-<em
810+ >f</em
811+ >(<em
812+ >x</em
813+ >)}{<em
814+ >h</em
815+ >}</li
776816 ><li
777− >Here&rsquo;s one that has a line break in it: \alpha + \omega \times x^2.</li
817+ >Here&rsquo;s one that has a line break in it: &#945;+&#969;&#8201;×&#8201;<em
818+ >x</em
819+ ><sup
820+ >2</sup
821+ >.</li
778822 ></ul
779823 ><p
780824 >These shouldn&rsquo;t be math:</p
tests/writer.man+7−7
@@ -576,20 +576,20 @@ Ellipses\&...and\&...and\&...\.
576576.IP \[bu] 2
577577.IP \[bu] 2
578578.IP \[bu] 2
579−2+2=4
579+\f[B]2+2=4\f[]
580580.IP \[bu] 2
581−x\ \\in\ y
581+\f[B]x\ \\in\ y\f[]
582582.IP \[bu] 2
583−\\alpha\ \\wedge\ \\omega
583+\f[B]\\alpha\ \\wedge\ \\omega\f[]
584584.IP \[bu] 2
585−223
585+\f[B]223\f[]
586586.IP \[bu] 2
587−p-Tree
587+\f[B]p\f[]-Tree
588588.IP \[bu] 2
589−\\frac{d}{dx}f(x)=\\lim_{h\\to\ 0}\\frac{f(x+h)-f(x)}{h}
589+\f[B]\\frac{d}{dx}f(x)=\\lim_{h\\to\ 0}\\frac{f(x+h)-f(x)}{h}\f[]
590590.IP \[bu] 2
591591Here's one that has a line break in it:
592−\\alpha\ +\ \\omega\ \\times\ x^2\.
592+\f[B]\\alpha\ +\ \\omega\ \\times\ x^2\f[]\.
593593.PP
594594These shouldn't be math:
595595.IP \[bu] 2
tests/writer.rtf+7−7
@@ -252,13 +252,13 @@ quoted link
252252{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 LaTeX\par}
253253{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab \par}
254254{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab \par}
255−{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\cf1 2+2=4\cf0 } \par}
256−{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\cf1 x \\in y\cf0 } \par}
257−{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\cf1 \\alpha \\wedge \\omega\cf0 } \par}
258−{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\cf1 223\cf0 } \par}
259−{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\cf1 p\cf0 } -Tree\par}
260−{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\cf1 \\frac\{d\}\{dx\}f(x)=\\lim_\{h\\to 0\}\\frac\{f(x+h)-f(x)\}\{h\}\cf0 } \par}
261−{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Here\u8217's one that has a line break in it: {\cf1 \\alpha + \\omega \\times x^2\cf0 } .\sa180\par}
255+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\i 2} +{\i 2} ={\i 4} \par}
256+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\i x} \u8201?\u8712?\u8201?{\i y} \par}
257+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab \u945?\u8201?\u8743?\u8201?\u969?\par}
258+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\i 223} \par}
259+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\i p} -Tree\par}
260+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab \\frac\{{\i d} \}\{{\i dx} \}{\i f} ({\i x} )=\\lim{\sub {\i h} \u8201?\u8594?\u8201?{\i 0} } \\frac\{{\i f} ({\i x} +{\i h} )-{\i f} ({\i x} )\}\{{\i h} \}\par}
261+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Here\u8217's one that has a line break in it: \u945?+\u969?\u8201?\u215?\u8201?{\i x} {\super 2} .\sa180\par}
262262{\pard \ql \f0 \sa180 \li0 \fi0 These shouldn\u8217't be math:\par}
263263{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab To get the famous equation, write {\f1 $e = mc^2$} .\par}
264264{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab $22,000 is a {\i lot} of money. So is $34,000. (It worked if \u8220"lot\u8221" is emphasized.)\par}