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

* Re: pandoc 2.19 "flattens" text in table of contents, no more <span> — workaround?
       [not found] ` <a9663214-8b54-4f70-8dcf-8b726ac9b121n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-10-11 19:38   ` Gwern Branwen
  0 siblings, 0 replies; 2+ messages in thread
From: Gwern Branwen @ 2022-10-11 19:38 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Spans were removed by https://github.com/jgm/pandoc/issues/8020

Adding the triangle to the header text is working as it should. (It's
a strange use of <span>s which was not documented nor was it intended,
and you shouldn't've been relying on it.) There would seem to be many
more natural and less error-prone ways to decorate headers with a "▴".
Most obviously, why don't you use a CSS ::after pseudo-element, when
this sort of link annotation is their most common use and avoids
apparent problems with your original approach? (For example, if you
are injecting the triangle as a text literal, isn't it going to
pollute copy-paste?) Or if that doesn't work for something, why not
just wrap the triangle in a real span with a meaningful class, and
then just hide it in the ToC like '#toc span.return-marker { display:
none; }', something like that?

--
gwern

-- 
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/CAMwO0gzcxrMGX0%3DF2Dw_CZvAi1w0RjQYP8%2BwAsx-cemU65NgDw%40mail.gmail.com.


^ 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).