Write out Docbook 5 namespace

This commit is contained in:
Ivo Clarysse 2016-04-29 15:43:15 -07:00
parent 271cb4d845
commit 987ec3a752
3 changed files with 10 additions and 7 deletions

View file

@ -292,7 +292,7 @@ writers = [
, writerHtml5 = True }) , writerHtml5 = True })
,("docbook" , PureStringWriter writeDocbook) ,("docbook" , PureStringWriter writeDocbook)
,("docbook5" , PureStringWriter $ \o -> ,("docbook5" , PureStringWriter $ \o ->
writeDocbook o{ writerDocBook5 = True }) writeDocbook o{ writerDocbook5 = True })
,("opml" , PureStringWriter writeOPML) ,("opml" , PureStringWriter writeOPML)
,("opendocument" , PureStringWriter writeOpenDocument) ,("opendocument" , PureStringWriter writeOpenDocument)
,("latex" , PureStringWriter writeLaTeX) ,("latex" , PureStringWriter writeLaTeX)

View file

@ -357,7 +357,7 @@ data WriterOptions = WriterOptions
, writerSourceURL :: Maybe String -- ^ Absolute URL + directory of 1st source file , writerSourceURL :: Maybe String -- ^ Absolute URL + directory of 1st source file
, writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory
, writerCiteMethod :: CiteMethod -- ^ How to print cites , writerCiteMethod :: CiteMethod -- ^ How to print cites
, writerDocBook5 :: Bool -- ^ Produce DocBook5 , writerDocbook5 :: Bool -- ^ Produce DocBook5
, writerHtml5 :: Bool -- ^ Produce HTML5 , writerHtml5 :: Bool -- ^ Produce HTML5
, writerHtmlQTags :: Bool -- ^ Use @<q>@ tags for quotes in HTML , writerHtmlQTags :: Bool -- ^ Use @<q>@ tags for quotes in HTML
, writerBeamer :: Bool -- ^ Produce beamer LaTeX slide show , writerBeamer :: Bool -- ^ Produce beamer LaTeX slide show
@ -404,7 +404,7 @@ instance Default WriterOptions where
, writerSourceURL = Nothing , writerSourceURL = Nothing
, writerUserDataDir = Nothing , writerUserDataDir = Nothing
, writerCiteMethod = Citeproc , writerCiteMethod = Citeproc
, writerDocBook5 = False , writerDocbook5 = False
, writerHtml5 = False , writerHtml5 = False
, writerHtmlQTags = False , writerHtmlQTags = False
, writerBeamer = False , writerBeamer = False

View file

@ -112,12 +112,15 @@ elementToDocbook opts lvl (Sec _ _num (id',_,_) title elements) =
else elements else elements
tag = case lvl of tag = case lvl of
n | n == 0 -> "chapter" n | n == 0 -> "chapter"
| n >= 1 && n <= 5 -> if writerDocBook5 opts | n >= 1 && n <= 5 -> if writerDocbook5 opts
then "section" then "section"
else "sect" ++ show n else "sect" ++ show n
| otherwise -> "simplesect" | otherwise -> "simplesect"
in inTags True tag [("id", writerIdentifierPrefix opts ++ id') | idAttr = [("id", writerIdentifierPrefix opts ++ id') | not (null id')]
not (null id')] $ nsAttr = if writerDocbook5 opts && lvl == 0 then [("xmlns", "http://docbook.org/ns/docbook")]
else []
attribs = nsAttr ++ idAttr
in inTags True tag attribs $
inTagsSimple "title" (inlinesToDocbook opts title) $$ inTagsSimple "title" (inlinesToDocbook opts title) $$
vcat (map (elementToDocbook opts (lvl + 1)) elements') vcat (map (elementToDocbook opts (lvl + 1)) elements')
@ -231,7 +234,7 @@ blockToDocbook opts (DefinitionList lst) =
in inTags True "variablelist" attribs $ deflistItemsToDocbook opts lst in inTags True "variablelist" attribs $ deflistItemsToDocbook opts lst
blockToDocbook opts (RawBlock f str) blockToDocbook opts (RawBlock f str)
| f == "docbook" = text str -- raw XML block | f == "docbook" = text str -- raw XML block
| f == "html" = if writerDocBook5 opts | f == "html" = if writerDocbook5 opts
then empty -- No html in Docbook5 then empty -- No html in Docbook5
else text str -- allow html for backwards compatibility else text str -- allow html for backwards compatibility
| otherwise = empty | otherwise = empty