@@ -441,7 +441,7 @@ writeDocx opts doc = do
441 Nothing -> mknode "w:sectPr" [] ()
441 Nothing -> mknode "w:sectPr" [] ()
443 -- let sectpr = fromMaybe (mknode "w:sectPr" [] ()) mbsectpr'
443 -- let sectpr = fromMaybe (mknode "w:sectPr" [] ()) mbsectpr'
444− let contents' = contents ++ [sectpr]
444+ let contents' = contents ++ [Elem sectpr]
445 let docContents = mknode "w:document" stdAttributes
445 let docContents = mknode "w:document" stdAttributes
446 $ mknode "w:body" [] contents'
446 $ mknode "w:body" [] contents'
@@ -538,7 +538,8 @@ writeDocx opts doc = do
539 -- docProps/custom.xml
539 -- docProps/custom.xml
540 let customProperties :: [(String, String)]
540 let customProperties :: [(String, String)]
541− customProperties = [(T.unpack k, T.unpack $ lookupMetaString k meta) | k <- M.keys (unMeta meta)
541+ customProperties = [ (T.unpack k, T.unpack $ lookupMetaString k meta)
542+ | k <- M.keys (unMeta meta)
542 , k `notElem` (["title", "author", "keywords"]
543 , k `notElem` (["title", "author", "keywords"]
543 ++ extraCoreProps)]
544 ++ extraCoreProps)]
544 let mkCustomProp (k, v) pid = mknode "property"
545 let mkCustomProp (k, v) pid = mknode "property"
@@ -788,7 +789,7 @@ makeTOC opts = do
788 mknode "w:docPartUnique" [] ()]
789 mknode "w:docPartUnique" [] ()]
789 -- w:docPartObj
790 -- w:docPartObj
790 ), -- w:sdtPr
791 ), -- w:sdtPr
791− mknode "w:sdtContent" [] (title++[
792+ mknode "w:sdtContent" [] (title ++ [ Elem $
792 mknode "w:p" [] (
793 mknode "w:p" [] (
793 mknode "w:r" [] [
794 mknode "w:r" [] [
794 mknode "w:fldChar" [("w:fldCharType","begin"),("w:dirty","true")] (),
795 mknode "w:fldChar" [("w:fldCharType","begin"),("w:dirty","true")] (),
@@ -802,7 +803,9 @@ makeTOC opts = do
803-- | Convert Pandoc document to two lists of
804-- | Convert Pandoc document to two lists of
804-- OpenXML elements (the main document and footnotes).
805-- OpenXML elements (the main document and footnotes).
805−writeOpenXML :: (PandocMonad m) => WriterOptions -> Pandoc -> WS m ([Element], [Element],[Element])
806+writeOpenXML :: (PandocMonad m)
807+ => WriterOptions -> Pandoc
808+ -> WS m ([Content], [Element], [Element])
806writeOpenXML opts (Pandoc meta blocks) = do
809writeOpenXML opts (Pandoc meta blocks) = do
807 let tit = docTitle meta
810 let tit = docTitle meta
808 let auths = docAuthors meta
811 let auths = docAuthors meta
@@ -830,6 +833,7 @@ writeOpenXML opts (Pandoc meta blocks) = do
831 mknode "w:comment" [('w':':':T.unpack k,T.unpack v) | (k,v) <- kvs]
834 mknode "w:comment" [('w':':':T.unpack k,T.unpack v) | (k,v) <- kvs]
832 [ mknode "w:p" [] $
835 [ mknode "w:p" [] $
833 [ mknode "w:pPr" []
837 [ mknode "w:pPr" []
834 [ mknode "w:pStyle" [("w:val", "CommentText")] () ]
838 [ mknode "w:pStyle" [("w:val", "CommentText")] () ]
835 , mknode "w:r" []
839 , mknode "w:r" []
@@ -844,11 +848,11 @@ writeOpenXML opts (Pandoc meta blocks) = do
844 toc <- if includeTOC
848 toc <- if includeTOC
845 then makeTOC opts
849 then makeTOC opts
846 else return []
850 else return []
847− let meta' = title ++ subtitle ++ authors ++ date ++ abstract ++ toc
851+ let meta' = title ++ subtitle ++ authors ++ date ++ abstract ++ map Elem toc
848 return (meta' ++ doc', notes', comments')
852 return (meta' ++ doc', notes', comments')
850-- | Convert a list of Pandoc blocks to OpenXML.
854-- | Convert a list of Pandoc blocks to OpenXML.
851−blocksToOpenXML :: (PandocMonad m) => WriterOptions -> [Block] -> WS m [Element]
855+blocksToOpenXML :: (PandocMonad m) => WriterOptions -> [Block] -> WS m [Content]
852blocksToOpenXML opts = fmap concat . mapM (blockToOpenXML opts) . separateTables
856blocksToOpenXML opts = fmap concat . mapM (blockToOpenXML opts) . separateTables
854-- Word combines adjacent tables unless you put an empty paragraph between
858-- Word combines adjacent tables unless you put an empty paragraph between
@@ -884,10 +888,10 @@ dynamicStyleKey :: T.Text
884dynamicStyleKey = "custom-style"
888dynamicStyleKey = "custom-style"
886-- | Convert a Pandoc block element to OpenXML.
890-- | Convert a Pandoc block element to OpenXML.
887−blockToOpenXML :: (PandocMonad m) => WriterOptions -> Block -> WS m [Element]
891+blockToOpenXML :: (PandocMonad m) => WriterOptions -> Block -> WS m [Content]
888blockToOpenXML opts blk = withDirection $ blockToOpenXML' opts blk
892blockToOpenXML opts blk = withDirection $ blockToOpenXML' opts blk
890−blockToOpenXML' :: (PandocMonad m) => WriterOptions -> Block -> WS m [Element]
894+blockToOpenXML' :: (PandocMonad m) => WriterOptions -> Block -> WS m [Content]
891blockToOpenXML' _ Null = return []
895blockToOpenXML' _ Null = return []
892blockToOpenXML' opts (Div (ident,_classes,kvs) bs) = do
896blockToOpenXML' opts (Div (ident,_classes,kvs) bs) = do
893 stylemod <- case lookup dynamicStyleKey kvs of
897 stylemod <- case lookup dynamicStyleKey kvs of
@@ -921,18 +925,18 @@ blockToOpenXML' opts (Header lev (ident,_,kvs) lst) = do
921 Just n -> do
925 Just n -> do
922 num <- withTextPropM (rStyleM "SectionNumber")
926 num <- withTextPropM (rStyleM "SectionNumber")
923 (inlineToOpenXML opts (Str n))
927 (inlineToOpenXML opts (Str n))
924− return $ num ++ [mknode "w:r" [] [mknode "w:tab" [] ()]]
928+ return $ num ++ [Elem $ mknode "w:r" [] [mknode "w:tab" [] ()]]
925 Nothing -> return []
929 Nothing -> return []
926 else return []
930 else return []
927 contents <- (number ++) <$> inlinesToOpenXML opts lst
931 contents <- (number ++) <$> inlinesToOpenXML opts lst
928 if T.null ident
932 if T.null ident
929− then return [mknode "w:p" [] (paraProps ++ contents)]
933+ then return [Elem $ mknode "w:p" [] (map Elem paraProps ++ contents)]
931 let bookmarkName = ident
935 let bookmarkName = ident
932 modify $ \s -> s{ stSectionIds = Set.insert bookmarkName
936 modify $ \s -> s{ stSectionIds = Set.insert bookmarkName
933 $ stSectionIds s }
937 $ stSectionIds s }
934 bookmarkedContents <- wrapBookmark bookmarkName contents
938 bookmarkedContents <- wrapBookmark bookmarkName contents
935− return [mknode "w:p" [] (paraProps ++ bookmarkedContents)]
939+ return [Elem $ mknode "w:p" [] (map Elem paraProps ++ bookmarkedContents)]
936blockToOpenXML' opts (Plain lst) = do
940blockToOpenXML' opts (Plain lst) = do
937 isInTable <- gets stInTable
941 isInTable <- gets stInTable
938 isInList <- gets stInList
942 isInList <- gets stInList
@@ -952,7 +956,9 @@ blockToOpenXML' opts (Para [Image attr alt (src,T.stripPrefix "fig:" -> Just tit
952 contents <- inlinesToOpenXML opts [Image attr alt (src,tit)]
956 contents <- inlinesToOpenXML opts [Image attr alt (src,tit)]
953 captionNode <- withParaPropM (pStyleM "Image Caption")
957 captionNode <- withParaPropM (pStyleM "Image Caption")
954 $ blockToOpenXML opts (Para alt)
958 $ blockToOpenXML opts (Para alt)
955− return $ mknode "w:p" [] (paraProps ++ contents) : captionNode
960+ Elem (mknode "w:p" [] (map Elem paraProps ++ contents))
956blockToOpenXML' opts (Para lst)
962blockToOpenXML' opts (Para lst)
957 | null lst && not (isEnabled Ext_empty_paragraphs opts) = return []
963 | null lst && not (isEnabled Ext_empty_paragraphs opts) = return []
958 | otherwise = do
964 | otherwise = do
@@ -969,10 +975,10 @@ blockToOpenXML' opts (Para lst)
970 modify $ \s -> s { stFirstPara = False }
976 modify $ \s -> s { stFirstPara = False }
971 contents <- inlinesToOpenXML opts lst
977 contents <- inlinesToOpenXML opts lst
972− return [mknode "w:p" [] (paraProps' ++ contents)]
978+ return [Elem $ mknode "w:p" [] (map Elem paraProps' ++ contents)]
973blockToOpenXML' opts (LineBlock lns) = blockToOpenXML opts $ linesToPara lns
979blockToOpenXML' opts (LineBlock lns) = blockToOpenXML opts $ linesToPara lns
974blockToOpenXML' _ b@(RawBlock format str)
980blockToOpenXML' _ b@(RawBlock format str)
975− | format == Format "openxml" = return [ x | Elem x <- parseXML str ]
981+ | format == Format "openxml" = return (parseXML str)
976 | otherwise = do
982 | otherwise = do
977 report $ BlockNotRendered b
983 report $ BlockNotRendered b
978 return []
984 return []
@@ -987,7 +993,7 @@ blockToOpenXML' opts (CodeBlock attrs@(ident, _, _) str) = do
987 wrapBookmark ident p
993 wrapBookmark ident p
988blockToOpenXML' _ HorizontalRule = do
994blockToOpenXML' _ HorizontalRule = do
989 setFirstPara
995 setFirstPara
990− return [
996+ return [ Elem $
991 mknode "w:p" [] $ mknode "w:r" [] $ mknode "w:pict" []
997 mknode "w:p" [] $ mknode "w:r" [] $ mknode "w:pict" []
992 $ mknode "v:rect" [("style","width:0;height:1.5pt"),
998 $ mknode "v:rect" [("style","width:0;height:1.5pt"),
993 ("o:hralign","center"),
999 ("o:hralign","center"),
@@ -1006,26 +1012,28 @@ blockToOpenXML' opts (Table _ blkCapt specs thead tbody tfoot) = do
1006 -- Not in the spec but in Word 2007, 2010. See #4953.
1012 -- Not in the spec but in Word 2007, 2010. See #4953.
1007 let cellToOpenXML (al, cell) = do
1013 let cellToOpenXML (al, cell) = do
1008 es <- withParaProp (alignmentFor al) $ blocksToOpenXML opts cell
1014 es <- withParaProp (alignmentFor al) $ blocksToOpenXML opts cell
1009− return $ if any (\e -> qName (elName e) == "p") es
1015+ return $ if any (\e -> qName (elName e) == "p") (onlyElems es)
1011− else es ++ [mknode "w:p" [] ()]
1017+ else es ++ [Elem $ mknode "w:p" [] ()]
1012 headers' <- mapM cellToOpenXML $ zip aligns headers
1018 headers' <- mapM cellToOpenXML $ zip aligns headers
1013 rows' <- mapM (mapM cellToOpenXML . zip aligns) rows
1019 rows' <- mapM (mapM cellToOpenXML . zip aligns) rows
1014− let borderProps = mknode "w:tcPr" []
1020+ let borderProps = Elem $ mknode "w:tcPr" []
1015 [ mknode "w:tcBorders" []
1021 [ mknode "w:tcBorders" []
1016 $ mknode "w:bottom" [("w:val","single")] ()
1022 $ mknode "w:bottom" [("w:val","single")] ()
1017 , mknode "w:vAlign" [("w:val","bottom")] () ]
1023 , mknode "w:vAlign" [("w:val","bottom")] () ]
1018 compactStyle <- pStyleM "Compact"
1024 compactStyle <- pStyleM "Compact"
1019− let emptyCell' = [mknode "w:p" [] [mknode "w:pPr" [] [compactStyle]]]
1025+ let emptyCell' = [Elem $ mknode "w:p" [] [mknode "w:pPr" [] [compactStyle]]]
1020 let mkcell border contents = mknode "w:tc" []
1026 let mkcell border contents = mknode "w:tc" []
1021 $ [ borderProps | border ] ++
1027 $ [ borderProps | border ] ++
1022 if null contents
1028 if null contents
1023 then emptyCell'
1029 then emptyCell'
1024 else contents
1030 else contents
1025− let mkrow border cells = mknode "w:tr" [] $
1031+ let mkrow border cells =
1026− [mknode "w:trPr" [] [
1033+ [ mknode "w:trPr" []
1027− mknode "w:cnfStyle" [("w:firstRow","1")] ()] | border]
1034+ [ mknode "w:cnfStyle" [("w:firstRow","1")] ()]
1028− ++ map (mkcell border) cells
1036+ ++ map (mkcell border) cells
1029 let textwidth = 7920 -- 5.5 in in twips, 1/20 pt
1037 let textwidth = 7920 -- 5.5 in in twips, 1/20 pt
1030 let fullrow = 5000 -- 100% specified in pct
1038 let fullrow = 5000 -- 100% specified in pct
1031 let rowwidth = fullrow * sum widths
1039 let rowwidth = fullrow * sum widths
@@ -1035,7 +1043,8 @@ blockToOpenXML' opts (Table _ blkCapt specs thead tbody tfoot) = do
1035 modify $ \s -> s { stInTable = False }
1043 modify $ \s -> s { stInTable = False }
1036 return $
1044 return $
1037 caption' ++
1045 caption' ++
1038− [mknode "w:tbl" []
1047+ mknode "w:tbl" []
1039 ( mknode "w:tblPr" []
1048 ( mknode "w:tblPr" []
1040 ( mknode "w:tblStyle" [("w:val","Table")] () :
1049 ( mknode "w:tblStyle" [("w:val","Table")] () :
1041 mknode "w:tblW" [("w:type", "pct"), ("w:w", show rowwidth)] () :
1050 mknode "w:tblW" [("w:type", "pct"), ("w:w", show rowwidth)] () :
@@ -1070,7 +1079,9 @@ blockToOpenXML' opts (DefinitionList items) = do
1070 setFirstPara
1079 setFirstPara
1071 return l
1080 return l
1073−definitionListItemToOpenXML :: (PandocMonad m) => WriterOptions -> ([Inline],[[Block]]) -> WS m [Element]
1082+definitionListItemToOpenXML :: (PandocMonad m)
1083+ => WriterOptions -> ([Inline],[[Block]])
1074definitionListItemToOpenXML opts (term,defs) = do
1085definitionListItemToOpenXML opts (term,defs) = do
1075 term' <- withParaPropM (pStyleM "Definition Term")
1086 term' <- withParaPropM (pStyleM "Definition Term")
1076 $ blockToOpenXML opts (Para term)
1087 $ blockToOpenXML opts (Para term)
@@ -1083,8 +1094,11 @@ addList marker = do
1083 lists <- gets stLists
1094 lists <- gets stLists
1084 modify $ \st -> st{ stLists = lists ++ [marker] }
1095 modify $ \st -> st{ stLists = lists ++ [marker] }
1086−listItemToOpenXML :: (PandocMonad m) => WriterOptions -> Int -> [Block] -> WS m [Element]
1097+listItemToOpenXML :: (PandocMonad m)
1087−listItemToOpenXML _ _ [] = return []
1101+listItemToOpenXML _ _ [] = return []
1088listItemToOpenXML opts numid (first:rest) = do
1102listItemToOpenXML opts numid (first:rest) = do
1089 oldInList <- gets stInList
1103 oldInList <- gets stInList
1090 modify $ \st -> st{ stInList = True }
1104 modify $ \st -> st{ stInList = True }
@@ -1111,7 +1125,7 @@ alignmentToString alignment = case alignment of
1111 AlignDefault -> "left"
1125 AlignDefault -> "left"
1113-- | Convert a list of inline elements to OpenXML.
1127-- | Convert a list of inline elements to OpenXML.
1114−inlinesToOpenXML :: (PandocMonad m) => WriterOptions -> [Inline] -> WS m [Element]
1128+inlinesToOpenXML :: PandocMonad m => WriterOptions -> [Inline] -> WS m [Content]
1115inlinesToOpenXML opts lst = concat `fmap` mapM (inlineToOpenXML opts) lst
1129inlinesToOpenXML opts lst = concat `fmap` mapM (inlineToOpenXML opts) lst
1117withNumId :: (PandocMonad m) => Int -> WS m a -> WS m a
1131withNumId :: (PandocMonad m) => Int -> WS m a -> WS m a
@@ -1186,12 +1200,12 @@ setFirstPara :: PandocMonad m => WS m ()
1186setFirstPara = modify $ \s -> s { stFirstPara = True }
1200setFirstPara = modify $ \s -> s { stFirstPara = True }
1188-- | Convert an inline element to OpenXML.
1202-- | Convert an inline element to OpenXML.
1189−inlineToOpenXML :: PandocMonad m => WriterOptions -> Inline -> WS m [Element]
1203+inlineToOpenXML :: PandocMonad m => WriterOptions -> Inline -> WS m [Content]
1190inlineToOpenXML opts il = withDirection $ inlineToOpenXML' opts il
1204inlineToOpenXML opts il = withDirection $ inlineToOpenXML' opts il
1192−inlineToOpenXML' :: PandocMonad m => WriterOptions -> Inline -> WS m [Element]
1206+inlineToOpenXML' :: PandocMonad m => WriterOptions -> Inline -> WS m [Content]
1193inlineToOpenXML' _ (Str str) =
1207inlineToOpenXML' _ (Str str) =
1194− formattedString str
1208+ map Elem <$> formattedString str
1195inlineToOpenXML' opts Space = inlineToOpenXML opts (Str " ")
1209inlineToOpenXML' opts Space = inlineToOpenXML opts (Str " ")
1196inlineToOpenXML' opts SoftBreak = inlineToOpenXML opts (Str " ")
1210inlineToOpenXML' opts SoftBreak = inlineToOpenXML opts (Str " ")
1197inlineToOpenXML' opts (Span ("",["csl-block"],[]) ils) =
1211inlineToOpenXML' opts (Span ("",["csl-block"],[]) ils) =
@@ -1199,10 +1213,11 @@ inlineToOpenXML' opts (Span ("",["csl-block"],[]) ils) =
1199inlineToOpenXML' opts (Span ("",["csl-left-margin"],[]) ils) =
1213inlineToOpenXML' opts (Span ("",["csl-left-margin"],[]) ils) =
1200 inlinesToOpenXML opts ils
1214 inlinesToOpenXML opts ils
1201inlineToOpenXML' opts (Span ("",["csl-right-inline"],[]) ils) =
1215inlineToOpenXML' opts (Span ("",["csl-right-inline"],[]) ils) =
1202− ([mknode "w:r" []
1217+ mknode "w:r" []
1203− (mknode "w:t"
1218+ (mknode "w:t"
1204− [("xml:space","preserve")]
1219+ [("xml:space","preserve")]
1205− ("\t" :: String))] ++)
1220+ ("\t" :: String))] ++)
1206 <$> inlinesToOpenXML opts ils
1221 <$> inlinesToOpenXML opts ils
1207inlineToOpenXML' opts (Span ("",["csl-indent"],[]) ils) =
1222inlineToOpenXML' opts (Span ("",["csl-indent"],[]) ils) =
1208 inlinesToOpenXML opts ils
1223 inlinesToOpenXML opts ils
@@ -1212,18 +1227,18 @@ inlineToOpenXML' _ (Span (ident,["comment-start"],kvs) ils) = do
1212 let ident' = fromMaybe ident (lookup "id" kvs)
1227 let ident' = fromMaybe ident (lookup "id" kvs)
1213 kvs' = filter (("id" /=) . fst) kvs
1228 kvs' = filter (("id" /=) . fst) kvs
1214 modify $ \st -> st{ stComments = (("id",ident'):kvs', ils) : stComments st }
1229 modify $ \st -> st{ stComments = (("id",ident'):kvs', ils) : stComments st }
1215− return [ mknode "w:commentRangeStart" [("w:id", T.unpack ident')] () ]
1230+ return [ Elem $ mknode "w:commentRangeStart" [("w:id", T.unpack ident')] () ]
1216inlineToOpenXML' _ (Span (ident,["comment-end"],kvs) _) =
1231inlineToOpenXML' _ (Span (ident,["comment-end"],kvs) _) =
1217 -- prefer the "id" in kvs, since that is the one produced by the docx
1232 -- prefer the "id" in kvs, since that is the one produced by the docx
1218 -- reader.
1233 -- reader.
1219 let ident' = fromMaybe ident (lookup "id" kvs)
1234 let ident' = fromMaybe ident (lookup "id" kvs)
1220− in
1235+ in return . map Elem $
1221− return [ mknode "w:commentRangeEnd" [("w:id", T.unpack ident')] ()
1236+ [ mknode "w:commentRangeEnd" [("w:id", T.unpack ident')] ()
1222− , mknode "w:r" []
1237+ , mknode "w:r" []
1223− [ mknode "w:rPr" []
1238+ [ mknode "w:rPr" []
1224− [ mknode "w:rStyle" [("w:val", "CommentReference")] () ]
1239+ [ mknode "w:rStyle" [("w:val", "CommentReference")] () ]
1225− , mknode "w:commentReference" [("w:id", T.unpack ident')] () ]
1240+ , mknode "w:commentReference" [("w:id", T.unpack ident')] () ]
1227inlineToOpenXML' opts (Span (ident,classes,kvs) ils) = do
1242inlineToOpenXML' opts (Span (ident,classes,kvs) ils) = do
1228 stylemod <- case lookup dynamicStyleKey kvs of
1243 stylemod <- case lookup dynamicStyleKey kvs of
1229 Just (fromString . T.unpack -> sty) -> do
1244 Just (fromString . T.unpack -> sty) -> do
@@ -1255,8 +1270,9 @@ inlineToOpenXML' opts (Span (ident,classes,kvs) ils) = do
1255 modify $ \s -> s{stInsId = insId + 1}
1270 modify $ \s -> s{stInsId = insId + 1}
1256 return $ \f -> do
1271 return $ \f -> do
1258− return [ mknode "w:ins"
1274+ mknode "w:ins"
1259− (("w:id", show insId) : changeAuthorDate) x]
1275+ (("w:id", show insId) : changeAuthorDate) x]
1260 else return id
1276 else return id
1261 delmod <- if "deletion" `elem` classes
1277 delmod <- if "deletion" `elem` classes
@@ -1265,8 +1281,8 @@ inlineToOpenXML' opts (Span (ident,classes,kvs) ils) = do
1265 modify $ \s -> s{stDelId = delId + 1}
1281 modify $ \s -> s{stDelId = delId + 1}
1266 return $ \f -> local (\env->env{envInDel=True}) $ do
1282 return $ \f -> local (\env->env{envInDel=True}) $ do
1268− return [mknode "w:del"
1284+ return [Elem $ mknode "w:del"
1269− (("w:id", show delId) : changeAuthorDate) x]
1285+ (("w:id", show delId) : changeAuthorDate) x]
1270 else return id
1286 else return id
1271 contents <- insmod $ delmod $ dirmod $ stylemod $ pmod
1287 contents <- insmod $ delmod $ dirmod $ stylemod $ pmod
1272 $ inlinesToOpenXML opts ils
1288 $ inlinesToOpenXML opts ils
@@ -1294,9 +1310,9 @@ inlineToOpenXML' opts (SmallCaps lst) =
1294inlineToOpenXML' opts (Strikeout lst) =
1310inlineToOpenXML' opts (Strikeout lst) =
1295 withTextProp (mknode "w:strike" [] ())
1311 withTextProp (mknode "w:strike" [] ())
1296 $ inlinesToOpenXML opts lst
1312 $ inlinesToOpenXML opts lst
1297−inlineToOpenXML' _ LineBreak = return [br]
1313+inlineToOpenXML' _ LineBreak = return [Elem br]
1298inlineToOpenXML' _ il@(RawInline f str)
1314inlineToOpenXML' _ il@(RawInline f str)
1299− | f == Format "openxml" = return [ x | Elem x <- parseXML str ]
1315+ | f == Format "openxml" = return (parseXML str)
1300 | otherwise = do
1316 | otherwise = do
1301 report $ InlineNotRendered il
1317 report $ InlineNotRendered il
1302 return []
1318 return []
@@ -1309,13 +1325,13 @@ inlineToOpenXML' opts (Math mathType str) = do
1309 when (mathType == DisplayMath) setFirstPara
1325 when (mathType == DisplayMath) setFirstPara
1310 res <- (lift . lift) (convertMath writeOMML mathType str)
1326 res <- (lift . lift) (convertMath writeOMML mathType str)
1311 case res of
1327 case res of
1312− Right r -> return [r]
1328+ Right r -> return [Elem r]
1313 Left il -> inlineToOpenXML' opts il
1329 Left il -> inlineToOpenXML' opts il
1314inlineToOpenXML' opts (Cite _ lst) = inlinesToOpenXML opts lst
1330inlineToOpenXML' opts (Cite _ lst) = inlinesToOpenXML opts lst
1315inlineToOpenXML' opts (Code attrs str) = do
1331inlineToOpenXML' opts (Code attrs str) = do
1316 let alltoktypes = [KeywordTok ..]
1332 let alltoktypes = [KeywordTok ..]
1317 tokTypesMap <- mapM (\tt -> (,) tt <$> rStyleM (fromString $ show tt)) alltoktypes
1333 tokTypesMap <- mapM (\tt -> (,) tt <$> rStyleM (fromString $ show tt)) alltoktypes
1318− let unhighlighted = intercalate [br] `fmap`
1334+ let unhighlighted = (map Elem . intercalate [br]) `fmap`
1319 mapM formattedString (T.lines str)
1335 mapM formattedString (T.lines str)
1320 formatOpenXML _fmtOpts = intercalate [br] . map (map toHlTok)
1336 formatOpenXML _fmtOpts = intercalate [br] . map (map toHlTok)
1321 toHlTok (toktype,tok) =
1337 toHlTok (toktype,tok) =
@@ -1328,7 +1344,7 @@ inlineToOpenXML' opts (Code attrs str) = do
1328 then unhighlighted
1344 then unhighlighted
1329 else case highlight (writerSyntaxMap opts)
1345 else case highlight (writerSyntaxMap opts)
1330 formatOpenXML attrs str of
1346 formatOpenXML attrs str of
1331− Right h -> return h
1347+ Right h -> return (map Elem h)
1332 Left msg -> do
1348 Left msg -> do
1333 unless (T.null msg) $ report $ CouldNotHighlight msg
1349 unless (T.null msg) $ report $ CouldNotHighlight msg
1334 unhighlighted
1350 unhighlighted
@@ -1351,14 +1367,14 @@ inlineToOpenXML' opts (Note bs) = do
1351 $ insertNoteRef bs)
1367 $ insertNoteRef bs)
1352 let newnote = mknode "w:footnote" [("w:id", notenum)] contents
1368 let newnote = mknode "w:footnote" [("w:id", notenum)] contents
1353 modify $ \s -> s{ stFootnotes = newnote : notes }
1369 modify $ \s -> s{ stFootnotes = newnote : notes }
1354− return [ mknode "w:r" []
1370+ return [ Elem $ mknode "w:r" []
1355 [ mknode "w:rPr" [] footnoteStyle
1371 [ mknode "w:rPr" [] footnoteStyle
1356 , mknode "w:footnoteReference" [("w:id", notenum)] () ] ]
1372 , mknode "w:footnoteReference" [("w:id", notenum)] () ] ]
1357-- internal link:
1373-- internal link:
1358inlineToOpenXML' opts (Link _ txt (T.uncons -> Just ('#', xs),_)) = do
1374inlineToOpenXML' opts (Link _ txt (T.uncons -> Just ('#', xs),_)) = do
1359 contents <- withTextPropM (rStyleM "Hyperlink") $ inlinesToOpenXML opts txt
1375 contents <- withTextPropM (rStyleM "Hyperlink") $ inlinesToOpenXML opts txt
1361− [ mknode "w:hyperlink" [("w:anchor", T.unpack $ toBookmarkName xs)] contents ]
1377+ [ Elem $ mknode "w:hyperlink" [("w:anchor", T.unpack $ toBookmarkName xs)] contents ]
1362-- external link:
1378-- external link:
1363inlineToOpenXML' opts (Link _ txt (src,_)) = do
1379inlineToOpenXML' opts (Link _ txt (src,_)) = do
1364 contents <- withTextPropM (rStyleM "Hyperlink") $ inlinesToOpenXML opts txt
1380 contents <- withTextPropM (rStyleM "Hyperlink") $ inlinesToOpenXML opts txt
@@ -1370,7 +1386,7 @@ inlineToOpenXML' opts (Link _ txt (src,_)) = do
1370 modify $ \st -> st{ stExternalLinks =
1386 modify $ \st -> st{ stExternalLinks =
1371 M.insert (T.unpack src) i extlinks }
1387 M.insert (T.unpack src) i extlinks }
1372 return i
1388 return i
1373− return [ mknode "w:hyperlink" [("r:id",id')] contents ]
1389+ return [ Elem $ mknode "w:hyperlink" [("r:id",id')] contents ]
1374inlineToOpenXML' opts (Image attr@(imgident, _, _) alt (src, title)) = do
1390inlineToOpenXML' opts (Image attr@(imgident, _, _) alt (src, title)) = do
1375 pageWidth <- asks envPrintWidth
1391 pageWidth <- asks envPrintWidth
1376 imgs <- gets stImages
1392 imgs <- gets stImages
@@ -1434,7 +1450,7 @@ inlineToOpenXML' opts (Image attr@(imgident, _, _) alt (src, title)) = do
1436 wrapBookmark imgident =<< case stImage of
1452 wrapBookmark imgident =<< case stImage of
1437− Just imgData -> return [generateImgElt imgData]
1453+ Just imgData -> return [Elem $ generateImgElt imgData]
1438 Nothing -> ( do --try
1454 Nothing -> ( do --try
1439 (img, mt) <- P.fetchItem src
1455 (img, mt) <- P.fetchItem src
1440 ident <- ("rId"++) `fmap` getUniqueId
1456 ident <- ("rId"++) `fmap` getUniqueId
@@ -1462,7 +1478,7 @@ inlineToOpenXML' opts (Image attr@(imgident, _, _) alt (src, title)) = do
1463 -- insert mime type to use in constructing [Content_Types].xml
1479 -- insert mime type to use in constructing [Content_Types].xml
1464 modify $ \st -> st { stImages = M.insert (T.unpack src) imgData $ stImages st }
1480 modify $ \st -> st { stImages = M.insert (T.unpack src) imgData $ stImages st }
1465− return [generateImgElt imgData]
1481+ return [Elem $ generateImgElt imgData]
1467 `catchError` ( \e -> do
1483 `catchError` ( \e -> do
1468 report $ CouldNotFetchResource src $ T.pack (show e)
1484 report $ CouldNotFetchResource src $ T.pack (show e)
@@ -1512,7 +1528,7 @@ withDirection x = do
1512 , envTextProperties = EnvProps textStyle textProps'
1528 , envTextProperties = EnvProps textStyle textProps'
1515−wrapBookmark :: (PandocMonad m) => T.Text -> [Element] -> WS m [Element]
1531+wrapBookmark :: (PandocMonad m) => T.Text -> [Content] -> WS m [Content]
1516wrapBookmark "" contents = return contents
1532wrapBookmark "" contents = return contents
1517wrapBookmark ident contents = do
1533wrapBookmark ident contents = do
1518 id' <- getUniqueId
1534 id' <- getUniqueId
@@ -1520,7 +1536,7 @@ wrapBookmark ident contents = do
1520 [("w:id", id')
1536 [("w:id", id')
1521 ,("w:name", T.unpack $ toBookmarkName ident)] ()
1537 ,("w:name", T.unpack $ toBookmarkName ident)] ()
1522 bookmarkEnd = mknode "w:bookmarkEnd" [("w:id", id')] ()
1538 bookmarkEnd = mknode "w:bookmarkEnd" [("w:id", id')] ()
1523− return $ bookmarkStart : contents ++ [bookmarkEnd]
1539+ return $ Elem bookmarkStart : contents ++ [Elem bookmarkEnd]
1525-- Word imposes a 40 character limit on bookmark names and requires
1541-- Word imposes a 40 character limit on bookmark names and requires
1526-- that they begin with a letter. So we just use a hash of the
1542-- that they begin with a letter. So we just use a hash of the