git.iko.soy/typeable/pandoc
on master help sign in
OpenDocument writer: Fixed indentation for verbatim blocks inside defn lists.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1284 788f1e2b-df1e-0410-8736-df70ead52e1b

commit94e2d373bc9a28f1ee86273f4e51d08b7bd4cebd authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateMon 9 Jun 2008, 21:13 (18 years ago) parentdd454eb
1 file changed+16−6
Text/Pandoc/Writers/OpenDocument.hs+16−6
Text/Pandoc/Writers/OpenDocument.hs+16−6
@@ -55,6 +55,7 @@ data WriterState =
5555 , stParaStyles :: [Doc]
5656 , stListStyles :: [(Int, [Doc])]
5757 , indentPara :: Int
58+ , inDefinition :: Bool
5859 }
5960
6061defaultWriterState :: WriterState
@@ -64,6 +65,7 @@ defaultWriterState =
6465 , stParaStyles = []
6566 , stListStyles = []
6667 , indentPara = 0
68+ , inDefinition = False
6769 }
6870
6971addTableStyle :: Doc -> State WriterState ()
@@ -81,6 +83,9 @@ increaseIndent = modify $ \s -> s { indentPara = 1 + indentPara s }
8183resetIndent :: State WriterState ()
8284resetIndent = modify $ \s -> s { indentPara = 0 }
8385
86+setInDefinitionList :: Bool -> State WriterState ()
87+setInDefinitionList b = modify $ \s -> s { inDefinition = b }
88+
8489inParagraphTags :: Doc -> Doc
8590inParagraphTags = inTags False "text:p" [("text:style-name", "Text_20_body")]
8691
@@ -231,7 +236,10 @@ blockToOpenDocument o bs
231236 | HorizontalRule <- bs = return empty
232237 | otherwise = return empty
233238 where
234− defList b = vcat <$> mapM (deflistItemToOpenDocument o) b
239+ defList b = do setInDefinitionList True
240+ r <- vcat <$> mapM (deflistItemToOpenDocument o) b
241+ setInDefinitionList False
242+ return r
235243 preformatted s = vcat <$> mapM (inPreformattedTags . escapeStringForXML) (lines s)
236244 mkBlockQuote b = do increaseIndent
237245 i <- paraStyle "Quotations" []
@@ -406,16 +414,18 @@ paraStyle :: String -> [(String,String)] -> State WriterState Int
406414paraStyle parent attrs = do
407415 pn <- (+) 1 . length <$> gets stParaStyles
408416 i <- (*) 0.5 . fromIntegral <$> gets indentPara :: State WriterState Double
417+ b <- gets inDefinition
409418 let styleAttr = [ ("style:name" , "P" ++ show pn)
410419 , ("style:family" , "paragraph" )
411420 , ("style:parent-style-name", parent )]
412− indent = if i == 0
421+ indentVal = if b then "0.5in" else show i ++ "in"
422+ indent = if i == 0 && not b
413423 then empty
414424 else selfClosingTag "style:paragraph-properties"
415− [ ("fo:margin-left" , show i ++ "in")
416− , ("fo:margin-right" , "0in" )
417− , ("fo:text-indent" , "0in" )
418− , ("style:auto-text-indent" , "false" )]
425+ [ ("fo:margin-left" , indentVal)
426+ , ("fo:margin-right" , "0in" )
427+ , ("fo:text-indent" , "0in" )
428+ , ("style:auto-text-indent" , "false" )]
419429 addParaStyle $ inTags True "style:style" (styleAttr ++ attrs) indent
420430 return pn
421431