git.iko.soy/typeable/pandoc
on master help sign in
Use texmath's parser in TexMath module.

* This replaces a lot of custom parser code, and expands the tex -> unicode conversion. * The behavior has also changed: if the whole formula can't be converted, the whole formula is left in raw TeX. Previously, pandoc converted parts of the formula to unicode and left other parts in raw TeX. * Added (but not yet exported) readTeXMath', which returns a Maybe. * Updated tests

commitc243e5b67b0a3be6a713c6120da24e5e65cb0357 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 25 Apr 2010, 12:33 (16 years ago) parentb3669e1
8 files changed+83−336
src/Text/Pandoc/Readers/TeXMath.hs+53−197 tests/s5.basic.html+1−25 tests/s5.fragment.html+1−25 tests/s5.inserts.html+1−25 tests/writer.docbook+5−5 tests/writer.html+5−29 tests/writer.opendocument+12−25 tests/writer.rtf+5−5
src/Text/Pandoc/Readers/TeXMath.hs+53−197
@@ -28,208 +28,64 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2828Conversion of TeX math to a list of 'Pandoc' inline elements.
2929-}
3030module Text.Pandoc.Readers.TeXMath (
31− readTeXMath
31+ readTeXMath
3232 ) where
3333
3434import Text.ParserCombinators.Parsec
3535import Text.Pandoc.Definition
36+import Text.TeXMath.Parser
3637
37−-- | Converts a string of raw TeX math to a list of 'Pandoc' inlines.
38+-- | Converts a raw TeX math formula to a list of 'Pandoc' inlines.
39+-- Defaults to raw formula between @$@ characters if entire formula
40+-- can't be converted.
3841readTeXMath :: String -- ^ String to parse (assumes @'\n'@ line endings)
3942 -> [Inline]
40−readTeXMath inp = case parse teXMath ("formula: " ++ inp) inp of
41− Left _ -> [Str inp] -- if unparseable, just include original
42− Right res -> res
43−
44−teXMath :: GenParser Char st [Inline]
45−teXMath = manyTill mathPart eof >>= return . concat
46−
47−mathPart :: GenParser Char st [Inline]
48−mathPart = whitespace <|> superscript <|> subscript <|> symbol <|>
49− argument <|> digits <|> letters <|> misc
50−
51−whitespace :: GenParser Char st [Inline]
52−whitespace = many1 space >> return []
53−
54−symbol :: GenParser Char st [Inline]
55−symbol = try $ do
56− char '\\'
57− res <- many1 letter
58− case lookup res teXsymbols of
59− Just m -> return [Str m]
60− Nothing -> return [Str $ "\\" ++ res]
61−
62−argument :: GenParser Char st [Inline]
63−argument = try $ do
64− char '{'
65− res <- many mathPart
66− char '}'
67− return $ if null res
68− then [Str " "]
69− else [Str "{"] ++ concat res ++ [Str "}"]
70−
71−digits :: GenParser Char st [Inline]
72−digits = do
73− res <- many1 digit
74− return [Str res]
75−
76−letters :: GenParser Char st [Inline]
77−letters = do
78− res <- many1 letter
79− return [Emph [Str res]]
80−
81−misc :: GenParser Char st [Inline]
82−misc = do
83− res <- noneOf "}"
84− return [Str [res]]
85−
86−scriptArg :: GenParser Char st [Inline]
87−scriptArg = try $ do
88− (try (do{char '{'; r <- many mathPart; char '}'; return $ concat r}))
89− <|> symbol
90− <|> (do{c <- (letter <|> digit); return [Str [c]]})
91−
92−superscript :: GenParser Char st [Inline]
93−superscript = try $ do
94− char '^'
95− arg <- scriptArg
96− return [Superscript arg]
97−
98−subscript :: GenParser Char st [Inline]
99−subscript = try $ do
100− char '_'
101− arg <- scriptArg
102− return [Subscript arg]
103−
104−withThinSpace :: String -> String
105−withThinSpace str = "\x2009" ++ str ++ "\x2009"
106−
107−teXsymbols :: [(String, String)]
108−teXsymbols =
109− [("alpha","\x3B1")
110− ,("beta", "\x3B2")
111− ,("chi", "\x3C7")
112− ,("delta", "\x3B4")
113− ,("Delta", "\x394")
114− ,("epsilon", "\x3B5")
115− ,("varepsilon", "\x25B")
116− ,("eta", "\x3B7")
117− ,("gamma", "\x3B3")
118− ,("Gamma", "\x393")
119− ,("iota", "\x3B9")
120− ,("kappa", "\x3BA")
121− ,("lambda", "\x3BB")
122− ,("Lambda", "\x39B")
123− ,("mu", "\x3BC")
124− ,("nu", "\x3BD")
125− ,("omega", "\x3C9")
126− ,("Omega", "\x3A9")
127− ,("phi", "\x3C6")
128− ,("varphi", "\x3D5")
129− ,("Phi", "\x3A6")
130− ,("pi", "\x3C0")
131− ,("Pi", "\x3A0")
132− ,("psi", "\x3C8")
133− ,("Psi", "\x3A8")
134− ,("rho", "\x3C1")
135− ,("sigma", "\x3C3")
136− ,("Sigma", "\x3A3")
137− ,("tau", "\x3C4")
138− ,("theta", "\x3B8")
139− ,("vartheta", "\x3D1")
140− ,("Theta", "\x398")
141− ,("upsilon", "\x3C5")
142− ,("xi", "\x3BE")
143− ,("Xi", "\x39E")
144− ,("zeta", "\x3B6")
145− ,("ne", "\x2260")
146− ,("lt", withThinSpace "<")
147− ,("le", withThinSpace "\x2264")
148− ,("leq", withThinSpace "\x2264")
149− ,("ge", withThinSpace "\x2265")
150− ,("geq", withThinSpace "\x2265")
151− ,("prec", withThinSpace "\x227A")
152− ,("succ", withThinSpace "\x227B")
153− ,("preceq", withThinSpace "\x2AAF")
154− ,("succeq", withThinSpace "\x2AB0")
155− ,("in", withThinSpace "\x2208")
156− ,("notin", withThinSpace "\x2209")
157− ,("subset", withThinSpace "\x2282")
158− ,("supset", withThinSpace "\x2283")
159− ,("subseteq", withThinSpace "\x2286")
160− ,("supseteq", withThinSpace "\x2287")
161− ,("equiv", withThinSpace "\x2261")
162− ,("cong", withThinSpace "\x2245")
163− ,("approx", withThinSpace "\x2248")
164− ,("propto", withThinSpace "\x221D")
165− ,("cdot", withThinSpace "\x22C5")
166− ,("star", withThinSpace "\x22C6")
167− ,("backslash", "\\")
168− ,("times", withThinSpace "\x00D7")
169− ,("divide", withThinSpace "\x00F7")
170− ,("circ", withThinSpace "\x2218")
171− ,("oplus", withThinSpace "\x2295")
172− ,("otimes", withThinSpace "\x2297")
173− ,("odot", withThinSpace "\x2299")
174− ,("sum", "\x2211")
175− ,("prod", "\x220F")
176− ,("wedge", withThinSpace "\x2227")
177− ,("bigwedge", withThinSpace "\x22C0")
178− ,("vee", withThinSpace "\x2228")
179− ,("bigvee", withThinSpace "\x22C1")
180− ,("cap", withThinSpace "\x2229")
181− ,("bigcap", withThinSpace "\x22C2")
182− ,("cup", withThinSpace "\x222A")
183− ,("bigcup", withThinSpace "\x22C3")
184− ,("neg", "\x00AC")
185− ,("implies", withThinSpace "\x21D2")
186− ,("iff", withThinSpace "\x21D4")
187− ,("forall", "\x2200")
188− ,("exists", "\x2203")
189− ,("bot", "\x22A5")
190− ,("top", "\x22A4")
191− ,("vdash", "\x22A2")
192− ,("models", withThinSpace "\x22A8")
193− ,("uparrow", "\x2191")
194− ,("downarrow", "\x2193")
195− ,("rightarrow", withThinSpace "\x2192")
196− ,("to", withThinSpace "\x2192")
197− ,("rightarrowtail", "\x21A3")
198− ,("twoheadrightarrow", withThinSpace "\x21A0")
199− ,("twoheadrightarrowtail", withThinSpace "\x2916")
200− ,("mapsto", withThinSpace "\x21A6")
201− ,("leftarrow", withThinSpace "\x2190")
202− ,("leftrightarrow", withThinSpace "\x2194")
203− ,("Rightarrow", withThinSpace "\x21D2")
204− ,("Leftarrow", withThinSpace "\x21D0")
205− ,("Leftrightarrow", withThinSpace "\x21D4")
206− ,("partial", "\x2202")
207− ,("nabla", "\x2207")
208− ,("pm", "\x00B1")
209− ,("emptyset", "\x2205")
210− ,("infty", "\x221E")
211− ,("aleph", "\x2135")
212− ,("ldots", "...")
213− ,("therefore", "\x2234")
214− ,("angle", "\x2220")
215− ,("quad", "\x00A0\x00A0")
216− ,("cdots", "\x22EF")
217− ,("vdots", "\x22EE")
218− ,("ddots", "\x22F1")
219− ,("diamond", "\x22C4")
220− ,("Box", "\x25A1")
221− ,("lfloor", "\x230A")
222− ,("rfloor", "\x230B")
223− ,("lceiling", "\x2308")
224− ,("rceiling", "\x2309")
225− ,("langle", "\x2329")
226− ,("rangle", "\x232A")
227− ,("int", "\8747")
228− ,("{", "{")
229− ,("}", "}")
230− ,("[", "[")
231− ,("]", "]")
232− ,("|", "|")
233− ,("||", "||")
234− ]
43+readTeXMath inp = case readTeXMath' inp of
44+ Nothing -> [Str ("$" ++ inp ++ "$")]
45+ Just res -> res
46+
47+-- | Like 'readTeXMath', but without the default.
48+readTeXMath' :: String -- ^ String to parse (assumes @'\n'@ line endings)
49+ -> Maybe [Inline]
50+readTeXMath' inp = case parse formula "formula" inp of
51+ Left _ -> Just [Str inp]
52+ Right exps -> expsToInlines exps
53+
54+expsToInlines :: [Exp] -> Maybe [Inline]
55+expsToInlines xs = do
56+ res <- mapM expToInlines xs
57+ return (concat res)
58+
59+expToInlines :: Exp -> Maybe [Inline]
60+expToInlines (ENumber s) = Just [Str s]
61+expToInlines (EIdentifier s) = Just [Emph [Str s]]
62+expToInlines (EMathOperator s) = Just [Str s]
63+expToInlines (ESymbol t s) = Just $ addSpace t (Str s)
64+ where addSpace Op x = [x, thinspace]
65+ addSpace Bin x = [medspace, x, medspace]
66+ addSpace Rel x = [widespace, x, widespace]
67+ addSpace Pun x = [x, thinspace]
68+ addSpace _ x = [x]
69+ thinspace = Str "\x2006"
70+ medspace = Str "\x2005"
71+ widespace = Str "\x2004"
72+expToInlines (EStretchy x) = expToInlines x
73+expToInlines (EGrouped xs) = expsToInlines xs
74+expToInlines (ESpace _) = Just [Str " "] -- variable widths not supported
75+expToInlines (EBinary _ _ _) = Nothing
76+expToInlines (ESub x y) = do
77+ x' <- expToInlines x
78+ y' <- expToInlines y
79+ return $ x' ++ [Subscript y']
80+expToInlines (ESuper x y) = do
81+ x' <- expToInlines x
82+ y' <- expToInlines y
83+ return $ x' ++ [Superscript y']
84+expToInlines (ESubsup x y z) = do
85+ x' <- expToInlines x
86+ y' <- expToInlines y
87+ z' <- expToInlines z
88+ return $ x' ++ [Subscript y'] ++ [Superscript z']
89+expToInlines (EText _ x) = Just [Emph [Str x]]
90+expToInlines _ = Nothing
23591
tests/s5.basic.html+1−25
@@ -309,31 +309,7 @@
309309><ul
310310><li
311311 ><span class="math"
312− >\frac{<em
313− >d</em
314− >}{<em
315− >dx</em
316− >}<em
317− >f</em
318− >(<em
319− >x</em
320− >)=\lim<sub
321− ><em
322− >h</em
323− > → 0</sub
324− >\frac{<em
325− >f</em
326− >(<em
327− >x</em
328− >+<em
329− >h</em
330− >)-<em
331− >f</em
332− >(<em
333− >x</em
334− >)}{<em
335− >h</em
336− >}</span
312+ >$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span
337313 ></li
338314 ></ul
339315></div>
tests/s5.fragment.html+1−25
@@ -14,31 +14,7 @@
1414 ><ul
1515 ><li
1616 ><span class="math"
17− >\frac{<em
18− >d</em
19− >}{<em
20− >dx</em
21− >}<em
22− >f</em
23− >(<em
24− >x</em
25− >)=\lim<sub
26− ><em
27− >h</em
28− > → 0</sub
29− >\frac{<em
30− >f</em
31− >(<em
32− >x</em
33− >+<em
34− >h</em
35− >)-<em
36− >f</em
37− >(<em
38− >x</em
39− >)}{<em
40− >h</em
41− >}</span
17+ >$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span
4218 ></li
4319 ></ul
4420 ></div
tests/s5.inserts.html+1−25
@@ -29,31 +29,7 @@ STUFF INSERTED
2929 ><ul
3030 ><li
3131 ><span class="math"
32− >\frac{<em
33− >d</em
34− >}{<em
35− >dx</em
36− >}<em
37− >f</em
38− >(<em
39− >x</em
40− >)=\lim<sub
41− ><em
42− >h</em
43− > → 0</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− >}</span
32+ >$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span
5733 ></li
5834 ></ul
5935 ></div
tests/writer.docbook+5−5
@@ -1077,17 +1077,17 @@ Blah
10771077 </listitem>
10781078 <listitem>
10791079 <para>
1080− 2+2=4
1080+ 2 + 2 = 4
10811081 </para>
10821082 </listitem>
10831083 <listitem>
10841084 <para>
1085− <emphasis>x</emphasis> ∈ <emphasis>y</emphasis>
1085+ <emphasis>x</emphasis> ∈ <emphasis>y</emphasis>
10861086 </para>
10871087 </listitem>
10881088 <listitem>
10891089 <para>
1090− α ∧ ω
1090+ α ∧ ω
10911091 </para>
10921092 </listitem>
10931093 <listitem>
@@ -1103,13 +1103,13 @@ Blah
11031103 <listitem>
11041104 <para>
11051105 Here's some display math:
1106− \frac{<emphasis>d</emphasis>}{<emphasis>dx</emphasis>}<emphasis>f</emphasis>(<emphasis>x</emphasis>)=\lim<subscript><emphasis>h</emphasis> → 0</subscript>\frac{<emphasis>f</emphasis>(<emphasis>x</emphasis>+<emphasis>h</emphasis>)-<emphasis>f</emphasis>(<emphasis>x</emphasis>)}{<emphasis>h</emphasis>}
1106+ $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$
11071107 </para>
11081108 </listitem>
11091109 <listitem>
11101110 <para>
11111111 Here's one that has a line break in it:
1112− α+ω × <emphasis>x</emphasis><superscript>2</superscript>.
1112+ α + ω × <emphasis>x</emphasis><superscript>2</superscript>.
11131113 </para>
11141114 </listitem>
11151115 </itemizedlist>
tests/writer.html+5−29
@@ -830,19 +830,19 @@ Blah
830830 ></li
831831 ><li
832832 ><span class="math"
833− >2+2=4</span
833+ >2 + 2 = 4</span
834834 ></li
835835 ><li
836836 ><span class="math"
837837 ><em
838838 >x</em
839− > ∈ <em
839+ > ∈ <em
840840 >y</em
841841 ></span
842842 ></li
843843 ><li
844844 ><span class="math"
845− >α ∧ ω</span
845+ >α ∧ ω</span
846846 ></li
847847 ><li
848848 ><span class="math"
@@ -856,35 +856,11 @@ Blah
856856 >-Tree</li
857857 ><li
858858 >Here’s some display math: <span class="math"
859− >\frac{<em
860− >d</em
861− >}{<em
862− >dx</em
863− >}<em
864− >f</em
865− >(<em
866− >x</em
867− >)=\lim<sub
868− ><em
869− >h</em
870− > → 0</sub
871− >\frac{<em
872− >f</em
873− >(<em
874− >x</em
875− >+<em
876− >h</em
877− >)-<em
878− >f</em
879− >(<em
880− >x</em
881− >)}{<em
882− >h</em
883− >}</span
859+ >$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span
884860 ></li
885861 ><li
886862 >Here’s one that has a line break in it: <span class="math"
887− >α+ω × <em
863+ >α + ω × <em
888864 >x</em
889865 ><sup
890866 >2</sup
tests/writer.opendocument+12−25
@@ -689,30 +689,17 @@
689689 <style:style style:name="T59" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
690690 <style:style style:name="T60" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
691691 <style:style style:name="T61" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
692− <style:style style:name="T62" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
692+ <style:style style:name="T62" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>
693693 <style:style style:name="T63" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
694694 <style:style style:name="T64" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
695− <style:style style:name="T65" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" style:text-position="sub 58%" /></style:style>
696− <style:style style:name="T66" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>
697− <style:style style:name="T67" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>
695+ <style:style style:name="T65" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
696+ <style:style style:name="T66" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
697+ <style:style style:name="T67" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
698698 <style:style style:name="T68" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
699699 <style:style style:name="T69" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
700700 <style:style style:name="T70" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
701701 <style:style style:name="T71" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
702702 <style:style style:name="T72" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
703− <style:style style:name="T73" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
704− <style:style style:name="T74" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
705− <style:style style:name="T75" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>
706− <style:style style:name="T76" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
707− <style:style style:name="T77" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
708− <style:style style:name="T78" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
709− <style:style style:name="T79" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
710− <style:style style:name="T80" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
711− <style:style style:name="T81" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
712− <style:style style:name="T82" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
713− <style:style style:name="T83" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
714− <style:style style:name="T84" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
715− <style:style style:name="T85" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
716703 <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Quotations">
717704 <style:paragraph-properties fo:margin-left="0.5in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" />
718705 </style:style>
@@ -1317,13 +1304,13 @@
13171304 <text:p text:style-name="P51"><text:span text:style-name="Teletype">\cite[22-23]{smith.1899}</text:span></text:p>
13181305 </text:list-item>
13191306 <text:list-item>
1320− <text:p text:style-name="P51">2+2=4</text:p>
1307+ <text:p text:style-name="P51">2 + 2 = 4</text:p>
13211308 </text:list-item>
13221309 <text:list-item>
1323− <text:p text:style-name="P51"><text:span text:style-name="T58">x</text:span> ∈ <text:span text:style-name="T59">y</text:span></text:p>
1310+ <text:p text:style-name="P51"><text:span text:style-name="T58">x</text:span> ∈ <text:span text:style-name="T59">y</text:span></text:p>
13241311 </text:list-item>
13251312 <text:list-item>
1326− <text:p text:style-name="P51">α ∧ ω</text:p>
1313+ <text:p text:style-name="P51">α ∧ ω</text:p>
13271314 </text:list-item>
13281315 <text:list-item>
13291316 <text:p text:style-name="P51">223</text:p>
@@ -1332,10 +1319,10 @@
13321319 <text:p text:style-name="P51"><text:span text:style-name="T60">p</text:span>-Tree</text:p>
13331320 </text:list-item>
13341321 <text:list-item>
1335− <text:p text:style-name="P51">Here&#8217;s some display math: \frac{<text:span text:style-name="T61">d</text:span>}{<text:span text:style-name="T62">dx</text:span>}<text:span text:style-name="T63">f</text:span>(<text:span text:style-name="T64">x</text:span>)=\lim<text:span text:style-name="T65">h</text:span><text:span text:style-name="T66"> → </text:span><text:span text:style-name="T67">0</text:span>\frac{<text:span text:style-name="T68">f</text:span>(<text:span text:style-name="T69">x</text:span>+<text:span text:style-name="T70">h</text:span>)-<text:span text:style-name="T71">f</text:span>(<text:span text:style-name="T72">x</text:span>)}{<text:span text:style-name="T73">h</text:span>}</text:p>
1322+ <text:p text:style-name="P51">Here&#8217;s some display math: $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</text:p>
13361323 </text:list-item>
13371324 <text:list-item>
1338− <text:p text:style-name="P51">Here&#8217;s one that has a line break in it: α+ω × <text:span text:style-name="T74">x</text:span><text:span text:style-name="T75">2</text:span>.</text:p>
1325+ <text:p text:style-name="P51">Here&#8217;s one that has a line break in it: α + ω × <text:span text:style-name="T61">x</text:span><text:span text:style-name="T62">2</text:span>.</text:p>
13391326 </text:list-item>
13401327</text:list>
13411328<text:p text:style-name="Text_20_body">These shouldn&#8217;t be math:</text:p>
@@ -1344,13 +1331,13 @@
13441331 <text:p text:style-name="P52">To get the famous equation, write <text:span text:style-name="Teletype">$e = mc^2$</text:span>.</text:p>
13451332 </text:list-item>
13461333 <text:list-item>
1347− <text:p text:style-name="P52">$22,000 is a <text:span text:style-name="T76">lot</text:span> of money. So is $34,000. (It worked if &#8220;lot&#8221; is emphasized.)</text:p>
1334+ <text:p text:style-name="P52">$22,000 is a <text:span text:style-name="T63">lot</text:span> of money. So is $34,000. (It worked if &#8220;lot&#8221; is emphasized.)</text:p>
13481335 </text:list-item>
13491336 <text:list-item>
13501337 <text:p text:style-name="P52">Shoes ($20) and socks ($5).</text:p>
13511338 </text:list-item>
13521339 <text:list-item>
1353− <text:p text:style-name="P52">Escaped <text:span text:style-name="Teletype">$</text:span>: $73 <text:span text:style-name="T77">this</text:span><text:span text:style-name="T78"> </text:span><text:span text:style-name="T79">should</text:span><text:span text:style-name="T80"> </text:span><text:span text:style-name="T81">be</text:span><text:span text:style-name="T82"> </text:span><text:span text:style-name="T83">emphasized</text:span> 23$.</text:p>
1340+ <text:p text:style-name="P52">Escaped <text:span text:style-name="Teletype">$</text:span>: $73 <text:span text:style-name="T64">this</text:span><text:span text:style-name="T65"> </text:span><text:span text:style-name="T66">should</text:span><text:span text:style-name="T67"> </text:span><text:span text:style-name="T68">be</text:span><text:span text:style-name="T69"> </text:span><text:span text:style-name="T70">emphasized</text:span> 23$.</text:p>
13541341 </text:list-item>
13551342</text:list>
13561343<text:p text:style-name="Text_20_body">Here&#8217;s a LaTeX table:</text:p>
@@ -1454,7 +1441,7 @@ Cat <text:s text:c="3" />&amp; 1 <text:s text:c="5" />\\ \hline
14541441<text:p text:style-name="Text_20_body">Here is a movie <draw:frame><draw:image xlink:href="movie.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame> icon.</text:p>
14551442<text:p text:style-name="Horizontal_20_Line" />
14561443<text:h text:style-name="Heading_20_1" text:outline-level="1">Footnotes</text:h>
1457−<text:p text:style-name="Text_20_body">Here is a footnote reference,<text:note text:id="ftn0" text:note-class="footnote"><text:note-citation>1</text:note-citation><text:note-body><text:p text:style-name="Footnote">Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.</text:p></text:note-body></text:note> and another.<text:note text:id="ftn1" text:note-class="footnote"><text:note-citation>2</text:note-citation><text:note-body><text:p text:style-name="Footnote">Here&#8217;s the long note. This one contains multiple blocks.</text:p><text:p text:style-name="Footnote">Subsequent blocks are indented to show that they belong to the footnote (as with list items).</text:p><text:p text:style-name="P58"><text:s text:c="2" />{ &lt;code&gt; }</text:p><text:p text:style-name="Footnote">If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.</text:p></text:note-body></text:note> This should <text:span text:style-name="T84">not</text:span> be a footnote reference, because it contains a space.[^my note] Here is an inline note.<text:note text:id="ftn2" text:note-class="footnote"><text:note-citation>3</text:note-citation><text:note-body><text:p text:style-name="Footnote">This is <text:span text:style-name="T85">easier</text:span> to type. Inline notes may contain <text:a xlink:type="simple" xlink:href="http://google.com" office:name=""><text:span text:style-name="Definition">links</text:span></text:a> and <text:span text:style-name="Teletype">]</text:span> verbatim characters, as well as [bracketed text].</text:p></text:note-body></text:note></text:p>
1444+<text:p text:style-name="Text_20_body">Here is a footnote reference,<text:note text:id="ftn0" text:note-class="footnote"><text:note-citation>1</text:note-citation><text:note-body><text:p text:style-name="Footnote">Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.</text:p></text:note-body></text:note> and another.<text:note text:id="ftn1" text:note-class="footnote"><text:note-citation>2</text:note-citation><text:note-body><text:p text:style-name="Footnote">Here&#8217;s the long note. This one contains multiple blocks.</text:p><text:p text:style-name="Footnote">Subsequent blocks are indented to show that they belong to the footnote (as with list items).</text:p><text:p text:style-name="P58"><text:s text:c="2" />{ &lt;code&gt; }</text:p><text:p text:style-name="Footnote">If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.</text:p></text:note-body></text:note> This should <text:span text:style-name="T71">not</text:span> be a footnote reference, because it contains a space.[^my note] Here is an inline note.<text:note text:id="ftn2" text:note-class="footnote"><text:note-citation>3</text:note-citation><text:note-body><text:p text:style-name="Footnote">This is <text:span text:style-name="T72">easier</text:span> to type. Inline notes may contain <text:a xlink:type="simple" xlink:href="http://google.com" office:name=""><text:span text:style-name="Definition">links</text:span></text:a> and <text:span text:style-name="Teletype">]</text:span> verbatim characters, as well as [bracketed text].</text:p></text:note-body></text:note></text:p>
14581445<text:p text:style-name="P59">Notes can go in quotes.<text:note text:id="ftn3" text:note-class="footnote"><text:note-citation>4</text:note-citation><text:note-body><text:p text:style-name="Footnote">In quote.</text:p></text:note-body></text:note></text:p>
14591446<text:list text:style-name="L30">
14601447 <text:list-item>
tests/writer.rtf+5−5
@@ -264,13 +264,13 @@ quoted link
264264{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
265265{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 LaTeX\par}
266266{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab \par}
267−{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab 2+2=4\par}
268−{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\i x}\u8201?\u8712?\u8201?{\i y}\par}
269−{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab \u945?\u8201?\u8743?\u8201?\u969?\par}
267+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab 2\u8197?+\u8197?2\u8196?=\u8196?4\par}
268+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\i x}\u8196?\u8712?\u8196?{\i y}\par}
269+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab \u945?\u8197?\u8743?\u8197?\u969?\par}
270270{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab 223\par}
271271{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\i p}-Tree\par}
272−{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Here\u8217's some display math: \\frac\{{\i d}\}\{{\i dx}\}{\i f}({\i x})=\\lim{\sub {\i h}\u8201?\u8594?\u8201?0}\\frac\{{\i f}({\i x}+{\i h})-{\i f}({\i x})\}\{{\i h}\}\par}
273−{\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}
272+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Here\u8217's some display math: $\\frac\{d\}\{dx\}f(x)=\\lim_\{h\\to 0\}\\frac\{f(x+h)-f(x)\}\{h\}$\par}
273+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Here\u8217's one that has a line break in it: \u945?\u8197?+\u8197?\u969?\u8197?\u215?\u8197?{\i x}{\super 2}.\sa180\par}
274274{\pard \ql \f0 \sa180 \li0 \fi0 These shouldn\u8217't be math:\par}
275275{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab To get the famous equation, write {\f1 $e = mc^2$}.\par}
276276{\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}