git.iko.soy/typeable/pandoc
on master help sign in
Write out Docbook 5 namespace
commit987ec3a7523f4fe529575004d76d93680f127fa3 authorIvo Clarysse <ivo@bcdevices.com> dateFri 29 Apr 2016, 15:43 (10 years ago) parent271cb4d
3 files changed+10−7
src/Text/Pandoc.hs+1−1 src/Text/Pandoc/Options.hs+2−2 src/Text/Pandoc/Writers/Docbook.hs+7−4
src/Text/Pandoc.hs+1−1
@@ -292,7 +292,7 @@ writers = [
292292 , writerHtml5 = True })
293293 ,("docbook" , PureStringWriter writeDocbook)
294294 ,("docbook5" , PureStringWriter $ \o ->
295− writeDocbook o{ writerDocBook5 = True })
295+ writeDocbook o{ writerDocbook5 = True })
296296 ,("opml" , PureStringWriter writeOPML)
297297 ,("opendocument" , PureStringWriter writeOpenDocument)
298298 ,("latex" , PureStringWriter writeLaTeX)
src/Text/Pandoc/Options.hs+2−2
@@ -357,7 +357,7 @@ data WriterOptions = WriterOptions
357357 , writerSourceURL :: Maybe String -- ^ Absolute URL + directory of 1st source file
358358 , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory
359359 , writerCiteMethod :: CiteMethod -- ^ How to print cites
360− , writerDocBook5 :: Bool -- ^ Produce DocBook5
360+ , writerDocbook5 :: Bool -- ^ Produce DocBook5
361361 , writerHtml5 :: Bool -- ^ Produce HTML5
362362 , writerHtmlQTags :: Bool -- ^ Use @<q>@ tags for quotes in HTML
363363 , writerBeamer :: Bool -- ^ Produce beamer LaTeX slide show
@@ -404,7 +404,7 @@ instance Default WriterOptions where
404404 , writerSourceURL = Nothing
405405 , writerUserDataDir = Nothing
406406 , writerCiteMethod = Citeproc
407− , writerDocBook5 = False
407+ , writerDocbook5 = False
408408 , writerHtml5 = False
409409 , writerHtmlQTags = False
410410 , writerBeamer = False
src/Text/Pandoc/Writers/Docbook.hs+7−4
@@ -112,12 +112,15 @@ elementToDocbook opts lvl (Sec _ _num (id',_,_) title elements) =
112112 else elements
113113 tag = case lvl of
114114 n | n == 0 -> "chapter"
115− | n >= 1 && n <= 5 -> if writerDocBook5 opts
115+ | n >= 1 && n <= 5 -> if writerDocbook5 opts
116116 then "section"
117117 else "sect" ++ show n
118118 | otherwise -> "simplesect"
119− in inTags True tag [("id", writerIdentifierPrefix opts ++ id') |
120− not (null id')] $
119+ idAttr = [("id", writerIdentifierPrefix opts ++ id') | not (null id')]
120+ nsAttr = if writerDocbook5 opts && lvl == 0 then [("xmlns", "http://docbook.org/ns/docbook")]
121+ else []
122+ attribs = nsAttr ++ idAttr
123+ in inTags True tag attribs $
121124 inTagsSimple "title" (inlinesToDocbook opts title) $$
122125 vcat (map (elementToDocbook opts (lvl + 1)) elements')
123126
@@ -231,7 +234,7 @@ blockToDocbook opts (DefinitionList lst) =
231234 in inTags True "variablelist" attribs $ deflistItemsToDocbook opts lst
232235blockToDocbook opts (RawBlock f str)
233236 | f == "docbook" = text str -- raw XML block
234− | f == "html" = if writerDocBook5 opts
237+ | f == "html" = if writerDocbook5 opts
235238 then empty -- No html in Docbook5
236239 else text str -- allow html for backwards compatibility
237240 | otherwise = empty