git.iko.soy/typeable/pandoc
on master help sign in
Treat some ambiguous styles as custom for now
908a47eNikolay Yakimov
docxstyles.txtnew file+44
@@ -0,0 +1,44 @@
1+| Name | Id | custom | word | type | alt |
2+|:-----------------------|:---------------------|:------:|:----:|:----:|:---------------------------------|
3+| Title | Title | | + | p | |
4+| Subtitle | Subtitle | | + | p | |
5+| Author | Author | ? | | p | ? |
6+| Date | Date | | + | p | |
7+| Abstract | Abstract | ? | | p | ? |
8+| Bibliography | Bibliography | | + | p | |
9+| Heading 1 | Heading1 | | + | p | |
10+| Heading 2 | Heading2 | | + | p | |
11+| Heading 3 | Heading3 | | + | p | |
12+| Heading 4 | Heading4 | | + | p | |
13+| Heading 5 | Heading5 | | + | p | |
14+| Compact | Compact | ? | | p | ? |
15+| Image Caption | ImageCaption | | | p | caption |
16+| First Paragraph | FirstParagraph | | ??? | p | |
17+| Body Text | BodyText | | + | p | |
18+| Block Quote | BlockQuote | | | p | Intense Quote, Block Text, Quote |
19+| Source Code | SourceCode | + | | p | |
20+| Table Caption | TableCaption | | | p | caption |
21+| Definition Term | DefinitionTerm | ? | | p | ? |
22+| Definition | Definition | ? | | p | ? |
23+| Verbatim Char | VerbatimChar | + | | c | |
24+| Footnote Ref | FootnoteRef | + | | c | footnote reference |
25+| Footnote Text | FootnoteText | | + | p | |
26+| Link | Link | + | | c | Hyperlink |
27+| Normal | Normal | | d | p | |
28+| Default Paragraph Font | DefaultParagraphFont | | d | c | |
29+| Normal Table | TableNormal | | d | t | |
30+| Body Text Char | BodyTextChar | + | | c | |
31+
32+
33+| Name | ambiguous | type | can be replaced by |
34+|:----------------|:---------:|:----:|:---------------------------------|
35+| Author | yes | p | ? |
36+| Abstract | yes | p | ? |
37+| Compact | yes | p | ? |
38+| Image Caption | yes | p | caption |
39+| Block Quote | yes | p | Intense Quote, Block Text, Quote |
40+| Table Caption | yes | p | caption |
41+| Definition Term | yes | p | ? |
42+| Definition | yes | p | ? |
43+| Link | no | c | Hyperlink |
44+| Footnote Ref | no | c | footnote reference |
src/Text/Pandoc/Writers/Docx.hs+10−11
@@ -619,12 +619,12 @@ writeOpenXML opts (Pandoc meta blocks) = do
619 _ -> []
619 _ -> []
620 title <- withParaPropM (pStyleM "Title") $ blocksToOpenXML opts [Para tit | not (null tit)]
620 title <- withParaPropM (pStyleM "Title") $ blocksToOpenXML opts [Para tit | not (null tit)]
621 subtitle <- withParaPropM (pStyleM "Subtitle") $ blocksToOpenXML opts [Para subtitle' | not (null subtitle')]
621 subtitle <- withParaPropM (pStyleM "Subtitle") $ blocksToOpenXML opts [Para subtitle' | not (null subtitle')]
622− authors <- withParaPropM (pStyleM "Author") $ blocksToOpenXML opts $
622+ authors <- withParaProp (pCustomStyle "Author") $ blocksToOpenXML opts $
623 map Para auths
623 map Para auths
624 date <- withParaPropM (pStyleM "Date") $ blocksToOpenXML opts [Para dat | not (null dat)]
624 date <- withParaPropM (pStyleM "Date") $ blocksToOpenXML opts [Para dat | not (null dat)]
625 abstract <- if null abstract'
625 abstract <- if null abstract'
626 then return []
626 then return []
627− else withParaPropM (pStyleM "Abstract") $ blocksToOpenXML opts abstract'
627+ else withParaProp (pCustomStyle "Abstract") $ blocksToOpenXML opts abstract'
628 let convertSpace (Str x : Space : Str y : xs) = Str (x ++ " " ++ y) : xs
628 let convertSpace (Str x : Space : Str y : xs) = Str (x ++ " " ++ y) : xs
629 convertSpace (Str x : Str y : xs) = Str (x ++ y) : xs
629 convertSpace (Str x : Str y : xs) = Str (x ++ y) : xs
630 convertSpace xs = xs
630 convertSpace xs = xs
@@ -693,14 +693,14 @@ blockToOpenXML opts (Header lev (ident,_,_) lst) = do
693 ,("w:name",bookmarkName)] ()
693 ,("w:name",bookmarkName)] ()
694 let bookmarkEnd = mknode "w:bookmarkEnd" [("w:id", id')] ()
694 let bookmarkEnd = mknode "w:bookmarkEnd" [("w:id", id')] ()
695 return [mknode "w:p" [] (paraProps ++ [bookmarkStart, bookmarkEnd] ++ contents)]
695 return [mknode "w:p" [] (paraProps ++ [bookmarkStart, bookmarkEnd] ++ contents)]
696−blockToOpenXML opts (Plain lst) = withParaPropM (pStyleM "Compact")
696+blockToOpenXML opts (Plain lst) = withParaProp (pCustomStyle "Compact")
697 $ blockToOpenXML opts (Para lst)
697 $ blockToOpenXML opts (Para lst)
698-- title beginning with fig: indicates that the image is a figure
698-- title beginning with fig: indicates that the image is a figure
699blockToOpenXML opts (Para [Image alt (src,'f':'i':'g':':':tit)]) = do
699blockToOpenXML opts (Para [Image alt (src,'f':'i':'g':':':tit)]) = do
700 setFirstPara
700 setFirstPara
701 paraProps <- getParaProps False
701 paraProps <- getParaProps False
702 contents <- inlinesToOpenXML opts [Image alt (src,tit)]
702 contents <- inlinesToOpenXML opts [Image alt (src,tit)]
703− captionNode <- withParaPropM (pStyleM "Image Caption")
703+ captionNode <- withParaProp (pCustomStyle "ImageCaption")
704 $ blockToOpenXML opts (Para alt)
704 $ blockToOpenXML opts (Para alt)
705 return $ mknode "w:p" [] (paraProps ++ contents) : captionNode
705 return $ mknode "w:p" [] (paraProps ++ contents) : captionNode
706-- fixDisplayMath sometimes produces a Para [] as artifact
706-- fixDisplayMath sometimes produces a Para [] as artifact
@@ -712,8 +712,8 @@ blockToOpenXML opts (Para lst) = do
712 _ -> False
712 _ -> False
713 pSM <- gets stParaStyles
713 pSM <- gets stParaStyles
714 let paraProps' = case paraProps of
714 let paraProps' = case paraProps of
715− [] | isFirstPara -> [mknode "w:pPr" [] [(pStyle "First Paragraph" pSM)]]
715+ [] | isFirstPara -> [mknode "w:pPr" [] [pCustomStyle "FirstParagraph"]]
716− [] -> [mknode "w:pPr" [] [(pStyle "Body Text" pSM)]]
716+ [] -> [mknode "w:pPr" [] [pStyle "Body Text" pSM]]
717 ps -> ps
717 ps -> ps
718 modify $ \s -> s { stFirstPara = False }
718 modify $ \s -> s { stFirstPara = False }
719 contents <- inlinesToOpenXML opts lst
719 contents <- inlinesToOpenXML opts lst
@@ -741,7 +741,7 @@ blockToOpenXML opts (Table caption aligns widths headers rows) = do
741 let captionStr = stringify caption
741 let captionStr = stringify caption
742 caption' <- if null caption
742 caption' <- if null caption
743 then return []
743 then return []
744− else withParaPropM (pStyleM "Table Caption")
744+ else withParaProp (pCustomStyle "TableCaption")
745 $ blockToOpenXML opts (Para caption)
745 $ blockToOpenXML opts (Para caption)
746 let alignmentFor al = mknode "w:jc" [("w:val",alignmentToString al)] ()
746 let alignmentFor al = mknode "w:jc" [("w:val",alignmentToString al)] ()
747 let cellToOpenXML (al, cell) = withParaProp (alignmentFor al)
747 let cellToOpenXML (al, cell) = withParaProp (alignmentFor al)
@@ -752,8 +752,7 @@ blockToOpenXML opts (Table caption aligns widths headers rows) = do
752 [ mknode "w:tcBorders" []
752 [ mknode "w:tcBorders" []
753 $ mknode "w:bottom" [("w:val","single")] ()
753 $ mknode "w:bottom" [("w:val","single")] ()
754 , mknode "w:vAlign" [("w:val","bottom")] () ]
754 , mknode "w:vAlign" [("w:val","bottom")] () ]
755− let emptyCell = [mknode "w:p" [] [mknode "w:pPr" []
755+ let emptyCell = [mknode "w:p" [] [pCustomStyle "Compact"]]
756− [mknode "w:pStyle" [("w:val","Compact")] ()]]]
757 let mkcell border contents = mknode "w:tc" []
756 let mkcell border contents = mknode "w:tc" []
758 $ [ borderProps | border ] ++
757 $ [ borderProps | border ] ++
759 if null contents
758 if null contents
@@ -801,9 +800,9 @@ blockToOpenXML opts (DefinitionList items) = do
801
800
802definitionListItemToOpenXML :: WriterOptions -> ([Inline],[[Block]]) -> WS [Element]
801definitionListItemToOpenXML :: WriterOptions -> ([Inline],[[Block]]) -> WS [Element]
803definitionListItemToOpenXML opts (term,defs) = do
802definitionListItemToOpenXML opts (term,defs) = do
804− term' <- withParaPropM (pStyleM "Definition Term")
803+ term' <- withParaProp (pCustomStyle "DefinitionTerm")
805 $ blockToOpenXML opts (Para term)
804 $ blockToOpenXML opts (Para term)
806− defs' <- withParaPropM (pStyleM "Definition")
805+ defs' <- withParaProp (pCustomStyle "Definition")
807 $ concat `fmap` mapM (blocksToOpenXML opts) defs
806 $ concat `fmap` mapM (blocksToOpenXML opts) defs
808 return $ term' ++ defs'
807 return $ term' ++ defs'
809
808