public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: "krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <krulis.tomas.tk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: How to access Span elements with lua filter based on their content
Date: Fri, 6 Nov 2020 07:50:20 -0800 (PST)	[thread overview]
Message-ID: <84ffd932-2be5-4900-b115-58220e691dcbn@googlegroups.com> (raw)
In-Reply-To: <871rh7trtg.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>


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

Hello Mr. Krewinkel,
thank you for your help. The filter works great! The export option has made 
no difference for me, but I might be using it wrong (as it is always with 
me, I am learning working with Emacs, so I am probably doing something the 
way I shouldnt :D).
The second part is difficult for me. Could you elaborate a little more 
about how did you identified that those `'todo'` or `'TODO'` in the 
TODO-Span as classes, and not attributes? This might be silly question, I 
guess this is somehow inspired by HTML, but it would be really helpfull for 
me to know how this element is represented in pandoc AST.
And the element [String "TODO"] is a one-element list in pandoc-AST, 
therefore it cannot be chacked as-is? Did I got the last part correctly?
Regards, Tomas

Dne čtvrtek 5. listopadu 2020 v 22:31:07 UTC+1 uživatel Albert Krewinkel 
napsal:

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

-- 
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/84ffd932-2be5-4900-b115-58220e691dcbn%40googlegroups.com.

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

  parent reply	other threads:[~2020-11-06 15:50 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
     [not found]     ` <871rh7trtg.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2020-11-06 15:50       ` krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org [this message]
     [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=84ffd932-2be5-4900-b115-58220e691dcbn@googlegroups.com \
    --to=krulis.tomas.tk-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).