diff options
author | Mauro Bieg <mb21@users.noreply.github.com> | 2017-02-03 09:53:43 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-02-03 09:53:43 +0100 |
commit | 5cd475be7057487ba4f63e2257b6f65b975acd58 (patch) | |
tree | 10d2d4d1f698d665c4a35526e163b548af9b4e64 | |
parent | 9327e70c1081f83f60bbc473f60bb25d7cee314a (diff) | |
download | pandoc-5cd475be7057487ba4f63e2257b6f65b975acd58.tar.gz |
HTML and DocBook writers: fix internal links with writerIdentifierPrefix opt (#3398)
closes #3397
-rw-r--r-- | MANUAL.txt | 8 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Docbook.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 8 |
3 files changed, 10 insertions, 8 deletions
diff --git a/MANUAL.txt b/MANUAL.txt index 3e4425a72..29fde9168 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -733,10 +733,10 @@ Options affecting specific writers `--id-prefix=`*STRING* -: Specify a prefix to be added to all automatically generated identifiers - in HTML and DocBook output, and to footnote numbers in Markdown output. - This is useful for preventing duplicate identifiers when generating - fragments to be included in other pages. +: Specify a prefix to be added to all identifiers and internal links + in HTML and DocBook output, and to footnote numbers in Markdown + and Haddock output. This is useful for preventing duplicate + identifiers when generating fragments to be included in other pages. `-T` *STRING*, `--title-prefix=`*STRING* diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs index 4c5b255d8..482cae3db 100644 --- a/src/Text/Pandoc/Writers/Docbook.hs +++ b/src/Text/Pandoc/Writers/Docbook.hs @@ -405,7 +405,7 @@ inlineToDocbook opts (Link attr txt (src, _)) | otherwise = do version <- ask (if isPrefixOf "#" src - then inTags False "link" $ ("linkend", drop 1 src) : idAndRole attr + then inTags False "link" $ ("linkend", writerIdentifierPrefix opts ++ drop 1 src) : idAndRole attr else if version == DocBook5 then inTags False "link" $ ("xlink:href", src) : idAndRole attr else inTags False "ulink" $ ("url", src) : idAndRole attr ) diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index d1fb3dda7..64eccd35e 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -933,9 +933,11 @@ inlineToHtml opts inline = do linkText <- inlineListToHtml opts txt slideVariant <- gets stSlideVariant let s' = case s of - '#':xs | slideVariant == RevealJsSlides - -> '#':'/':xs - _ -> s + '#':xs -> let prefix = if slideVariant == RevealJsSlides + then "/" + else writerIdentifierPrefix opts + in '#' : prefix ++ xs + _ -> s let link = H.a ! A.href (toValue s') $ linkText let link' = if txt == [Str (unEscapeString s)] then link ! A.class_ "uri" |