On 06/13/2023 04:28 AM, 'William Lupton' via pandoc-discuss wrote: > This lua filter will remove the caption: > > function Figure(figure) >     figure.caption = {} >     return figure > end > > (It didn't work to set figure.caption to nil. This seemed to have no effect. Perhaps someone can explain why?) > > On Mon, 12 Jun 2023 at 22:19, H > wrote: > > On June 12, 2023 5:09:20 PM EDT, 'William Lupton' via pandoc-discuss > wrote: > >I'm not sure whether this helps in your situation, but if the image has > >no > >alt text then there'll be no caption in the HTML (and no figure element > >either). This document: > > > >![test](https://www.somedomain.tld/test.jpg) > > > >![](https://www.somedomain.tld/test.jpg) > > > >...gives this HTML: > > > >
> >test > > > >
> >

> > > >See https://pandoc.org/MANUAL.html#extension-implicit_figures > > > > > >On Sun, 11 Jun 2023 at 16:54, H > wrote: > > > >> On 06/11/2023 09:51 AM, BPJ wrote: > >> > >> An image will be wrapped in a `
` when it is the only thing in > >a > >> paragraph, so the workaround is to add a non-breaking space after the > >> image. > >> > >> This filter removes the Figure leaving the Image and an nbspace in a > >Para > >> unless the Image has a class `.fig`. > >> > >> It can be used both to globally insert the needed nbspace into > >Markdown or > >> used always to so to speak implement a better syntax where you > >clearly mark > >> a lone-image paragraph if you want a figure. > >> > >> https://gist.github.com/bpj/6664b0b0755e7ebe9007de4d1426d400 > >> > >> Den sön 11 juni 2023 04:26H > skrev: > >> > >>> On 06/06/2023 03:14 PM, H wrote: > >>> > >>> On 06/01/2023 04:34 AM, 'William Lupton' via pandoc-discuss wrote: > >>> > >>> Am I correct in thinking that when you say "filter" here, you really > >mean > >>> "writer"? > >>> > >>> In filters, you can use the 'traverse' field to force top-down > >traversal. > >>> See https://pandoc.org/lua-filters.html#traversal-order > >>> > >>> In writers, you can choose to call doc:walk(), which will honour > >>> 'traverse'. See > >>> > >https://pandoc.org/custom-writers.html#example-modified-markdown-writer > >>> (and example below) > >>> > >>> However, if you use pandoc.scaffolding.Writer (as I think you are?) > >then > >>> I suspect that you can't control the traversal order (but I'm not > >sure that > >>> it makes sense to do so, because, for example, surely you always > >want the > >>> contents of a
to have been traversed before you add '
' > >and > >>> '
'?). > >>> > >>> With the custom writer shown below, and with an input file that > >consists > >>> of the single line 'Text' (and using my logging module > >>> ), you get this with the > >default > >>> 'typewise' traversal: > >>> > >>> (#) inline Str "Text" > >>> (#) inlines Inlines[1] {[1] Str "Text"} > >>> (#) block Para {content: Inlines[1] {[1] Str "Text"}} > >>> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str > >"Text"}}} > >>> (#) meta Meta {} > >>> (#) doc Pandoc { > >>>   blocks: Blocks[1] { > >>>     [1] Para { > >>>       content: Inlines[1] { > >>>         [1] Str "Text" > >>>       } > >>>     } > >>>   } > >>>   meta: Meta {} > >>> } > >>> > >>> ...and this with 'topdown' traversal: > >>> > >>> (#) doc Pandoc { > >>>   blocks: Blocks[1] { > >>>     [1] Para { > >>>       content: Inlines[1] { > >>>         [1] Str "Text" > >>>       } > >>>     } > >>>   } > >>>   meta: Meta {} > >>> } > >>> (#) meta Meta {} > >>> (#) blocks Blocks[1] {[1] Para {content: Inlines[1] {[1] Str > >"Text"}}} > >>> (#) block Para {content: Inlines[1] {[1] Str "Text"}} > >>> (#) inlines Inlines[1] {[1] Str "Text"} > >>> (#) inline Str "Text" > >>> > >>> The writer: > >>> > >>> local logging = require 'logging' > >>> > >>> local function report(label, elem) > >>>     logging.temp(label, elem) > >>> end > >>> > >>> -- 'typewise' (default) or 'topdown' > >>> local traverse = 'topdown' > >>> > >>> function Writer (doc, opts) > >>>     local filter = { > >>>         traverse = traverse, > >>>         Inline = function(inline) > >>>             report('inline', inline) > >>>         end, > >>>         Inlines= function(inlines) > >>>             report('inlines', inlines) > >>>         end, > >>>         Block = function(block) > >>>             report('block', block) > >>>         end, > >>>         Blocks = function(blocks) > >>>             report('blocks', blocks) > >>>         end, > >>>         Meta = function(meta) > >>>             report('meta', meta) > >>>         end, > >>>         Pandoc = function(doc) > >>>             report('doc', doc) > >>>         end, > >>>     } > >>>     return pandoc.write(doc:walk(filter), 'html', opts) > >>> end > >>> > >>> Thank you for your thoughtful response. I realize I have used the > >term > >>> 'filter' and 'writer' cavalierly. I have a "slightly" complicated > >layout I > >>> want to output from the writer and my thought right now is that I > >should > >>> try to add the
and
in the right places in a filter and > >then > >>> let the writer just output the resulting html. > >>> > >>> I may have to traverse the AST several times in my filter to > >accomplish > >>> the result since multiple
need to be added at different > >levels > >>> to achieve the desired output. > >>> > >>> I just downloaded your logging filter to aid in the development and > >am > >>> also working on formalizing the rules for adding
. > >>> > >>> > >>> I spent some more time learning more about writing filters and have > >made > >>> some progress. > >>> > >>> I think the entire logic for adding
to achieve the > >desired > >>> layout might be doable in the filter and most of it seems to be > >working. > >>> > >>> One thing I found is that when an image is included using the > >following > >>> syntax > >>> ![test](https://www.somedomain.tld/test.jpg) > >>> pandoc wraps the element in
which I think > >I > >>> don't want/need. > >>> > >>> How can I get rid of
wrapped around elements? At > >the > >>> very least I want got get rid of some text I do not > >>> need inside the
element? > >>> > >>> Got it, thank you and I will look at your code. If I am not adding > >the > >> non-breakable space after the image however, how do I get rid of the > >> element which I do not need (or want cluttering up my > >code)? > >> > >> -- > >> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org . > >> To view this discussion on the web visit > >> > >https://groups.google.com/d/msgid/pandoc-discuss/b189960a-3e0d-19b8-91e2-c16dc88cd595%40meddatainc.com > >> > > > >> . > >> > > It does have alt text and I do want to keep that. I do, however, want to get rid of the text - is this doable? > Thank you. -- 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/c11494eb-470f-e0bd-7d93-be6b4f75db7d%40meddatainc.com.