public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: "szho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <szhorvat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: pandoc 2.19 "flattens" text in table of contents, no more <span> — workaround?
Date: Tue, 11 Oct 2022 11:55:52 -0700 (PDT)	[thread overview]
Message-ID: <a9663214-8b54-4f70-8dcf-8b726ac9b121n@googlegroups.com> (raw)


[-- 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 --]

             reply	other threads:[~2022-10-11 18:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11 18:55 szho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org [this message]
     [not found] ` <a9663214-8b54-4f70-8dcf-8b726ac9b121n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-10-11 19:38   ` Gwern Branwen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a9663214-8b54-4f70-8dcf-8b726ac9b121n@googlegroups.com \
    --to=szhorvat-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).