diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-08-17 12:48:41 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-08-17 12:48:41 -0700 |
commit | c14088ea93ba3b978ce6aed7be16b0c4d5778513 (patch) | |
tree | 115d9c0ce9889e35e00024a446f1d1b42f6c8aff | |
parent | 58cbd20b1ffb77d4f67a81bfc4d1d953865b4732 (diff) | |
download | pandoc-c14088ea93ba3b978ce6aed7be16b0c4d5778513.tar.gz |
Docx writer: Fixed regression, bungled list numbering.
In pandoc 1.13, all lists come out as basic ordered lists.
This fixes that bad regression.
Closes #1544.
-rw-r--r-- | src/Text/Pandoc/Writers/Docx.hs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 38031b7dc..2ee7bd5a5 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -114,7 +114,13 @@ type WS a = StateT WriterState IO a mknode :: Node t => String -> [(String,String)] -> t -> Element mknode s attrs = - add_attrs (map (\(k,v) -> Attr (unqual k) v) attrs) . node (unqual s) + add_attrs (map (\(k,v) -> Attr (nodename k) v) attrs) . node (nodename s) + +nodename :: String -> QName +nodename s = QName{ qName = name, qURI = Nothing, qPrefix = prefix } + where (name, prefix) = case break (==':') s of + (xs,[]) -> (xs, Nothing) + (ys,(_:zs)) -> (zs, Just ys) toLazy :: B.ByteString -> BL.ByteString toLazy = BL.fromChunks . (:[]) @@ -297,7 +303,8 @@ writeDocx opts doc@(Pandoc meta _) = do -- otherwise things break: [Elem e | e <- allElts , qName (elName e) == "abstractNum" ] ++ - [Elem e | e <- allElts, qName (elName e) == "num" ] } + [Elem e | e <- allElts + , qName (elName e) == "num" ] } let docPropsPath = "docProps/core.xml" let docProps = mknode "cp:coreProperties" [("xmlns:cp","http://schemas.openxmlformats.org/package/2006/metadata/core-properties") @@ -470,7 +477,7 @@ mkLvl marker lvl = patternFor _ s = s ++ "." getNumId :: WS Int -getNumId = ((999 +) . length) `fmap` gets stLists +getNumId = (((baseListId - 1) +) . length) `fmap` gets stLists -- | Convert Pandoc document to two lists of -- OpenXML elements (the main document and footnotes). |