From: Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: How to access Span elements with lua filter based on their content
Date: Thu, 05 Nov 2020 22:30:19 +0100 [thread overview]
Message-ID: <871rh7trtg.fsf@zeitkraut.de> (raw)
In-Reply-To: <fa68cec8-4ff1-4bbe-95fa-65d36c28bda7n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org writes:
> I am using pandoc to convert `org-agenda` list of todos to `docx` and `pdf`
> for my coworkers. File exported from `emacs org-agenda` can look like that
> (simplified):
>
> `tasks.org`
> ```
> * TODO Feed the cat
> ```
>
> Pandoc native output of this file parsing is:
>
> ```
> [Header 1 ("feed-the-cat",[],[]) [Span ("",["todo","TODO"],[]) [Str
> "TODO"],Space,Str "Feed",Space,Str "the",Space,Str "cat"]]
> ```
>
> Now if I convert this to any output format, I get spurious "TODO" pandoc
> strings (that are present from `org-mode`). How can I get rid of this
> "TODO" string (preferably also with surrounding spaces)?
Two options:
1. The org reader recognizes most org export options. So adding the
following line to your input file should be enough:
#+OPTIONS: todo:nil
See: https://orgmode.org/manual/Export-Settings.html
2. With a Lua filter you'll want
function Span (span)
if span.classes:includes 'todo' then
return {} -- delete this element
end
end
> So, how can I access, or match, `pandoc Span` elements based on their
> content? Where can I read more about this?
_Just_ on their content is difficult for various reasons, but you can
compare AST elements using the normal `==` Lua operator. The comparison
of elements happens in Haskell, where elements don't have identity.
So `pandoc.Span {pandoc.Str 'hi'} == pandoc.Span {pandoc.Str 'hi'}`
would be true, but `{pandoc.Str 'hi'} == {pandoc.Str 'hi'}` would be
false, as lists are note treated as AST elements. We might change that
at some point.
HTH,
--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124
next prev parent reply other threads:[~2020-11-05 21:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-05 17:01 krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
[not found] ` <fa68cec8-4ff1-4bbe-95fa-65d36c28bda7n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-11-05 21:30 ` Albert Krewinkel [this message]
[not found] ` <871rh7trtg.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2020-11-06 15:50 ` krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
[not found] ` <84ffd932-2be5-4900-b115-58220e691dcbn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-11-06 19:31 ` Albert Krewinkel
[not found] ` <87tuu2s2mw.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2020-11-08 18:20 ` krulis....-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=871rh7trtg.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).