summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-01-24 15:01:22 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-01-24 15:01:39 +0100
commit6d751cb386cbfaf70df77f176f270f4dc830ae02 (patch)
treef1be5a7c6ce10dbd1535c5985575180e7fe2a7df
parent77e8682a7367ccfa08b43357eee5c13c752756f2 (diff)
OpenDocument writer: small refactoring.
Removed separate 'parent' param in paraStyle.
-rw-r--r--src/Text/Pandoc/Writers/OpenDocument.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
index 5107cb499..8f0e037c5 100644
--- a/src/Text/Pandoc/Writers/OpenDocument.hs
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -226,7 +226,7 @@ withParagraphStyle _ _ [] = return empty
inPreformattedTags :: String -> State WriterState Doc
inPreformattedTags s = do
- n <- paraStyle "Preformatted_20_Text" []
+ n <- paraStyle [("style:parent-style-name","Preformatted_20_Text")]
return . inParagraphTagsWithStyle ("P" ++ show n) . handleSpaces $ s
orderedListToOpenDocument :: WriterOptions -> Int -> [[Block]] -> State WriterState Doc
@@ -287,7 +287,8 @@ deflistItemToOpenDocument o (t,d) = do
inBlockQuote :: WriterOptions -> Int -> [Block] -> State WriterState Doc
inBlockQuote o i (b:bs)
| BlockQuote l <- b = do increaseIndent
- ni <- paraStyle "Quotations" []
+ ni <- paraStyle
+ [("style:parent-style-name","Quotations")]
go =<< inBlockQuote o ni (map plainToPara l)
| Para l <- b = do go =<< inParagraphTagsWithStyle ("P" ++ show i) <$> inlinesToOpenDocument o l
| otherwise = do go =<< blockToOpenDocument o b
@@ -333,7 +334,8 @@ blockToOpenDocument o bs
return r
preformatted s = (flush . vcat) <$> mapM (inPreformattedTags . escapeStringForXML) (lines s)
mkBlockQuote b = do increaseIndent
- i <- paraStyle "Quotations" []
+ i <- paraStyle
+ [("style:parent-style-name","Quotations")]
inBlockQuote o i (map plainToPara b)
orderedList a b = do (ln,pn) <- newOrderedListStyle (isTightList b) a
inTags True "text:list" [ ("text:style-name", "L" ++ show ln)]
@@ -536,15 +538,14 @@ tableStyle num wcs =
columnStyles = map colStyle wcs
in table $$ vcat columnStyles $$ cellStyle
-paraStyle :: String -> [(String,String)] -> State WriterState Int
-paraStyle parent attrs = do
+paraStyle :: [(String,String)] -> State WriterState Int
+paraStyle attrs = do
pn <- (+) 1 . length <$> gets stParaStyles
i <- (*) 0.5 . fromIntegral <$> gets stIndentPara :: State WriterState Double
b <- gets stInDefinition
t <- gets stTight
let styleAttr = [ ("style:name" , "P" ++ show pn)
- , ("style:family" , "paragraph" )
- , ("style:parent-style-name", parent )]
+ , ("style:family" , "paragraph" )]
indentVal = flip (++) "in" . show $ if b then (max 0.5 i) else i
tight = if t then [ ("fo:margin-top" , "0in" )
, ("fo:margin-bottom" , "0in" )]
@@ -562,7 +563,9 @@ paraStyle parent attrs = do
return pn
paraListStyle :: Int -> State WriterState Int
-paraListStyle l = paraStyle "Text_20_body" [("style:list-style-name", "L" ++ show l )]
+paraListStyle l = paraStyle
+ [("style:parent-style-name","Text_20_body")
+ ,("style:list-style-name", "L" ++ show l )]
paraTableStyles :: String -> Int -> [Alignment] -> [(String, Doc)]
paraTableStyles _ _ [] = []