diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-12-28 22:30:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-28 22:30:25 -0700 |
commit | ac8e72a95d3a4f9f6988bcf4b1f12cb14ef7ec24 (patch) | |
tree | 96f898af9822da31b559695d4123e3483b9fbbc9 /src/Text/Pandoc/Writers/ODT.hs | |
parent | bc8b4de3e81971eb0f05ed02b7b2ebaacc3d1959 (diff) | |
parent | 19bab48dccd670e272a6f949321de5413eb96136 (diff) | |
download | pandoc-ac8e72a95d3a4f9f6988bcf4b1f12cb14ef7ec24.tar.gz |
Merge pull request #4170 from oltolm/opendocument
improve formatting of formulas in OpenDocument
Diffstat (limited to 'src/Text/Pandoc/Writers/ODT.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/ODT.hs | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs index 390d7c3ba..08b4206e3 100644 --- a/src/Text/Pandoc/Writers/ODT.hs +++ b/src/Text/Pandoc/Writers/ODT.hs @@ -56,7 +56,7 @@ import Text.Pandoc.XML import Text.TeXMath import Text.XML.Light -data ODTState = ODTState { stEntries :: [Entry] +newtype ODTState = ODTState { stEntries :: [Entry] } type O m = StateT ODTState m @@ -224,17 +224,39 @@ transformPicMath _ (Math t math) = do let dirname = "Formula-" ++ show (length entries) ++ "/" let fname = dirname ++ "content.xml" let entry = toEntry fname epochtime (fromStringLazy mathml) - modify $ \st -> st{ stEntries = entry : entries } + let fname' = dirname ++ "settings.xml" + let entry' = toEntry fname' epochtime $ documentSettings (t == InlineMath) + modify $ \st -> st{ stEntries = entry' : (entry : entries) } return $ RawInline (Format "opendocument") $ render Nothing $ - inTags False "draw:frame" [("text:anchor-type", - if t == DisplayMath - then "paragraph" - else "as-char") - ,("style:vertical-pos", "middle") - ,("style:vertical-rel", "text")] $ + inTags False "draw:frame" (if t == DisplayMath + then [("draw:style-name","fr2") + -- `draw:frame` does not support either + -- `style:vertical-pos` or `style:vertical-rel`, + -- therefore those attributes must go into the + -- `style:style` element + ,("text:anchor-type","paragraph")] + else [("draw:style-name","fr1") + ,("text:anchor-type","as-char")]) $ selfClosingTag "draw:object" [("xlink:href", dirname) , ("xlink:type", "simple") , ("xlink:show", "embed") , ("xlink:actuate", "onLoad")] transformPicMath _ x = return x + +documentSettings :: Bool -> B.ByteString +documentSettings isTextMode = fromStringLazy $ render Nothing + $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + $$ + (inTags True "office:document-settings" + [("xmlns:office","urn:oasis:names:tc:opendocument:xmlns:office:1.0") + ,("xmlns:xlink","http://www.w3.org/1999/xlink") + ,("xmlns:config","urn:oasis:names:tc:opendocument:xmlns:config:1.0") + ,("xmlns:ooo","http://openoffice.org/2004/office") + ,("office:version","1.2")] $ + inTagsSimple "office:settings" $ + inTags False "config:config-item-set" + [("config:name", "ooo:configuration-settings")] $ + inTags False "config:config-item" [("config:name", "IsTextMode") + ,("config:type", "boolean")] $ + text $ if isTextMode then "true" else "false") |