public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* pandoc 2.19 "flattens" text in table of contents, no more <span> — workaround?
@ 2022-10-11 18:55 szho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
       [not found] ` <a9663214-8b54-4f70-8dcf-8b726ac9b121n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: szho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org @ 2022-10-11 18:55 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1985 bytes --]

Dear Pandoc users,

I had a small Pandoc filter that extended each subheading with a link back 
to its parent heading. However, this changes the heading text (by adding 
the link text), which showed up in the table of contents. I did not want 
this, and since I use HTML output, I could use some CSS to hide the extra 
text. This was possible because the extra text was in a <span> element.

However, since pandoc 2.19, the extra text is just appended, without a 
<span>. Thus I cannot hide it the same way. Is there a workaround?

To give a concrete example, consider this simple markdown:

# My Title

## Chapter 1

Foo

## Chapter 2

Bar

This is a simplified version of my filter:

local function head_add_backlink (head) 
head.content:extend(
  {
    pandoc.Link(
     "▴",
     "#my-title",
     "",
     pandoc.Attr("", {'link-back'})
    )
   }
)
return head
end

return { 
  { Header = head_add_backlink }
}

I am running this with pandoc --toc --lua-filter=my_filter.lua -t html -s 
test.md 

With pandoc 2.18, the table of contents looked like this:

<li><a href="#chapter-1" id="toc-chapter-1">Chapter 1<span>▴</span></a></li>

With 2.9 it looks like this

<li><a href="#chapter-1" id="toc-chapter-1">Chapter 1▴</a></li>

Notice that there is no more <span> that I can use to hide the "▴" 
character.

Is there a simple way to achieve my goal with 2.19, i.e. have backlinks in 
each header yet not show these backlinks in the table of contents?

Thanks for any help in advance,
Szabolcs

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/a9663214-8b54-4f70-8dcf-8b726ac9b121n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 5404 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-11 19:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-11 18:55 pandoc 2.19 "flattens" text in table of contents, no more <span> — workaround? szho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
     [not found] ` <a9663214-8b54-4f70-8dcf-8b726ac9b121n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-10-11 19:38   ` Gwern Branwen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).