public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* How to access Span elements with lua filter based on their content
@ 2020-11-05 17:01 krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
       [not found] ` <fa68cec8-4ff1-4bbe-95fa-65d36c28bda7n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org @ 2020-11-05 17:01 UTC (permalink / raw)
  To: pandoc-discuss


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

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

My first attempt was to use lua filter. I can simply do:

`deleteSpans.lua`
```
function Span(el)
     return pandoc.Str('')
end
```

but this removes just all `Spans`, which could be bad (but doesnt mind in 
my current specific case).

I have tryed to do better like this:

`removeTODO.lua`
```
function Span(el)
  if el.text == 'TODO' then
      return pandoc.Str('')
    else
      return nil
  end
end
```

But this doesnt have any effect. When I look at `lua-filter` docs and on 
`Span` constructor, and try to reverse-engineer that, I am very confused. 
There are `Attr`, `attributes`, and such, and none of them worked.

So, how can I access, or match, `pandoc Span` elements based on their 
content? Where can I read more about this?

If it is possible to achive from `emacs` or `org-agenda` side, I will be 
very interested in that option too.

So far, I was little hesitant to go through hackage and `pandoc.types`; but 
if that is the place to go (in the future), than I give it my best shot.

Thank you very much with any help in this.
Regards, Tomas

-- 
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/fa68cec8-4ff1-4bbe-95fa-65d36c28bda7n%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-08 18:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05 17:01 How to access Span elements with lua filter based on their content 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
     [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

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