@@ -32,7 +32,7 @@ module Text.Pandoc.Writers.Docbook (
33import Text.Pandoc.Definition
33import Text.Pandoc.Definition
34import Text.Pandoc.Shared
34import Text.Pandoc.Shared
35−import Text.Pandoc.Entities ( encodeEntities )
35+import Text.Pandoc.Entities ( escapeSGMLString )
36import Data.Char ( toLower, ord )
36import Data.Char ( toLower, ord )
37import Data.List ( isPrefixOf, partition, drop )
37import Data.List ( isPrefixOf, partition, drop )
38import Text.PrettyPrint.HughesPJ hiding ( Str )
38import Text.PrettyPrint.HughesPJ hiding ( Str )
@@ -64,8 +64,8 @@ authorToDocbook name = inTagsIndented "author" $
64 then -- last name first
64 then -- last name first
65 let (lastname, rest) = break (==',') name
65 let (lastname, rest) = break (==',') name
66 firstname = removeLeadingSpace rest in
66 firstname = removeLeadingSpace rest in
67− inTagsSimple "firstname" (text $ encodeEntities firstname) <>
67+ inTagsSimple "firstname" (text $ escapeSGMLString firstname) <>
68− inTagsSimple "surname" (text $ encodeEntities lastname)
68+ inTagsSimple "surname" (text $ escapeSGMLString lastname)
69 else -- last name last
69 else -- last name last
70 let namewords = words name
70 let namewords = words name
71 lengthname = length namewords
71 lengthname = length namewords
@@ -73,8 +73,8 @@ authorToDocbook name = inTagsIndented "author" $
73 0 -> ("","")
73 0 -> ("","")
74 1 -> ("", name)
74 1 -> ("", name)
75 n -> (joinWithSep " " (take (n-1) namewords), last namewords) in
75 n -> (joinWithSep " " (take (n-1) namewords), last namewords) in
76− inTagsSimple "firstname" (text $ encodeEntities firstname) $$
76+ inTagsSimple "firstname" (text $ escapeSGMLString firstname) $$
77− inTagsSimple "surname" (text $ encodeEntities lastname)
77+ inTagsSimple "surname" (text $ escapeSGMLString lastname)
79-- | Convert Pandoc document to string in Docbook format.
79-- | Convert Pandoc document to string in Docbook format.
80writeDocbook :: WriterOptions -> Pandoc -> String
80writeDocbook :: WriterOptions -> Pandoc -> String
@@ -86,7 +86,7 @@ writeDocbook opts (Pandoc (Meta title authors date) blocks) =
86 then inTagsIndented "articleinfo" $
86 then inTagsIndented "articleinfo" $
87 (inTagsSimple "title" (wrap opts title)) $$
87 (inTagsSimple "title" (wrap opts title)) $$
88 (vcat (map authorToDocbook authors)) $$
88 (vcat (map authorToDocbook authors)) $$
89− (inTagsSimple "date" (text $ encodeEntities date))
89+ (inTagsSimple "date" (text $ escapeSGMLString date))
90 else empty
90 else empty
91 blocks' = replaceReferenceLinks blocks
91 blocks' = replaceReferenceLinks blocks
92 (noteBlocks, blocks'') = partition isNoteBlock blocks'
92 (noteBlocks, blocks'') = partition isNoteBlock blocks'
@@ -141,7 +141,7 @@ blockToDocbook opts (Para lst) =
141blockToDocbook opts (BlockQuote blocks) =
141blockToDocbook opts (BlockQuote blocks) =
142 inTagsIndented "blockquote" (blocksToDocbook opts blocks)
142 inTagsIndented "blockquote" (blocksToDocbook opts blocks)
143blockToDocbook opts (CodeBlock str) =
143blockToDocbook opts (CodeBlock str) =
144− text "<screen>\n" <> text (encodeEntities str) <> text "\n</screen>"
144+ text "<screen>\n" <> text (escapeSGMLString str) <> text "\n</screen>"
145blockToDocbook opts (BulletList lst) =
145blockToDocbook opts (BulletList lst) =
146 inTagsIndented "itemizedlist" $ listItemsToDocbook opts lst
146 inTagsIndented "itemizedlist" $ listItemsToDocbook opts lst
147blockToDocbook opts (OrderedList lst) =
147blockToDocbook opts (OrderedList lst) =
@@ -198,7 +198,7 @@ inlinesToDocbook opts lst = hcat (map (inlineToDocbook opts) lst)
199-- | Convert an inline element to Docbook.
199-- | Convert an inline element to Docbook.
200inlineToDocbook :: WriterOptions -> Inline -> Doc
200inlineToDocbook :: WriterOptions -> Inline -> Doc
201−inlineToDocbook opts (Str str) = text $ encodeEntities str
201+inlineToDocbook opts (Str str) = text $ escapeSGMLString str
202inlineToDocbook opts (Emph lst) =
202inlineToDocbook opts (Emph lst) =
203 inTagsSimple "emphasis" (inlinesToDocbook opts lst)
203 inTagsSimple "emphasis" (inlinesToDocbook opts lst)
204inlineToDocbook opts (Strong lst) =
204inlineToDocbook opts (Strong lst) =
@@ -211,7 +211,7 @@ inlineToDocbook opts Ellipses = text "…"
211inlineToDocbook opts EmDash = text "—"
211inlineToDocbook opts EmDash = text "—"
212inlineToDocbook opts EnDash = text "–"
212inlineToDocbook opts EnDash = text "–"
213inlineToDocbook opts (Code str) =
213inlineToDocbook opts (Code str) =
214− inTagsSimple "literal" $ text (encodeEntities str)
214+ inTagsSimple "literal" $ text (escapeSGMLString str)
215inlineToDocbook opts (TeX str) = inlineToDocbook opts (Code str)
215inlineToDocbook opts (TeX str) = inlineToDocbook opts (Code str)
216inlineToDocbook opts (HtmlInline str) = empty
216inlineToDocbook opts (HtmlInline str) = empty
217inlineToDocbook opts LineBreak =
217inlineToDocbook opts LineBreak =
@@ -219,7 +219,7 @@ inlineToDocbook opts LineBreak =
219inlineToDocbook opts Space = char ' '
219inlineToDocbook opts Space = char ' '
220inlineToDocbook opts (Link txt (Src src tit)) =
220inlineToDocbook opts (Link txt (Src src tit)) =
221 if isPrefixOf "mailto:" src
221 if isPrefixOf "mailto:" src
222− then inTagsSimple "email" $ text (encodeEntities $ drop 7 src)
222+ then inTagsSimple "email" $ text (escapeSGMLString $ drop 7 src)
223 else inTags False "ulink" [("url", src)] $ inlinesToDocbook opts txt
223 else inTags False "ulink" [("url", src)] $ inlinesToDocbook opts txt
224inlineToDocbook opts (Link text (Ref ref)) = empty -- shouldn't occur
224inlineToDocbook opts (Link text (Ref ref)) = empty -- shouldn't occur
225inlineToDocbook opts (Image alt (Src src tit)) =
225inlineToDocbook opts (Image alt (Src src tit)) =
@@ -227,7 +227,7 @@ inlineToDocbook opts (Image alt (Src src tit)) =
227 then empty
227 then empty
228 else inTagsIndented "objectinfo" $
228 else inTagsIndented "objectinfo" $
229 inTagsIndented "title"
229 inTagsIndented "title"
230− (text $ encodeEntities tit) in
230+ (text $ escapeSGMLString tit) in
231 inTagsIndented "inlinemediaobject" $
231 inTagsIndented "inlinemediaobject" $
232 inTagsIndented "imageobject" $
232 inTagsIndented "imageobject" $
233 titleDoc $$ selfClosingTag "imagedata" [("fileref", src)]
233 titleDoc $$ selfClosingTag "imagedata" [("fileref", src)]