summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2022-04-18 14:22:31 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2022-04-18 14:22:31 -0700
commit6a041a1b75e5b6e248d1d37d23ca22258d7a3cd8 (patch)
treef1a6c037723bd42649c932bc7ca9e9424c78dc53 /src
parent990eb85dc736494f8ae8d996ce3f4065ce0b733d (diff)
Don't replace links with empty spans in TOC.
This was a performance enhancement which probably isn't too significant. Closes #8020. Note that, with this change, T.P.Shared.deLink isn't used anywhere in the code base; perhaps we should deprecate it (or remove it, but this would be an API change).
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Shared.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs
index 7cf72ae8c..ea2536001 100644
--- a/src/Text/Pandoc/Writers/Shared.hs
+++ b/src/Text/Pandoc/Writers/Shared.hs
@@ -445,7 +445,10 @@ sectionToListItem opts (Div (ident,_,_)
then id
else (Span ("",["toc-section-number"],[])
[Str num] :) . (Space :)
- headerText' = addNumber $ walk (deLink . deNote) ils
+ clean (Link _ ils _) = ils
+ clean (Note _) = []
+ clean x = [x]
+ headerText' = addNumber $ walk (concatMap clean) ils
headerLink = if T.null ident
then headerText'
else [Link ("toc-" <> ident, [], []) headerText' ("#" <> ident, "")]