git.iko.soy/typeable/pandoc
on master help sign in
HTML and DocBook writers: fix internal links with writerIdentifierPrefix opt (#3398)

closes #3397

commit5cd475be7057487ba4f63e2257b6f65b975acd58 authorMauro Bieg <mb21@users.noreply.github.com> dateFri 3 Feb 2017, 09:53 (10 years ago) parent9327e70
3 files changed+10−8
MANUAL.txt+4−4 src/Text/Pandoc/Writers/Docbook.hs+1−1 src/Text/Pandoc/Writers/HTML.hs+5−3
MANUAL.txt+4−4
@@ -733,10 +733,10 @@ Options affecting specific writers
733733
734734`--id-prefix=`*STRING*
735735
736−: Specify a prefix to be added to all automatically generated identifiers
737− in HTML and DocBook output, and to footnote numbers in Markdown output.
738− This is useful for preventing duplicate identifiers when generating
739− fragments to be included in other pages.
736+: Specify a prefix to be added to all identifiers and internal links
737+ in HTML and DocBook output, and to footnote numbers in Markdown
738+ and Haddock output. This is useful for preventing duplicate
739+ identifiers when generating fragments to be included in other pages.
740740
741741`-T` *STRING*, `--title-prefix=`*STRING*
742742
src/Text/Pandoc/Writers/Docbook.hs+1−1
@@ -405,7 +405,7 @@ inlineToDocbook opts (Link attr txt (src, _))
405405 | otherwise = do
406406 version <- ask
407407 (if isPrefixOf "#" src
408− then inTags False "link" $ ("linkend", drop 1 src) : idAndRole attr
408+ then inTags False "link" $ ("linkend", writerIdentifierPrefix opts ++ drop 1 src) : idAndRole attr
409409 else if version == DocBook5
410410 then inTags False "link" $ ("xlink:href", src) : idAndRole attr
411411 else inTags False "ulink" $ ("url", src) : idAndRole attr )
src/Text/Pandoc/Writers/HTML.hs+5−3
@@ -933,9 +933,11 @@ inlineToHtml opts inline = do
933933 linkText <- inlineListToHtml opts txt
934934 slideVariant <- gets stSlideVariant
935935 let s' = case s of
936− '#':xs | slideVariant == RevealJsSlides
937− -> '#':'/':xs
938− _ -> s
936+ '#':xs -> let prefix = if slideVariant == RevealJsSlides
937+ then "/"
938+ else writerIdentifierPrefix opts
939+ in '#' : prefix ++ xs
940+ _ -> s
939941 let link = H.a ! A.href (toValue s') $ linkText
940942 let link' = if txt == [Str (unEscapeString s)]
941943 then link ! A.class_ "uri"