git.iko.soy/typeable/pandoc
on master help sign in
OpenDocument writer: don't profilerate text styles unnecessarily.

This change makes the writer create only as many temporary text styles as are absolutely necessary. It also consolidates adjacent nodes with the same style. Closes #3371.

commit41f4476aabe4eacec06e47c5d6dba2503b1eb1f0 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 23 Jan 2017, 15:18 (10 years ago) parentfaf4f78
2 files changed+102−137
src/Text/Pandoc/Writers/OpenDocument.hs+62−25 tests/writer.opendocument+40−112
src/Text/Pandoc/Writers/OpenDocument.hs+62−25
@@ -41,8 +41,11 @@ import Text.Printf ( printf )
4141import Control.Arrow ( (***), (>>>) )
4242import Control.Monad.State hiding ( when )
4343import Data.Char (chr)
44+import qualified Data.Set as Set
4445import qualified Data.Map as Map
4546import Text.Pandoc.Writers.Shared
47+import Data.List (sortBy)
48+import Data.Ord (comparing)
4649
4750-- | Auxiliary function to convert Plain block to Para.
4851plainToPara :: Block -> Block
@@ -58,8 +61,8 @@ data WriterState =
5861 , stTableStyles :: [Doc]
5962 , stParaStyles :: [Doc]
6063 , stListStyles :: [(Int, [Doc])]
61− , stTextStyles :: [Doc]
62− , stTextStyleAttr :: Map.Map TextStyle [(String,String)]
64+ , stTextStyles :: Map.Map (Set.Set TextStyle) (String, Doc)
65+ , stTextStyleAttr :: Set.Set TextStyle
6366 , stIndentPara :: Int
6467 , stInDefinition :: Bool
6568 , stTight :: Bool
@@ -73,8 +76,8 @@ defaultWriterState =
7376 , stTableStyles = []
7477 , stParaStyles = []
7578 , stListStyles = []
76− , stTextStyles = []
77− , stTextStyleAttr = Map.empty
79+ , stTextStyles = Map.empty
80+ , stTextStyleAttr = Set.empty
7881 , stIndentPara = 0
7982 , stInDefinition = False
8083 , stTight = False
@@ -94,14 +97,13 @@ addNote i = modify $ \s -> s { stNotes = i : stNotes s }
9497addParaStyle :: Doc -> State WriterState ()
9598addParaStyle i = modify $ \s -> s { stParaStyles = i : stParaStyles s }
9699
97−addTextStyle :: Doc -> State WriterState ()
98−addTextStyle i = modify $ \s -> s { stTextStyles = i : stTextStyles s }
100+addTextStyle :: Set.Set TextStyle -> (String, Doc) -> State WriterState ()
101+addTextStyle attrs i = modify $ \s ->
102+ s { stTextStyles = Map.insert attrs i (stTextStyles s) }
99103
100−addTextStyleAttr :: (TextStyle, [(String,String)]) -> State WriterState ()
101−addTextStyleAttr (ts, xs) = modify $ \s -> s { stTextStyleAttr = Map.insert ts xs (stTextStyleAttr s) }
102−
103−rmTextStyleAttr :: TextStyle -> State WriterState ()
104−rmTextStyleAttr ts = modify $ \s -> s { stTextStyleAttr = Map.delete ts (stTextStyleAttr s) }
104+addTextStyleAttr :: TextStyle -> State WriterState ()
105+addTextStyleAttr t = modify $ \s ->
106+ s { stTextStyleAttr = Set.insert t (stTextStyleAttr s) }
105107
106108increaseIndent :: State WriterState ()
107109increaseIndent = modify $ \s -> s { stIndentPara = 1 + stIndentPara s }
@@ -136,20 +138,33 @@ inSpanTags :: String -> Doc -> Doc
136138inSpanTags s = inTags False "text:span" [("text:style-name",s)]
137139
138140withTextStyle :: TextStyle -> State WriterState a -> State WriterState a
139−withTextStyle s f = addTextStyleAttr (s,textStyleAttr s) >>
140− f >>= \r -> rmTextStyleAttr s >> return r
141+withTextStyle s f = do
142+ oldTextStyleAttr <- gets stTextStyleAttr
143+ addTextStyleAttr s
144+ res <- f
145+ modify $ \st -> st{ stTextStyleAttr = oldTextStyleAttr }
146+ return res
141147
142148inTextStyle :: Doc -> State WriterState Doc
143149inTextStyle d = do
144150 at <- gets stTextStyleAttr
145− if Map.null at
151+ if Set.null at
146152 then return d
147153 else do
148− tn <- (+) 1 . length <$> gets stTextStyles
149− addTextStyle $ inTags False "style:style" [("style:name" , "T" ++ show tn)
150− ,("style:family", "text" )]
151− $ selfClosingTag "style:text-properties" (concatMap snd $ Map.toList at)
152− return $ inTags False "text:span" [("text:style-name","T" ++ show tn)] d
154+ styles <- gets stTextStyles
155+ case Map.lookup at styles of
156+ Just (styleName, _) -> return $
157+ inTags False "text:span" [("text:style-name",styleName)] d
158+ Nothing -> do
159+ let styleName = "T" ++ show (Map.size styles + 1)
160+ addTextStyle at (styleName,
161+ inTags False "style:style"
162+ [("style:name", styleName)
163+ ,("style:family", "text")]
164+ $ selfClosingTag "style:text-properties"
165+ (concatMap textStyleAttr (Set.toList at)))
166+ return $ inTags False
167+ "text:span" [("text:style-name",styleName)] d
153168
154169inHeaderTags :: Int -> Doc -> State WriterState Doc
155170inHeaderTags i d =
@@ -188,7 +203,9 @@ writeOpenDocument opts (Pandoc meta blocks) =
188203 meta
189204 b <- render' `fmap` blocksToOpenDocument opts blocks
190205 return (b, m)
191− styles = stTableStyles s ++ stParaStyles s ++ stTextStyles s
206+ styles = stTableStyles s ++ stParaStyles s ++
207+ map snd (reverse $ sortBy (comparing fst) $
208+ Map.elems (stTextStyles s))
192209 listStyle (n,l) = inTags True "text:list-style"
193210 [("style:name", "L" ++ show n)] (vcat l)
194211 listStyles = map listStyle (stListStyles s)
@@ -371,20 +388,40 @@ tableItemToOpenDocument o tn (n,i) =
371388
372389-- | Convert a list of inline elements to OpenDocument.
373390inlinesToOpenDocument :: WriterOptions -> [Inline] -> State WriterState Doc
374−inlinesToOpenDocument o l = hcat <$> mapM (inlineToOpenDocument o) l
391+inlinesToOpenDocument o l = hcat <$> toChunks o l
392+
393+toChunks :: WriterOptions -> [Inline] -> State WriterState [Doc]
394+toChunks _ [] = return []
395+toChunks o (x : xs)
396+ | isChunkable x = do
397+ contents <- (inTextStyle . hcat) =<<
398+ mapM (inlineToOpenDocument o) (x:ys)
399+ rest <- toChunks o zs
400+ return (contents : rest)
401+ | otherwise = do
402+ contents <- inlineToOpenDocument o x
403+ rest <- toChunks o xs
404+ return (contents : rest)
405+ where (ys, zs) = span isChunkable xs
406+
407+isChunkable :: Inline -> Bool
408+isChunkable (Str _) = True
409+isChunkable Space = True
410+isChunkable SoftBreak = True
411+isChunkable _ = False
375412
376413-- | Convert an inline element to OpenDocument.
377414inlineToOpenDocument :: WriterOptions -> Inline -> State WriterState Doc
378415inlineToOpenDocument o ils
379416 = case ils of
380− Space -> inTextStyle space
417+ Space -> return space
381418 SoftBreak
382419 | writerWrapText o == WrapPreserve
383− -> inTextStyle (preformatted "\n")
384− | otherwise -> inTextStyle space
420+ -> return $ preformatted "\n"
421+ | otherwise -> return $ space
385422 Span _ xs -> inlinesToOpenDocument o xs
386423 LineBreak -> return $ selfClosingTag "text:line-break" []
387− Str s -> inTextStyle $ handleSpaces $ escapeStringForXML s
424+ Str s -> return $ handleSpaces $ escapeStringForXML s
388425 Emph l -> withTextStyle Italic $ inlinesToOpenDocument o l
389426 Strong l -> withTextStyle Bold $ inlinesToOpenDocument o l
390427 Strikeout l -> withTextStyle Strike $ inlinesToOpenDocument o l
tests/writer.opendocument+40−112
@@ -632,73 +632,13 @@
632632 </text:list-level-style-number>
633633 </text:list-style>
634634 <style:style style:name="T1" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
635− <style:style style:name="T2" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
636− <style:style style:name="T3" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
637− <style:style style:name="T4" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
638− <style:style style:name="T5" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
639− <style:style style:name="T6" style:family="text"><style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
640− <style:style style:name="T7" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
641− <style:style style:name="T8" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
642− <style:style style:name="T9" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
643− <style:style style:name="T10" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
644− <style:style style:name="T11" style:family="text"><style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
645− <style:style style:name="T12" style:family="text"><style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
646− <style:style style:name="T13" style:family="text"><style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
647− <style:style style:name="T14" style:family="text"><style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
648− <style:style style:name="T15" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
649− <style:style style:name="T16" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
650− <style:style style:name="T17" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
651− <style:style style:name="T18" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
652− <style:style style:name="T19" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
653− <style:style style:name="T20" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
654− <style:style style:name="T21" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
655− <style:style style:name="T22" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
656− <style:style style:name="T23" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
657− <style:style style:name="T24" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
658− <style:style style:name="T25" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
659− <style:style style:name="T26" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
660− <style:style style:name="T27" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
661− <style:style style:name="T28" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
662− <style:style style:name="T29" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
663− <style:style style:name="T30" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
664− <style:style style:name="T31" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
665− <style:style style:name="T32" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
666− <style:style style:name="T33" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
667− <style:style style:name="T34" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
668− <style:style style:name="T35" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
669− <style:style style:name="T36" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
670− <style:style style:name="T37" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
671− <style:style style:name="T38" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
672− <style:style style:name="T39" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
673− <style:style style:name="T40" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
674− <style:style style:name="T41" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
675− <style:style style:name="T42" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" style:text-line-through-style="solid" /></style:style>
676− <style:style style:name="T43" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
677− <style:style style:name="T44" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>
678− <style:style style:name="T45" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" style:text-position="super 58%" /></style:style>
679− <style:style style:name="T46" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>
680− <style:style style:name="T47" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>
681− <style:style style:name="T48" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>
682− <style:style style:name="T49" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>
683− <style:style style:name="T50" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
684− <style:style style:name="T51" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
685− <style:style style:name="T52" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
686− <style:style style:name="T53" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
687− <style:style style:name="T54" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
688− <style:style style:name="T55" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
689− <style:style style:name="T56" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
690− <style:style style:name="T57" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
691− <style:style style:name="T58" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>
692− <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>
693− <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>
694− <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>
695− <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>
696− <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>
697− <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>
698− <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>
699− <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>
700− <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>
701− <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>
635+ <style:style style:name="T2" style:family="text"><style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
636+ <style:style style:name="T3" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
637+ <style:style style:name="T4" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
638+ <style:style style:name="T5" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" style:text-line-through-style="solid" /></style:style>
639+ <style:style style:name="T6" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>
640+ <style:style style:name="T7" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" style:text-position="super 58%" /></style:style>
641+ <style:style style:name="T8" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>
702642 <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Quotations">
703643 <style:paragraph-properties fo:margin-left="0.5in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" />
704644 </style:style>
@@ -871,7 +811,7 @@ link</text:span></text:a></text:h>
871811<text:h text:style-name="Heading_20_5" text:outline-level="5">Level 5</text:h>
872812<text:h text:style-name="Heading_20_1" text:outline-level="1">Level 1</text:h>
873813<text:h text:style-name="Heading_20_2" text:outline-level="2">Level 2 with
874−<text:span text:style-name="T2">emphasis</text:span></text:h>
814+<text:span text:style-name="T1">emphasis</text:span></text:h>
875815<text:h text:style-name="Heading_20_3" text:outline-level="3">Level 3</text:h>
876816<text:p text:style-name="First_20_paragraph">with no blank line</text:p>
877817<text:h text:style-name="Heading_20_2" text:outline-level="2">Level 2</text:h>
@@ -1244,11 +1184,11 @@ fruit</text:p>
12441184<text:p text:style-name="Definition_20_Definition">yellow fruit</text:p>
12451185<text:p text:style-name="First_20_paragraph">Multiple blocks with
12461186italics:</text:p>
1247−<text:p text:style-name="Definition_20_Term"><text:span text:style-name="T3">apple</text:span></text:p>
1187+<text:p text:style-name="Definition_20_Term"><text:span text:style-name="T1">apple</text:span></text:p>
12481188<text:p text:style-name="Definition_20_Definition">red
12491189fruit</text:p><text:p text:style-name="Definition_20_Definition">contains
12501190seeds, crisp, pleasant to taste</text:p>
1251−<text:p text:style-name="Definition_20_Term"><text:span text:style-name="T4">orange</text:span></text:p>
1191+<text:p text:style-name="Definition_20_Term"><text:span text:style-name="T1">orange</text:span></text:p>
12521192<text:p text:style-name="Definition_20_Definition">orange fruit</text:p><text:p text:style-name="P42">{ orange code block }</text:p><text:p text:style-name="P43">orange
12531193block quote</text:p>
12541194<text:p text:style-name="First_20_paragraph">Multiple definitions,
@@ -1295,9 +1235,9 @@ indentation:</text:p>
12951235<text:p text:style-name="Text_20_body">Interpreted markdown in a
12961236table:</text:p>
12971237<text:p text:style-name="Text_20_body">This is
1298−<text:span text:style-name="T5">emphasized</text:span></text:p>
1238+<text:span text:style-name="T1">emphasized</text:span></text:p>
12991239<text:p text:style-name="Text_20_body">And this is
1300−<text:span text:style-name="T6">strong</text:span></text:p>
1240+<text:span text:style-name="T2">strong</text:span></text:p>
13011241<text:p text:style-name="Text_20_body">Here’s a simple block:</text:p>
13021242<text:p text:style-name="Text_20_body">foo</text:p>
13031243<text:p text:style-name="Text_20_body">This should be a code block,
@@ -1323,47 +1263,38 @@ spaces on the line:</text:p>
13231263<text:h text:style-name="Heading_20_1" text:outline-level="1">Inline
13241264Markup</text:h>
13251265<text:p text:style-name="First_20_paragraph">This is
1326−<text:span text:style-name="T7">emphasized</text:span>, and so
1327−<text:span text:style-name="T8">is</text:span><text:span text:style-name="T9">
1328−</text:span><text:span text:style-name="T10">this</text:span>.</text:p>
1266+<text:span text:style-name="T1">emphasized</text:span>, and so
1267+<text:span text:style-name="T1">is this</text:span>.</text:p>
13291268<text:p text:style-name="Text_20_body">This is
1330−<text:span text:style-name="T11">strong</text:span>, and so
1331−<text:span text:style-name="T12">is</text:span><text:span text:style-name="T13">
1332−</text:span><text:span text:style-name="T14">this</text:span>.</text:p>
1269+<text:span text:style-name="T2">strong</text:span>, and so
1270+<text:span text:style-name="T2">is this</text:span>.</text:p>
13331271<text:p text:style-name="Text_20_body">An
1334−<text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition"><text:span text:style-name="T15">emphasized</text:span><text:span text:style-name="T16">
1335−</text:span><text:span text:style-name="T17">link</text:span></text:span></text:a>.</text:p>
1336−<text:p text:style-name="Text_20_body"><text:span text:style-name="T18">This</text:span><text:span text:style-name="T19">
1337−</text:span><text:span text:style-name="T20">is</text:span><text:span text:style-name="T21">
1338−</text:span><text:span text:style-name="T22">strong</text:span><text:span text:style-name="T23">
1339−</text:span><text:span text:style-name="T24">and</text:span><text:span text:style-name="T25">
1340−</text:span><text:span text:style-name="T26">em.</text:span></text:p>
1272+<text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition"><text:span text:style-name="T1">emphasized
1273+link</text:span></text:span></text:a>.</text:p>
1274+<text:p text:style-name="Text_20_body"><text:span text:style-name="T3">This is
1275+strong and em.</text:span></text:p>
13411276<text:p text:style-name="Text_20_body">So is
1342−<text:span text:style-name="T27">this</text:span> word.</text:p>
1343−<text:p text:style-name="Text_20_body"><text:span text:style-name="T28">This</text:span><text:span text:style-name="T29">
1344−</text:span><text:span text:style-name="T30">is</text:span><text:span text:style-name="T31">
1345−</text:span><text:span text:style-name="T32">strong</text:span><text:span text:style-name="T33">
1346−</text:span><text:span text:style-name="T34">and</text:span><text:span text:style-name="T35">
1347−</text:span><text:span text:style-name="T36">em.</text:span></text:p>
1277+<text:span text:style-name="T3">this</text:span> word.</text:p>
1278+<text:p text:style-name="Text_20_body"><text:span text:style-name="T3">This is
1279+strong and em.</text:span></text:p>
13481280<text:p text:style-name="Text_20_body">So is
1349−<text:span text:style-name="T37">this</text:span> word.</text:p>
1281+<text:span text:style-name="T3">this</text:span> word.</text:p>
13501282<text:p text:style-name="Text_20_body">This is code:
13511283<text:span text:style-name="Source_Text">&gt;</text:span>,
13521284<text:span text:style-name="Source_Text">$</text:span>,
13531285<text:span text:style-name="Source_Text">\</text:span>,
13541286<text:span text:style-name="Source_Text">\$</text:span>,
13551287<text:span text:style-name="Source_Text">&lt;html&gt;</text:span>.</text:p>
1356−<text:p text:style-name="Text_20_body"><text:span text:style-name="T38">This</text:span><text:span text:style-name="T39">
1357−</text:span><text:span text:style-name="T40">is</text:span><text:span text:style-name="T41">
1358−</text:span><text:span text:style-name="T42">strikeout</text:span><text:span text:style-name="T43">.</text:span></text:p>
1288+<text:p text:style-name="Text_20_body"><text:span text:style-name="T4">This is
1289+</text:span><text:span text:style-name="T5">strikeout</text:span><text:span text:style-name="T4">.</text:span></text:p>
13591290<text:p text:style-name="Text_20_body">Superscripts:
1360−a<text:span text:style-name="T44">bc</text:span>d
1361−a<text:span text:style-name="T45">hello</text:span>
1362−a<text:span text:style-name="T46">hello there</text:span>.</text:p>
1291+a<text:span text:style-name="T6">bc</text:span>d
1292+a<text:span text:style-name="T7">hello</text:span>
1293+a<text:span text:style-name="T6">hello there</text:span>.</text:p>
13631294<text:p text:style-name="Text_20_body">Subscripts:
1364−H<text:span text:style-name="T47">2</text:span>O,
1365−H<text:span text:style-name="T48">23</text:span>O,
1366−H<text:span text:style-name="T49">many of them</text:span>O.</text:p>
1295+H<text:span text:style-name="T8">2</text:span>O,
1296+H<text:span text:style-name="T8">23</text:span>O,
1297+H<text:span text:style-name="T8">many of them</text:span>O.</text:p>
13671298<text:p text:style-name="Text_20_body">These should not be superscripts or
13681299subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.</text:p>
13691300<text:p text:style-name="Horizontal_20_Line" />
@@ -1395,16 +1326,16 @@ five.</text:p>
13951326 <text:p text:style-name="P51">2 + 2 = 4</text:p>
13961327 </text:list-item>
13971328 <text:list-item>
1398− <text:p text:style-name="P51"><text:span text:style-name="T50">x</text:span> ∈ <text:span text:style-name="T51">y</text:span></text:p>
1329+ <text:p text:style-name="P51"><text:span text:style-name="T1">x</text:span> ∈ <text:span text:style-name="T1">y</text:span></text:p>
13991330 </text:list-item>
14001331 <text:list-item>
1401− <text:p text:style-name="P51"><text:span text:style-name="T52">α</text:span> ∧ <text:span text:style-name="T53">ω</text:span></text:p>
1332+ <text:p text:style-name="P51"><text:span text:style-name="T1">α</text:span> ∧ <text:span text:style-name="T1">ω</text:span></text:p>
14021333 </text:list-item>
14031334 <text:list-item>
14041335 <text:p text:style-name="P51">223</text:p>
14051336 </text:list-item>
14061337 <text:list-item>
1407− <text:p text:style-name="P51"><text:span text:style-name="T54">p</text:span>-Tree</text:p>
1338+ <text:p text:style-name="P51"><text:span text:style-name="T1">p</text:span>-Tree</text:p>
14081339 </text:list-item>
14091340 <text:list-item>
14101341 <text:p text:style-name="P51">Here’s some display math:
@@ -1412,7 +1343,7 @@ five.</text:p>
14121343 </text:list-item>
14131344 <text:list-item>
14141345 <text:p text:style-name="P51">Here’s one that has a line break in it:
1415− <text:span text:style-name="T55">α</text:span> + <text:span text:style-name="T56">ω</text:span> × <text:span text:style-name="T57">x</text:span><text:span text:style-name="T58">2</text:span>.</text:p>
1346+ <text:span text:style-name="T1">α</text:span> + <text:span text:style-name="T1">ω</text:span> × <text:span text:style-name="T1">x</text:span><text:span text:style-name="T6">2</text:span>.</text:p>
14161347 </text:list-item>
14171348</text:list>
14181349<text:p text:style-name="First_20_paragraph">These shouldn’t be math:</text:p>
@@ -1423,7 +1354,7 @@ five.</text:p>
14231354 </text:list-item>
14241355 <text:list-item>
14251356 <text:p text:style-name="P52">$22,000 is a
1426− <text:span text:style-name="T59">lot</text:span> of money. So is $34,000.
1357+ <text:span text:style-name="T1">lot</text:span> of money. So is $34,000.
14271358 (It worked if “lot” is emphasized.)</text:p>
14281359 </text:list-item>
14291360 <text:list-item>
@@ -1432,10 +1363,7 @@ five.</text:p>
14321363 <text:list-item>
14331364 <text:p text:style-name="P52">Escaped
14341365 <text:span text:style-name="Source_Text">$</text:span>: $73
1435− <text:span text:style-name="T60">this</text:span><text:span text:style-name="T61">
1436− </text:span><text:span text:style-name="T62">should</text:span><text:span text:style-name="T63">
1437− </text:span><text:span text:style-name="T64">be</text:span><text:span text:style-name="T65">
1438− </text:span><text:span text:style-name="T66">emphasized</text:span>
1366+ <text:span text:style-name="T1">this should be emphasized</text:span>
14391367 23$.</text:p>
14401368 </text:list-item>
14411369</text:list>
@@ -1585,10 +1513,10 @@ indented to show that they belong to the footnote (as with list
15851513items).</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
15861514you want, you can indent every line, but you can also be lazy and just indent
15871515the first line of each block.</text:p></text:note-body></text:note> This
1588−should <text:span text:style-name="T67">not</text:span> be a footnote
1516+should <text:span text:style-name="T1">not</text:span> be a footnote
15891517reference, because it contains a space.[^my note] Here is an inline
15901518note.<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
1591−is <text:span text:style-name="T68">easier</text:span> to type. Inline notes
1519+is <text:span text:style-name="T1">easier</text:span> to type. Inline notes
15921520may contain
15931521<text:a xlink:type="simple" xlink:href="http://google.com" office:name=""><text:span text:style-name="Definition">links</text:span></text:a>
15941522and <text:span text:style-name="Source_Text">]</text:span> verbatim