public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* How to manipulate with Block elements with Lua filters
@ 2022-01-10 14:32 Tomáš Kruliš
       [not found] ` <590abdf0-6bc5-4f37-a978-a46ad5cff5a8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Tomáš Kruliš @ 2022-01-10 14:32 UTC (permalink / raw)
  To: pandoc-discuss


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

Hello,

I would like to ask how you should, in general, detect and manipulate with 
Pandoc `block` elements. Currently, I am trying to replace `<div 
class='replace-me'>` tag with `<note>` tag in similar (highly simplified) 
HTML file:

```.{html}
<html>
<body>
<p> First line. </p>
<div class="replace-me another-class"> This should carry on to converted 
document. </div>
<p>End.</p>
</body>
</html>
```

I have tried to detect the `<div>` tag, use `walk_block` to get the `<div>` 
content and put it in `<note>` tag, I also found a code using `:walk` 
method. Lastly, I tried to convert `<div>` content to simple string and 
concatenate that in `RawInline` type:

```.{lua}
  if elem.t == 'Div' and elem.classes[1] == "replace-me" then
    content = pandoc.utils.stringify(elem.content)
    return pandoc.RawInline('html', '<note>' .. content.. '</note>')
  else
    return elem
  end
```

But none of that is working. I would like to ask you, how to work in 
general with `pandoc_walk` or `:walk` (are they the same?) and how to deal 
with my specific situation?
Thank you very much for any help, I ope that afterwards I will be able to 
help myself a little bit more :)
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/590abdf0-6bc5-4f37-a978-a46ad5cff5a8n%40googlegroups.com.

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

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

end of thread, other threads:[~2023-07-05 15:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10 14:32 How to manipulate with Block elements with Lua filters Tomáš Kruliš
     [not found] ` <590abdf0-6bc5-4f37-a978-a46ad5cff5a8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-01-10 18:46   ` BPJ
     [not found]     ` <CADAJKhAzeK-kPd7yHWbtGX=363VvcgFUj8gt_vEMUXfGkBd+ug-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-01-11 14:07       ` Tomáš Kruliš
     [not found]         ` <aea85ef4-af50-46e5-8e21-d677801cb971n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-01-11 20:56           ` Bastien DUMONT
2022-01-11 21:25           ` Bastien DUMONT
2022-01-12  9:45           ` BPJ
     [not found]             ` <CADAJKhD6WVs3UxD0Dt0bYLA8mE4-A4n=QyyKrwkT=MYO+QNaVg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-01-13 14:40               ` Tomáš Kruliš
2023-06-26 19:12       ` Ioan Muntean
     [not found]         ` <ae032a8d-4d0a-4608-b479-61965cee2793n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-07-05 15:44           ` BPJ

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