From de38adc7f3d63038b7c72856d25d6e03b2930f8d Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sat, 5 Dec 2009 18:26:29 +0000 Subject: 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 --- src/Text/Pandoc/Writers/Docbook.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') 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 -- cgit v1.2.3