From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32796 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "'William Lupton' via pandoc-discuss" Newsgroups: gmane.text.pandoc Subject: Re: Wrapping sections of text with
in custom filter Date: Tue, 13 Jun 2023 09:28:11 +0100 Message-ID: References: <2fc450a6-5a16-316c-02c8-8ef055bccd11@meddatainc.com> <1F66BB1E-B5C8-4062-8202-D82C5CE9A3D0@meddatainc.com> <6d414734-e661-ae2d-68a1-4dfc9cb4f035@meddatainc.com> <4c58dad0-bd86-608e-2d68-74bd6f2f808b@meddatainc.com> <574fbf9f-c1b8-711a-f14a-3acd75cbf634@meddatainc.com> <05ba5663-1578-d555-8539-d6a2bdff6743@meddatainc.com> <7878b22d-bf64-2d25-1136-d9f9cf5e135b@meddatainc.com> <992af9a4-285c-a20f-56de-347ea88f021f@meddatainc.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000004efad405fdfe9e7b" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27352"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCS4HJ6WSAHBBKORUCSAMGQEFX7VAQQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Jun 13 10:28:30 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lf1-f63.google.com ([209.85.167.63]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1q8zOA-0006sB-7I for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 13 Jun 2023 10:28:30 +0200 Original-Received: by mail-lf1-f63.google.com with SMTP id 2adb3069b0e04-4f617f00f27sf3555996e87.2 for ; Tue, 13 Jun 2023 01:28:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686644909; cv=pass; d=google.com; s=arc-20160816; b=c8KELIu/5866VUU3hX1hoN1znWYZMe+c6j70KKeYZ8TQnVjitakjzjyq2M6GUJ7CNX cY0rrdYln1Kl01bsaVmkm/yabEj2LxAdWRJ1TqhwYwNrOFcaFiyQUz4O+lrwXyGr32h2 qhG19P4hOEAZ1jsCrbkXqEFdjncsapwv1uFxOlRlu6GNGm2mfPoUywq9at8Nu6fJGOvc 9qSkD40Cy9pWT9QprP62caVn4L+Um4xqy59I92XdZCMlQKaeWaP9z+WF22HMPx3/HhF7 Ynri4/0agXF4WqUqbVq9dE7zJ62gyFHcbpxXwgciwN9o2gzYPRtK7YrwCh1R4Oua1eiY qNSA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date :from:in-reply-to:references:mime-version:dkim-signature; bh=kVdZxsCwwGJ4cRdceiTlnHUkyzLNs1+maRDdD5Y0kJ8=; b=g+LXsuXJ/BX9rL55dgtgvxsgIVQrefl8dtDkaX/ZTRblC7zu/E8hjVvdRJgoa/6Kt/ 7yQ6u/4bfLV3EFQQiFFNJx3+4rzsv0PE4hhEmVWlIwHbBOP2MtK5bf0SlA23jjXPgYbQ qcegsKQyKVyK9OfyHt6NUFlS6NDx7eOlolQKHfct3aS4FTYvkOy8qWQEz0uaVm8bydE6 s/r2gGKLipexLL1wFPWrpvDDXuw7jUSzmm6oWi6he3W7w/rEQ4ZgIKZUKmCNOlsLITUp SdpTudNT5wFgu5PDeB8A5VEmWNNql4TAOQNG2M2RJScLgXpMVmQKbAWW/Lbs9aRnaKIv a7CQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@broadband-forum.org header.s=google header.b=qN58zloW; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::631 as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadband-forum.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1686644909; x=1689236909; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:to:subject :message-id:date:from:in-reply-to:references:mime-version:from:to:cc :subject:date:message-id:reply-to; bh=kVdZxsCwwGJ4cRdceiTlnHUkyzLNs1+maRDdD5Y0kJ8=; b=skD/mLUKYnwC2cK6gWCZRjLKhVdA1CQLRVEVTg9B6G6pdKofcnI8qaknVozlKJ4O6X qWwL9IzQJXG7KGaX/MvuQGw3zIlR//ioeYGA9VKqHU+GTh3huD+0K4zud0OUEI6Bp7iJ 8y4umG1jaDtjhGcI/n2vB2eAdhP8Qw0cR3qsJrwT5sbdlCTKyCl14vcQXaGxhMtbcrsP Co/A30NSI9hRF2ae7uJ5RAyku7rHfmsGtyNI0kSMZLjHl3iUF1K/FljkAgLt3xPfB/b5 9XH9/1Z+X4W8L2Z+DUO1LiF38XKbeGBprEbopfsacpng5d2c0/0GTie/RFklAWMs74fa 76 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686644909; x=1689236909; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:to:subject :message-id:date:from:in-reply-to:references:mime-version :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kVdZxsCwwGJ4cRdceiTlnHUkyzLNs1+maRDdD5Y0kJ8=; b=lNbaEluxZrDVQLAg0G+Om41wCwx2paRmhrIo9UFcYLcAaKO4Zd2W3Z/+z+WEk0HLJ7 Lm+Oz2UYFnwKPkaEqLLxhhqsgYNB9xYKGC9Y5DM8DYUFC96JzD5i8477Vb30FC3J892+ ux3Wu5xVpNYhVCAgFX18fBvq1O7ZkWx7gd0fEj5MbD2Gn+L+HZxf7e+PDvfmh7uxsuSq 5wDi0mKQW8fK2YzZlC3fYC6BxJiasQLXu2nb9CaDdeWCC+S7K/R/M1CMNPV4iW4OBckL IatkZcGCaII97 X-Gm-Message-State: AC+VfDxiE+WkIKPyLJ/y0fJeJG/jCk4L6hvPwcns8+UfMkvkCdm5YiCM pTfyM/N0tZuZPm+v7NMLu1c= X-Google-Smtp-Source: ACHHUZ4M9P5hnEadxFb7c9GffPaQePNHKWWyQ/imk6bbYruHmGR2VpExocAh54MmPTg72u+Tqpq/Wg== X-Received: by 2002:a05:6512:411:b0:4f6:2020:7c24 with SMTP id u17-20020a056512041100b004f620207c24mr4844053lfk.5.1686644909070; Tue, 13 Jun 2023 01:28:29 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:600c:5123:b0:3f6:77a:31b0 with SMTP id o35-20020a05600c512300b003f6077a31b0ls1165356wms.1.-pod-prod-05-eu; Tue, 13 Jun 2023 01:28:24 -0700 (PDT) X-Received: by 2002:a7b:cd8e:0:b0:3f8:cde1:be0 with SMTP id y14-20020a7bcd8e000000b003f8cde10be0mr691854wmj.41.1686644904048; Tue, 13 Jun 2023 01:28:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686644904; cv=none; d=google.com; s=arc-20160816; b=z/sSyuVakB9Opq24l/QKqLUeD46KEFWK5RGKQ533s8cHmuBuKoGTWBZJG01/WDIsAJ seZlx3Ark3sbQza7YcXhpijb6G7GC7WDqHNONw3cdyudRzyAkBSwGETvhk7po63LIqJf Up3RyOy+6l4+T37iu2EgvkuDmevlQFSsQwM/Fqvh4rCE7bvVKad4RHXdh+e5Hn/CXdnx nXW9vbvDkYNyWI/UyW3bfVcw608wNFPRTejA36Ou4bb69eioMqUpQgcoX8U97ebhPTCX OhyYLCVoLfN9nHA2DFRLGFYQxTLmFyFqrEjKfrMvDdKd69yonsQJ1ET4/ENCwabSQ+kI bxJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=RHRRRuf7D/qsBu5uOd7BJAIwE8vSuEYay6Wpdu6VLVI=; b=IjdzqG/lue2x4eCMnniEP7Or6JVv1tCIivudDu38faGuHfekB1o0XATJ1MfxytW8j/ 0GMIWBZSnP5FZvHRCA11bECRHMaofFAuLiwVj4ndxJPXZZ0TKtDHpg56KHvNLGGIWOQj wNu2IjUNFWih1KL/V/exgBOqjLllk6PnHTz9yJ2IYQqYTIRTHqmjBrRfSFWPSNMadJI8 uHpjm4NXaVsfFijHOOO+/PC9yr03OJQ4aZpQIdfbxokXYIG8ZpwjoW9BIFywdZPJ4isy yh8NIHs5UQ2uuqaVsv0Or3guJVn54V/Rq3HQ2poxs6pGJn7PveOcxJW6U5Itd7jaFBcX AyKQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@broadband-forum.org header.s=google header.b=qN58zloW; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::631 as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadband-forum.org Original-Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com. [2a00:1450:4864:20::631]) by gmr-mx.google.com with ESMTPS id az20-20020a05600c601400b003f7e70ac85esi957929wmb.1.2023.06.13.01.28.23 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Jun 2023 01:28:23 -0700 (PDT) Received-SPF: pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::631 as permitted sender) client-ip=2a00:1450:4864:20::631; Original-Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-977c72b116fso794420366b.3 for ; Tue, 13 Jun 2023 01:28:23 -0700 (PDT) X-Received: by 2002:a17:906:eec1:b0:977:4b68:bf2 with SMTP id wu1-20020a170906eec100b009774b680bf2mr9806431ejb.54.1686644903042; Tue, 13 Jun 2023 01:28:23 -0700 (PDT) In-Reply-To: X-Original-Sender: wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@broadband-forum.org header.s=google header.b=qN58zloW; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::631 as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadband-forum.org X-Original-From: William Lupton Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:32796 Archived-At: --0000000000004efad405fdfe9e7b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable This lua filter will remove the caption: function Figure(figure) figure.caption =3D {} 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 < > pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 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: > > > >
> >3D"test" > >
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=C3=B6n 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 =3D require 'logging' > >>> > >>> local function report(label, elem) > >>> logging.temp(label, elem) > >>> end > >>> > >>> -- 'typewise' (default) or 'topdown' > >>> local traverse =3D 'topdown' > >>> > >>> function Writer (doc, opts) > >>> local filter =3D { > >>> traverse =3D traverse, > >>> Inline =3D function(inline) > >>> report('inline', inline) > >>> end, > >>> Inlines=3D function(inlines) > >>> report('inlines', inlines) > >>> end, > >>> Block =3D function(block) > >>> report('block', block) > >>> end, > >>> Blocks =3D function(blocks) > >>> report('blocks', blocks) > >>> end, > >>> Meta =3D function(meta) > >>> report('meta', meta) > >>> end, > >>> Pandoc =3D 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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 > >> > >< > https://groups.google.com/d/msgid/pandoc-discuss/b189960a-3e0d-19b8-91e2-= c16dc88cd595%40meddatainc.com?utm_medium=3Demail&utm_source=3Dfooter > > > >> . > >> > > 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? > > -- > 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/EAF5063B-4655-48B3-8961-= AF664AE3C94F%40meddatainc.com > . > --=20 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 e= mail 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/CAEe_xxjdOUK-tpNsw65u_v_gNr0nUkF5vfrQc0RQyLhJyjtHSA%40mail.g= mail.com. --0000000000004efad405fdfe9e7b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This lua filter will remove the caption:

function Figure(figure)
=C2=A0 =C2=A0 figure.= caption =3D {}
=C2=A0 =C2=A0 return figure
end

<= br>
(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 2= 023 at 22:19, H <agents@meddata= inc.com> wrote:
On June 12, 2023 5:09:20 PM EDT, 'William Lupton' via pandoc= -discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 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 ele= ment
>either). This document:
>
>![test](https://www.somedomain.tld/test.jpg)
>
>![](https://www.somedomain.tld/test.jpg)
>
>...gives this HTML:
>
><figure>
><img src=3D"https://www.somedomain.tld/test.jpg&q= uot; alt=3D"test" />
><figcaption aria-hidden=3D"true">test</figcaption>= ;
></figure>
><p><img src=3D"https://www.somedomain.tld/test.= jpg" /></p>
>
>See https://pandoc.org/MANUAL.html#exte= nsion-implicit_figures
>
>
>On Sun, 11 Jun 2023 at 16:54, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:
>
>> On 06/11/2023 09:51 AM, BPJ wrote:
>>
>> An image will be wrapped in a `<figure>` 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/666= 4b0b0755e7ebe9007de4d1426d400
>>
>> Den s=C3=B6n 11 juni 2023 04:26H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> skrev:
>>
>>> On 06/06/2023 03:14 PM, H wrote:
>>>
>>> On 06/01/2023 04:34 AM, 'William Lupton' via pandoc-di= scuss 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.h= tml#traversal-order
>>>
>>> In writers, you can choose to call doc:walk(), which will hono= ur
>>> '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 alwa= ys
>want the
>>> contents of a <div> to have been traversed before you ad= d '<div>'
>and
>>> '</div>'?).
>>>
>>> With the custom writer shown below, and with an input file tha= t
>consists
>>> of the single line 'Text' (and using my logging module=
>>> <https://github.com/pandoc-ext/logging>)= , 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 {
>>>=C2=A0 =C2=A0blocks: Blocks[1] {
>>>=C2=A0 =C2=A0 =C2=A0[1] Para {
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0content: Inlines[1] {
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0[1] Str "Text"
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0}
>>>=C2=A0 =C2=A0 =C2=A0}
>>>=C2=A0 =C2=A0}
>>>=C2=A0 =C2=A0meta: Meta {}
>>> }
>>>
>>> ...and this with 'topdown' traversal:
>>>
>>> (#) doc Pandoc {
>>>=C2=A0 =C2=A0blocks: Blocks[1] {
>>>=C2=A0 =C2=A0 =C2=A0[1] Para {
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0content: Inlines[1] {
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0[1] Str "Text"
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0}
>>>=C2=A0 =C2=A0 =C2=A0}
>>>=C2=A0 =C2=A0}
>>>=C2=A0 =C2=A0meta: 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 =3D require 'logging'
>>>
>>> local function report(label, elem)
>>>=C2=A0 =C2=A0 =C2=A0logging.temp(label, elem)
>>> end
>>>
>>> -- 'typewise' (default) or 'topdown'
>>> local traverse =3D 'topdown'
>>>
>>> function Writer (doc, opts)
>>>=C2=A0 =C2=A0 =C2=A0local filter =3D {
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0traverse =3D traverse,
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Inline =3D function(inline) >>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0report('inl= ine', inline)
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0end,
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Inlines=3D function(inlines)<= br> >>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0report('inl= ines', inlines)
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0end,
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Block =3D function(block)
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0report('blo= ck', block)
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0end,
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Blocks =3D function(blocks) >>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0report('blo= cks', blocks)
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0end,
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Meta =3D function(meta)
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0report('met= a', meta)
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0end,
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Pandoc =3D function(doc)
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0report('doc= ', doc)
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0end,
>>>=C2=A0 =C2=A0 =C2=A0}
>>>=C2=A0 =C2=A0 =C2=A0return 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 &qu= ot;slightly" complicated
>layout I
>>> want to output from the writer and my thought right now is tha= t I
>should
>>> try to add the <div> and </div> in the right place= s 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 <div></div> need to be a= dded at different
>levels
>>> to achieve the desired output.
>>>
>>> I just downloaded your logging filter to aid in the developmen= t and
>am
>>> also working on formalizing the rules for adding <div>&l= t;/div>.
>>>
>>>
>>> I spent some more time learning more about writing filters and= have
>made
>>> some progress.
>>>
>>> I think the entire logic for adding <div></div> to= achieve the
>desired
>>> layout might be doable in the filter and most of it seems to b= e
>working.
>>>
>>> One thing I found is that when an image is included using the<= br> >following
>>> syntax
>>> ![test](https://www.somedomain.tld/test.jpg)
>>> pandoc wraps the <image> element in <figure></f= igure> which I think
>I
>>> don't want/need.
>>>
>>> How can I get rid of <figure> wrapped around <image&g= t; elements? At
>the
>>> very least I want got get rid of <figurecaption>some tex= t I do not
>>> need</figurecaption> inside the <figure></figur= e> element?
>>>
>>> Got it, thank you and I will look at your code. If I am not ad= ding
>the
>> non-breakable space after the image however, how do I get rid of t= he
>> <figurecaption> element which I do not need (or want clutter= ing 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,<= br> >send an
>> email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.<= br> >> To view this discussion on the web visit
>>
>https://groups.google.com/d/msgid/pandoc-discuss/b189960a-3e0d-19b8-9= 1e2-c16dc88cd595%40meddatainc.com
>>
><https://groups.google.= com/d/msgid/pandoc-discuss/b189960a-3e0d-19b8-91e2-c16dc88cd595%40meddatain= c.com?utm_medium=3Demail&utm_source=3Dfooter>
>> .
>>

It does have alt text and I do want to keep that. I do, however, want to ge= t rid of the <figurecaption> text - is this doable?

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgi= d/pandoc-discuss/EAF5063B-4655-48B3-8961-AF664AE3C94F%40meddatainc.com.=

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.= google.com/d/msgid/pandoc-discuss/CAEe_xxjdOUK-tpNsw65u_v_gNr0nUkF5vfrQc0RQ= yLhJyjtHSA%40mail.gmail.com.
--0000000000004efad405fdfe9e7b--