aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-05-20 10:55:06 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-05-20 10:55:06 -0700
commitf532dd69c9a4f9a3d408c7e502dc5417fe4949c2 (patch)
tree99cffe1ac66381265045012df186cc2da700ec5c /src/Text
parent2fb570991511f79766b5183a467e96278e108380 (diff)
downloadpandoc-f532dd69c9a4f9a3d408c7e502dc5417fe4949c2.tar.gz
DocBook writer: add id to para if in Div with id element.
This makes the writer work properly with linked bibliographic items with pandoc-citeproc. Closes jgm/pandoc-citeproc#132.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/Docbook.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs
index 08a83c85e..f3b99e141 100644
--- a/src/Text/Pandoc/Writers/Docbook.hs
+++ b/src/Text/Pandoc/Writers/Docbook.hs
@@ -154,6 +154,14 @@ listItemToDocbook opts item =
-- | Convert a Pandoc block element to Docbook.
blockToDocbook :: WriterOptions -> Block -> Doc
blockToDocbook _ Null = empty
+-- Add ids to paragraphs in divs with ids - this is needed for
+-- pandoc-citeproc to get link anchors in bibliographies:
+blockToDocbook opts (Div (ident,_,_) [Para lst]) =
+ let attribs = [("id", ident) | not (null ident)] in
+ if hasLineBreaks lst
+ then flush $ nowrap $ inTags False "literallayout" attribs
+ $ inlinesToDocbook opts lst
+ else inTags True "para" attribs $ inlinesToDocbook opts lst
blockToDocbook opts (Div _ bs) = blocksToDocbook opts $ map plainToPara bs
blockToDocbook _ (Header _ _ _) = empty -- should not occur after hierarchicalize
blockToDocbook opts (Plain lst) = inlinesToDocbook opts lst