From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32800 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: H Newsgroups: gmane.text.pandoc Subject: Re: Wrapping sections of text with
in custom filter Date: Tue, 13 Jun 2023 13:28:00 -0400 Message-ID: References: <2fc450a6-5a16-316c-02c8-8ef055bccd11@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="------------2D145FAA1008BC72F5442AA0" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14125"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCEIZSNSZ4IRBIWOUKSAMGQEQEZJ2BQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Jun 13 19:28:08 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-yb1-f184.google.com ([209.85.219.184]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1q97oO-0003Un-9F for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 13 Jun 2023 19:28:08 +0200 Original-Received: by mail-yb1-f184.google.com with SMTP id 3f1490d57ef6-bd69bb4507esf380595276.2 for ; Tue, 13 Jun 2023 10:28:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686677287; cv=pass; d=google.com; s=arc-20160816; b=B2sr1Dr1SikgU/Nxuhs2T6F8UUG7X7WnTe8mC50VwzGsVDAhoEuyP7EgIWcDY044bD EyBSRhEyi87sRqyTuNQ5PUogSrv7UqJQ8EOXJN6/pSqpGfNsyEwZciXkcgPgoiM1/4HY kNf2QeZCh2WJVkJxdcRXLSvTpvvXEZ7j2puuL4b4A41xKebkqbBOu8flTCR0NQNjA4zV xr12zxi24v1cFFX2tbmBI8o1/Krj//q/lSzs3pg1SsgggTaj3A9rDzYyQQS8MmKSjwik jyYolDnbZ1bkHlPwAahh0mOg8j8RN5fp8n8Hc2/Lq7DCQFuMKhfSiUZs+gNZca4LoAuz AzJw== 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:ui-outboundreport :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:sender:dkim-signature; bh=d+iqOnuU7YKNFAMmm0S6AZS/qmZ1eGm5aWFdcxTRc7Y=; b=IASKrQ5NHA/C1EtHKxuUVZD3sCg5cOMWFJBluaMKYbwfFZC9zhY3zFEpgaIVXaIUDy n8SbbgI5X2iBMMObe2h+2MCX7gLaaA3eytEiM8hhq2AMcjh6EI+/B32QLfiZA1/zONVr dJf2RE5GGitcCe6GyS40MR88W1hsMlh9/sCuAZrpdNrpWOEmMBec0XHUm+Xl9kfdTwrx lRZnqow3HSvgCj1zEULBFzBSz6hnG/KNcv5r7RiM0bsZnhNTkbVTQqawjkkfCBsUbxCM cqOzb3Bo+I18CMrrp79mYfHVfXGSw00CxXWJrM6NzeNWLn5Bzk+JiwIcZ15aycA8Mrjq cR8A== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org designates 74.208.4.197 as permitted sender) smtp.mailfrom=agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=meddatainc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1686677287; x=1689269287; 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 :ui-outboundreport:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject:sender:from :to:cc:subject:date:message-id:reply-to; bh=d+iqOnuU7YKNFAMmm0S6AZS/qmZ1eGm5aWFdcxTRc7Y=; b=fx3iOGb0J554lPbcca1JbFsCAVdlmWUQ+1hrkDOi6hRhSfzw7p8whzT1bibiyN1GuY J8bWwN+Hanu4bWx4w/Vt/GqYZj+9TgNIbRx8HDYh+ue8Q7Z+YpAbjtcvNdj9q4nZrVx6 kjIEfqAs0hcwEzcXwvQry1CgOh4eNgXdGkT+0wRqqKRer9scCEN/5crAsyepZ+odQGZC G1qhMc9vvkQx1ZRvf3KthiRPpajovCSR//Rij2GyC51J02EZqrUBBAUzWih0tPg1ehyX pn+SYlDteIoMyH1Jg X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686677287; x=1689269287; 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 :ui-outboundreport:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject:x-beenthere :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=d+iqOnuU7YKNFAMmm0S6AZS/qmZ1eGm5aWFdcxTRc7Y=; b=Rbc15ywO4BJh9sKcpAb8+6QjyZf/gTych86S0+hDYHoZsg6ApLiE6hwoeBFyRv5cxM qq/CvX+leHFoRkWgYcCpXkdtP7tnMLuYJpDHFMt5oaNMZL7kTyQx+l68Lgt0hOxpRa/2 uTeum79aZL6ofANVnhi0Pb6qvVm+JHNy/LK8+ufc1RadNVb03IA3t7Y42zbvTjJj+9IH 4QDTeVT1aF7RVGdBV/ktv3Pib/mW Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDxFLbKGIidLEq3r+ZNgo0xujgKrd3tOYu1U3wwbVJCaZI4gFc2P g+rtnO/CZ674r3Cpgcy/YXk= X-Google-Smtp-Source: ACHHUZ5GbKK+xgwdYaN98cPFwN+MWR6blXZX20j2C9s28/iMsFW44JXxwAq84AoQp4qs5UONpydY/Q== X-Received: by 2002:a05:6902:512:b0:bc7:d7ba:4e8b with SMTP id x18-20020a056902051200b00bc7d7ba4e8bmr2508146ybs.13.1686677285914; Tue, 13 Jun 2023 10:28:05 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a25:4009:0:b0:bc3:f09f:1d92 with SMTP id n9-20020a254009000000b00bc3f09f1d92ls783534yba.0.-pod-prod-01-us; Tue, 13 Jun 2023 10:28:02 -0700 (PDT) X-Received: by 2002:a25:b118:0:b0:ba8:5a5a:8b23 with SMTP id g24-20020a25b118000000b00ba85a5a8b23mr2590708ybj.40.1686677282191; Tue, 13 Jun 2023 10:28:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686677282; cv=none; d=google.com; s=arc-20160816; b=xxG9WC+TD6vRnF0my0kyzxRTcsly8PxkPT5G7XuWoOwbPaeGeVLeA0oy0lAcm2EZp6 uAnPJ3JKNemQKETWc9zdh4n3XtCLpSZoLKorPEzr6gSKtr3pPa+5H+K+7D7Xo2zESPeV PRRGKs+1Cha++OhH3b/KqAfVCnevkqTc8Yh2jl/omxGwDaULAfy77r5/t/RFKwQRGoGs mDT22vSxIWEpnJ4UnYCStFOgFYNGmts0u1y9qF64TLWzWuaHLLRhq8UHjtuzJ3IbQYhs TPP1qdztnAvQYqTr5ZDQRlmJYEBaDLnj9LDxwJ0glfLQAuVnXUqlUE4/p4jo899IArp7 HL1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject; bh=sRgFYBZOLYFGsiGGnyrwWN8zy7zPc89TsFpo5+Hnf1I=; b=Vi0qrTMqkMAMSh2+0iy6ApBs0+9bsvJjtIdWKoZ31zhMqO03aV5I6kC0UBLdHbCbrK 5r1YMGNJqtcL7NRdEgLCd2pIcXDfdxhGbONviJ72yq82WPK/8UhYtwFJQ44ByTn3oL0N SvN5bMkLOXO4s+eXfpScNNzX2ab9p3dvTeKaiNWNSw7nrge7msP/g6kDplByT1J4ugMA YIhhqQoeHVtN7wTDN5qCAAxmg6hDBThCpeF5xDcCHWJkiJs1BseN4FDaOuiG9arSyofj mNAQfANlwZqJpwmQumeEGF3BB/Mxkscq3Kw8tagbr5BpHHogRxG1naAnrNlwQutxQvIb gGJw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org designates 74.208.4.197 as permitted sender) smtp.mailfrom=agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=meddatainc.com Original-Received: from mout.perfora.net (mout.perfora.net. [74.208.4.197]) by gmr-mx.google.com with ESMTPS id h4-20020a25d004000000b00ba7249f1c3csi1141921ybg.3.2023.06.13.10.28.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 10:28:02 -0700 (PDT) Received-SPF: pass (google.com: domain of agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org designates 74.208.4.197 as permitted sender) client-ip=74.208.4.197; Original-Received: from [192.168.1.17] ([72.94.51.172]) by mrelay.perfora.net (mreueus004 [74.208.5.2]) with ESMTPSA (Nemesis) id 1N5FYf-1q1ao002r7-0117SL for ; Tue, 13 Jun 2023 19:28:01 +0200 In-Reply-To: Content-Language: en-US X-Provags-ID: V03:K1:Apacr4X1Jkn6q6WHkTwtS00nwWFYaW62vG68paWxT1MOAOLJwop qSrwFYaICzXxT2eSyxda7Bzx8OxjhL1jDbcfX2NSkJHwuJtnVIVhqJDViMy/Pk9AJRGX8uT se4F/PRk7+ISMKDbTwP/f9v1LKKUzXOsWgjgBCT3GJ69q7UONL2XruSDNhZEefoj/qinlQ0 JwWnUWVG8ZWrYQswbKGoA== UI-OutboundReport: notjunk:1;M01:P0:dlhQ7K+/Zm8=;COEEV15Huon9rBk/KJvbs8yy4jU pI+ozEpI4Zv/sOnn6FnA3ZVv4wv21o6iBmJQ4dSjPLyNXCbzUGZeLqgtgUKB2E62iskjL/J26 Ffz0uYxwwzU5s9p/g94ZMhXgK/LdyAJVR8qbZwrPGKEc5GgFVOgcPBvEsAT7EpTqUfw95jtJr 6W0d2b/RbMCuA/93Dp3hW5/lCu5sj4XB53RIpygZrxElta8ylJft8zyhQZM4/DfKAcM/+6fzb 3rNyDe5grg73cONldlobk3OJYuf6kg0ft7VWIZIQzGtt78pXMTNI5F+sqByA2x0aZzIZfbCan /flbv3OSZOBpfZHN39cgsH8tNlt3p//QHrMYTUzkehjd+3wHEkrlAof0QJvX2EOXwIT8tQNi2 jgbMbGi5Y7ri6+368aW2NU77vhehEkt/nnaYs1BE2Hcshl+m6mX4fwjj6rkW3JrsemZhxeGAy HH9QvODAecA5AE+azoHm8CzzFU7+8vqV3G+3ztRwc51DH/aReWBcBb614lDaJfYRddMFzH/P+ 2O5fAgeG9OT/ttQuyQXtcdkzFCISDvFJckWBI2ggJiCOKgwuYRFbD4NMdDa9eZnAgAxDAVMis 0e0HbCkYDxo2QUdD5ROT9e9sIsO87odVqWVyC7WZasASfWsOKNBewDBe5r+N21Fgg2k+jVfvv VADebYgFOUD9OFKs0M2/42KrpBubTjr9TRIrV8rdQw== X-Original-Sender: agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org designates 74.208.4.197 as permitted sender) smtp.mailfrom=agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=meddatainc.com 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:32800 Archived-At: This is a multi-part message in MIME format. --------------2D145FAA1008BC72F5442AA0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On 06/13/2023 04:28 AM, 'William Lupton' via pandoc-discuss wrote: > This lua filter will remove the caption: > > function Figure(figure) > =C2=A0 =C2=A0 figure.caption =3D {} > =C2=A0 =C2=A0 return figure > end > > (It didn't work to set figure.caption to nil. This seemed to have no effe= ct. 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 elem= ent > >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 rea= lly > >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-wri= ter > >>> (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 { > >>>=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('inline', i= nline) > >>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0end, > >>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Inlines=3D function(inlines) > >>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0report('inlines', = 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('block', bl= ock) > >>>=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('blocks', b= locks) > >>>=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('meta', met= a) > >>>=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 "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 a= nd > >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 differe= nt > >levels > >>> to achieve the desired output. > >>> > >>> I just downloaded your logging filter to aid in the development a= nd > >am > >>> also working on formalizing the rules for adding
. > >>> > >>> > >>> I spent some more time learning more about writing filters and ha= ve > >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 thi= nk > >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 no= t > >>> need inside the
element? > >>> > >>> Got it, thank you and I will look at your code. If I am not addin= g > >the > >> non-breakable space after the image however, how do I get rid of t= he > >> 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. --=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/c11494eb-470f-e0bd-7d93-be6b4f75db7d%40meddatainc.com. --------------2D145FAA1008BC72F5442AA0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On 06/13/2023 04:28 AM, 'William Lupton' via pandoc-discuss wrote:
This lua filter will remove the caption:

function Figure(figure)
=C2=A0 =C2=A0 figure.caption =3D {}
=C2=A0 =C2=A0 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 <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:
On June 12, 2023 5:09:20 PM EDT, 'William Lupton' via pandoc-discuss <pandoc-discuss@googl= egroups.com> 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](h= ttps://www.somedomain.tld/test.jpg)
>
>![](h= ttps://www.somedomain.tld/test.jpg)
>
>...gives this HTML:
>
><figure>
><img src=3D"h= ttps://www.somedomain.tld/test.jpg" alt=3D"test" />
><figcaption aria-hidden=3D"true">test</figcaption>
></figure>
><p><img src=3D"https://www.somedoma= in.tld/test.jpg" /></p>
>
>See h= ttps://pandoc.org/MANUAL.html#extension-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.
>>
>> h= ttps://gist.github.com/bpj/6664b0b0755e7ebe9007de4d1426d400
>>
>> 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-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 h= ttps://pandoc.org/lua-filters.html#traversal-order
>>>
>>> In writers, you can choose to call doc:walk(), which will honour
>>> 'traverse'. See
>>>
>h= ttps://pandoc.org/custom-writers.html#example-modified-markdown-writer<= br> >>> (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 <div> to have been traversed before you add '<div>'
>and
>>> '</div>'?).
>>>
>>> With the custom writer shown below, and with an input file that
>consists
>>> of the single line 'Text' (and using my logging module
>>> <h= ttps://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 traver= se,
>>>=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=A0repor= t('inline', inline)
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0end,
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Inlines=3D function= (inlines)
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0repor= t('inlines', 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=A0repor= t('block', 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=A0repor= t('blocks', blocks)
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0end,
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Meta =3D function(m= eta)
>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0repor= t('meta', 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=A0repor= t('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(filt= er), '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 <div> and </div> 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 <div></div> 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 <div></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 be
>working.
>>>
>>> One thing I found is that when an image is included using the
>following
>>> syntax
>>> ![test](https://www.somedoma= in.tld/test.jpg)
>>> pandoc wraps the <image> element in <figure></figure> which I think
>I
>>> don't want/need.
>>>
>>> How can I get rid of <figure> wrapped around <image> elements? At
>the
>>> very least I want got get rid of <figurecaption>some text I do not
>>> need</figurecaption> inside the <figure></figure> 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
>> <figurecaption> 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+unsub= scribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
>> To view this discussion on the web visit
>>
>h= ttps://groups.google.com/d/msgid/pandoc-discuss/b189960a-3e0d-19b8-91e2-c16= dc88cd595%40meddatainc.com
>>
><h= ttps://groups.google.com/d/msgid/pandoc-discuss/b189960a-3e0d-19b8-91e2-c16= dc88cd595%40meddatainc.com?utm_medium=3Demail&utm_source=3Dfooter&g= t;
>> .
>>

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

--
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/ms= gid/pandoc-discuss/c11494eb-470f-e0bd-7d93-be6b4f75db7d%40meddatainc.com.
--------------2D145FAA1008BC72F5442AA0--