aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolay Yakimov <root@livid.pp.ru>2015-02-24 02:31:14 +0300
committerNikolay Yakimov <root@livid.pp.ru>2015-02-24 02:31:14 +0300
commit908a47e4b9c9ad5cc1fd2f5e551ef0fd98d93178 (patch)
treecb229eb50425c3366fde29341dff6ee9f2ea0b4d
parent47c70b91313dd5e907efd34d5a26d908b625c476 (diff)
downloadpandoc-908a47e4b9c9ad5cc1fd2f5e551ef0fd98d93178.tar.gz
Treat some ambiguous styles as custom for now
* Author * Abstract * Compact * ImageCaption * TableCaption * DefinitionTerm * Definition * FirstParagraph
-rw-r--r--docxstyles.txt44
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs21
2 files changed, 54 insertions, 11 deletions
diff --git a/docxstyles.txt b/docxstyles.txt
new file mode 100644
index 000000000..6bc405d15
--- /dev/null
+++ b/docxstyles.txt
@@ -0,0 +1,44 @@
+| Name | Id | custom | word | type | alt |
+|:-----------------------|:---------------------|:------:|:----:|:----:|:---------------------------------|
+| Title | Title | | + | p | |
+| Subtitle | Subtitle | | + | p | |
+| Author | Author | ? | | p | ? |
+| Date | Date | | + | p | |
+| Abstract | Abstract | ? | | p | ? |
+| Bibliography | Bibliography | | + | p | |
+| Heading 1 | Heading1 | | + | p | |
+| Heading 2 | Heading2 | | + | p | |
+| Heading 3 | Heading3 | | + | p | |
+| Heading 4 | Heading4 | | + | p | |
+| Heading 5 | Heading5 | | + | p | |
+| Compact | Compact | ? | | p | ? |
+| Image Caption | ImageCaption | | | p | caption |
+| First Paragraph | FirstParagraph | | ??? | p | |
+| Body Text | BodyText | | + | p | |
+| Block Quote | BlockQuote | | | p | Intense Quote, Block Text, Quote |
+| Source Code | SourceCode | + | | p | |
+| Table Caption | TableCaption | | | p | caption |
+| Definition Term | DefinitionTerm | ? | | p | ? |
+| Definition | Definition | ? | | p | ? |
+| Verbatim Char | VerbatimChar | + | | c | |
+| Footnote Ref | FootnoteRef | + | | c | footnote reference |
+| Footnote Text | FootnoteText | | + | p | |
+| Link | Link | + | | c | Hyperlink |
+| Normal | Normal | | d | p | |
+| Default Paragraph Font | DefaultParagraphFont | | d | c | |
+| Normal Table | TableNormal | | d | t | |
+| Body Text Char | BodyTextChar | + | | c | |
+
+
+| Name | ambiguous | type | can be replaced by |
+|:----------------|:---------:|:----:|:---------------------------------|
+| Author | yes | p | ? |
+| Abstract | yes | p | ? |
+| Compact | yes | p | ? |
+| Image Caption | yes | p | caption |
+| Block Quote | yes | p | Intense Quote, Block Text, Quote |
+| Table Caption | yes | p | caption |
+| Definition Term | yes | p | ? |
+| Definition | yes | p | ? |
+| Link | no | c | Hyperlink |
+| Footnote Ref | no | c | footnote reference |
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index f217dd9bc..9984c243f 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -619,12 +619,12 @@ writeOpenXML opts (Pandoc meta blocks) = do
_ -> []
title <- withParaPropM (pStyleM "Title") $ blocksToOpenXML opts [Para tit | not (null tit)]
subtitle <- withParaPropM (pStyleM "Subtitle") $ blocksToOpenXML opts [Para subtitle' | not (null subtitle')]
- authors <- withParaPropM (pStyleM "Author") $ blocksToOpenXML opts $
+ authors <- withParaProp (pCustomStyle "Author") $ blocksToOpenXML opts $
map Para auths
date <- withParaPropM (pStyleM "Date") $ blocksToOpenXML opts [Para dat | not (null dat)]
abstract <- if null abstract'
then return []
- else withParaPropM (pStyleM "Abstract") $ blocksToOpenXML opts abstract'
+ else withParaProp (pCustomStyle "Abstract") $ blocksToOpenXML opts abstract'
let convertSpace (Str x : Space : Str y : xs) = Str (x ++ " " ++ y) : xs
convertSpace (Str x : Str y : xs) = Str (x ++ y) : xs
convertSpace xs = xs
@@ -693,14 +693,14 @@ blockToOpenXML opts (Header lev (ident,_,_) lst) = do
,("w:name",bookmarkName)] ()
let bookmarkEnd = mknode "w:bookmarkEnd" [("w:id", id')] ()
return [mknode "w:p" [] (paraProps ++ [bookmarkStart, bookmarkEnd] ++ contents)]
-blockToOpenXML opts (Plain lst) = withParaPropM (pStyleM "Compact")
+blockToOpenXML opts (Plain lst) = withParaProp (pCustomStyle "Compact")
$ blockToOpenXML opts (Para lst)
-- title beginning with fig: indicates that the image is a figure
blockToOpenXML opts (Para [Image alt (src,'f':'i':'g':':':tit)]) = do
setFirstPara
paraProps <- getParaProps False
contents <- inlinesToOpenXML opts [Image alt (src,tit)]
- captionNode <- withParaPropM (pStyleM "Image Caption")
+ captionNode <- withParaProp (pCustomStyle "ImageCaption")
$ blockToOpenXML opts (Para alt)
return $ mknode "w:p" [] (paraProps ++ contents) : captionNode
-- fixDisplayMath sometimes produces a Para [] as artifact
@@ -712,8 +712,8 @@ blockToOpenXML opts (Para lst) = do
_ -> False
pSM <- gets stParaStyles
let paraProps' = case paraProps of
- [] | isFirstPara -> [mknode "w:pPr" [] [(pStyle "First Paragraph" pSM)]]
- [] -> [mknode "w:pPr" [] [(pStyle "Body Text" pSM)]]
+ [] | isFirstPara -> [mknode "w:pPr" [] [pCustomStyle "FirstParagraph"]]
+ [] -> [mknode "w:pPr" [] [pStyle "Body Text" pSM]]
ps -> ps
modify $ \s -> s { stFirstPara = False }
contents <- inlinesToOpenXML opts lst
@@ -741,7 +741,7 @@ blockToOpenXML opts (Table caption aligns widths headers rows) = do
let captionStr = stringify caption
caption' <- if null caption
then return []
- else withParaPropM (pStyleM "Table Caption")
+ else withParaProp (pCustomStyle "TableCaption")
$ blockToOpenXML opts (Para caption)
let alignmentFor al = mknode "w:jc" [("w:val",alignmentToString al)] ()
let cellToOpenXML (al, cell) = withParaProp (alignmentFor al)
@@ -752,8 +752,7 @@ blockToOpenXML opts (Table caption aligns widths headers rows) = do
[ mknode "w:tcBorders" []
$ mknode "w:bottom" [("w:val","single")] ()
, mknode "w:vAlign" [("w:val","bottom")] () ]
- let emptyCell = [mknode "w:p" [] [mknode "w:pPr" []
- [mknode "w:pStyle" [("w:val","Compact")] ()]]]
+ let emptyCell = [mknode "w:p" [] [pCustomStyle "Compact"]]
let mkcell border contents = mknode "w:tc" []
$ [ borderProps | border ] ++
if null contents
@@ -801,9 +800,9 @@ blockToOpenXML opts (DefinitionList items) = do
definitionListItemToOpenXML :: WriterOptions -> ([Inline],[[Block]]) -> WS [Element]
definitionListItemToOpenXML opts (term,defs) = do
- term' <- withParaPropM (pStyleM "Definition Term")
+ term' <- withParaProp (pCustomStyle "DefinitionTerm")
$ blockToOpenXML opts (Para term)
- defs' <- withParaPropM (pStyleM "Definition")
+ defs' <- withParaProp (pCustomStyle "Definition")
$ concat `fmap` mapM (blocksToOpenXML opts) defs
return $ term' ++ defs'