From: Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Pointers on modifying Plain objects(?)
Date: Thu, 22 Dec 2022 13:05:33 +0100 [thread overview]
Message-ID: <878riz8wf4.fsf@zeitkraut.de> (raw)
In-Reply-To: <8af6876b-72cc-448e-9f5e-7d12ccdf2ad8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
"balaj...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <balaji.dutt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
> The specific scenario I'm looking at is a Markdown file such as this:
>
> ### Todo
> - [ ] Foo
> - [X] Quux Qux
This is an interesting case because it is more complex than it seems.
The reason is pandoc's `task_list` extension that causes pandoc to
handle these checkboxes specially, converting them to [Str "☐", Space]
and [Str "☒", Space]. So we'll have to match on that in our filter.
A good approach would be to write a filter for Plain, like so:
``` lua
function Plain (plain)
-- modify the object here
return plain
end
```
Pandoc will then do all necessary document traversals automatically,
the function gets applied to all `Plain` elements in the document.
To check for the prefix, we'd do something like
``` lua
local done_marker = pandoc.List{pandoc.Str '☒', pandoc.Space()}
local prefix = pandoc.List{plain.content[1], plain.content[2]}
if prefix == done_marker then
-- modify content
end
```
I hope that's enough to get you started. Happy hacking!
--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124
--
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/878riz8wf4.fsf%40zeitkraut.de.
next prev parent reply other threads:[~2022-12-22 12:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-22 8:53 balaj...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
[not found] ` <8af6876b-72cc-448e-9f5e-7d12ccdf2ad8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-12-22 12:05 ` Albert Krewinkel [this message]
[not found] ` <878riz8wf4.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2022-12-24 8:37 ` balaj...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
[not found] ` <8f0e8d81-7f0b-49a7-b9b5-d78b19a0b1ban-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-12-24 10:26 ` Albert Krewinkel
[not found] ` <C927BB76-A05B-48E2-8277-0DED656D13CA-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2022-12-25 9:15 ` balaj...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
[not found] ` <5257c49e-968d-40bf-a398-ae104a53c5c8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-12-25 9:55 ` Albert Krewinkel
[not found] ` <877cyf7qb2.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2022-12-27 4:42 ` balaj...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
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=878riz8wf4.fsf@zeitkraut.de \
--to=albert+pandoc-9eawchwdxg8hfhg+jk9f0w@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).