aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2009-12-05 18:26:29 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2009-12-05 18:26:29 +0000
commitde38adc7f3d63038b7c72856d25d6e03b2930f8d (patch)
treecb0277291fd5aff27b488adabd67b031a1cfdfbc /src/Text
parent78475498b4d9ffc1677eff55667eb87108333544 (diff)
downloadpandoc-de38adc7f3d63038b7c72856d25d6e03b2930f8d.tar.gz
Docbook writer: add ids to sections. Use link for internal links.
See Issue #60. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1651 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/Docbook.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs
index cd426e7c8..13f670ab2 100644
--- a/src/Text/Pandoc/Writers/Docbook.hs
+++ b/src/Text/Pandoc/Writers/Docbook.hs
@@ -82,12 +82,12 @@ writeDocbook opts (Pandoc (Meta title authors date) blocks) =
-- | Convert an Element to Docbook.
elementToDocbook :: WriterOptions -> Element -> Doc
elementToDocbook opts (Blk block) = blockToDocbook opts block
-elementToDocbook opts (Sec _ _ title elements) =
+elementToDocbook opts (Sec _ id' title elements) =
-- Docbook doesn't allow sections with no content, so insert some if needed
let elements' = if null elements
then [Blk (Para [])]
else elements
- in inTagsIndented "section" $
+ in inTags True "section" [("id",id')] $
inTagsSimple "title" (wrap opts title) $$
vcat (map (elementToDocbook opts) elements')
@@ -262,7 +262,10 @@ inlineToDocbook opts (Link txt (src, _)) =
then emailLink
else inlinesToDocbook opts txt <+> char '(' <> emailLink <>
char ')'
- else inTags False "ulink" [("url", src)] $ inlinesToDocbook opts txt
+ else (if isPrefixOf "#" src
+ then inTags False "link" [("linkend", drop 1 src)]
+ else inTags False "ulink" [("url", src)]) $
+ inlinesToDocbook opts txt
inlineToDocbook _ (Image _ (src, tit)) =
let titleDoc = if null tit
then empty