From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32791 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: Sun, 11 Jun 2023 11:54:23 -0400 Message-ID: References: <2fc450a6-5a16-316c-02c8-8ef055bccd11@meddatainc.com> <93e5b610-66a2-6ac7-1d53-8a04a8314249@meddatainc.com> <853c402b-d9ee-4c9d-8bae-15b20faf7194n@googlegroups.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="------------ABE4D0BAC27D81BF9546F90D" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32223"; 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+bncBCEIZSNSZ4IRBMW4S6SAMGQE45HQQ3A-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sun Jun 11 17:54:32 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-pf1-f185.google.com ([209.85.210.185]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1q8NOh-00085M-VZ for gtp-pandoc-discuss@m.gmane-mx.org; Sun, 11 Jun 2023 17:54:32 +0200 Original-Received: by mail-pf1-f185.google.com with SMTP id d2e1a72fcca58-652e21cc2c4sf2019622b3a.3 for ; Sun, 11 Jun 2023 08:54:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686498870; cv=pass; d=google.com; s=arc-20160816; b=Yg9/HEiNIlmEnybg49QH9iHj9WLXbxy8kCmhIVOBOUcRND6z9l5jfyPR9HvFDO3mF0 kSfCsQs/rUkZgjZEewFRCH4mZ8jcfGzpy8kOQuUU664uopXM4Q/PCkhzWn9p4xTX70Qd flRIyrO4kPrstuV0gbdNwtlVihFWqrjTu70GHrTxnStgF8ZHxpBkyHcEo7eDjB52zg6w ZqY/TrA70MK0Tan6nOour2L2cGT/QVzTlKGHb5iaagxg6eIlJYhMPNJsMO1EhHJs/XR2 om5LFrBw+lh/6MYdHz67W4AIGlwg3ssRX6yMOjozpMdRTljnaTYiZVhuEZfE6InJbmod I/mw== 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=sqxnF8YEznZHftGhE6OKoIwAX8m5UN1525kC63wW4Ws=; b=fevxfBdWHmTkxFvZPjWIcuKf5o2RGTNlw4RZLNrpcRJ50NjOIX9ErdTb4S7Wak1Rw0 NsBZS+w7+o/IX8Ov/UwVxwmyftBF16M0K0TLvGXj0BbtKORfV5whdNqZKJ9BTdmD6+mt xA/u16X0chjXzXTls/PErAc7WamrYRVWI5IHQDK+ptYyALVSWIxf5lL3UzFk0/IQDPm9 QxKCi2zNEj53YxCmTxG/YRemk5CjW9LQa9upGMicwM/Ycw5mrWyZWaaMnMTYmebo9XqT SxwPapatgXVPiLSx3aQ73y5hN1KMokmZkhJL4cFNVuMBFny/rVPVwtM11F34QlIKiEJD Gg8w== 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.194 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=1686498870; x=1689090870; 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=sqxnF8YEznZHftGhE6OKoIwAX8m5UN1525kC63wW4Ws=; b=URvKs95TjgGJW1o2jf7rqkYniL4l3I8yLK1qej7AVVh3+rPMtYArXroC4vlcEVKvgD p4p988p0uksV42Fe+9BUg8fN0ad/XLsNQIjF0eOROs5C+BkxjY8U/knU6hEwv2LEMZGS 1Ac6X50M+La43vLcqfxVpnMLV7yf5VPitysSW0CxnyuqTXJ0LjMybNGDmSSLfU64IxX9 UCEr0WZBFAaj0kUsAfsAC5CwUPbUiSnIgNgAUiOQ4KkuLn3kM47K0o3WD3mF6ZG0q5IR VzMG/fwUNt6gxczvl X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686498870; x=1689090870; 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=sqxnF8YEznZHftGhE6OKoIwAX8m5UN1525kC63wW4Ws=; b=TGtHX8w0APfQp+kNuRcbW5vmCvCPtaeF6SLIj/4501DOsgP3h6odWnjZgSjkFZqPmu EpN7avhg9nR2ywKPBF8H3XCy9vuItm6qRpC1BtkvDg9ngC+7E18bhkYG3u7lxpeeawzz W8xNTiYcBoLjiWBqlJOJS2dwCTZdthoc/NyZTKOsTQ2PnMI8BRpqVB15Se7eKloOGRBN DLmv8/urI9Fw50IyKcr22oit4LU2 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDzW4/oPGm9iOeE+cydY2qd3KzoYdMgUi1nmiZwnbGp1TtvKmYc0 jhONhh6rOvpijQmCeAlvHHE= X-Google-Smtp-Source: ACHHUZ7vvPF01FCL9cpihGy+ZR0trOmKy37+0KihayA9hlQ4HfH9FhM2Uw9dkCSrTly4slbPiE7EYg== X-Received: by 2002:a05:6a00:24cb:b0:658:6252:fe57 with SMTP id d11-20020a056a0024cb00b006586252fe57mr8832594pfv.24.1686498870471; Sun, 11 Jun 2023 08:54:30 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a62:82cd:0:b0:657:1fe5:eb2a with SMTP id w196-20020a6282cd000000b006571fe5eb2als2982957pfd.0.-pod-prod-07-us; Sun, 11 Jun 2023 08:54:26 -0700 (PDT) X-Received: by 2002:a05:6a00:b8c:b0:64d:1451:8224 with SMTP id g12-20020a056a000b8c00b0064d14518224mr9156854pfj.22.1686498865923; Sun, 11 Jun 2023 08:54:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686498865; cv=none; d=google.com; s=arc-20160816; b=ngD8QjrOEfb31u+JGl34UeT5P1WwAyzUIX1LnWvVD5Gc+Cd9rYBK6gWXdNvafoUnvv XoIZly/ZJPKcYXvliI5BOYSwNioouItNFJNSN0LO7UH2fRra1STFucv63hDKZQi9CADp mF/JhxZNBgk5QgZsmkcn3ty8JX6I4PMu/MKzYZ8TUOBpz2dNBySfeS0D1mAIlmrW3Kug 4tXjwyv5/91QcLYNd8ALCc5wytjP+5XIESkWehQ7TVeVVT7Gz2wGeYHpZJYN9w3A9ZHS J5G3o7ItfT9l2zI4ydkbjHjWGd/72HF1NmuIQasbMNuQ64X5n2nMCxGIvjIppZGF35b1 3spw== 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=ahkzi8dzE281kxPZyTi0b26L7+fmbdD7bXAUNYoZP7c=; b=0KAtx+H2ZgmBSCQUSqqA9Ick/0gTIrkIeEGPXZKXxMXpjoyo7IV2ZdveNW178FbWOi QDnnFn6Mw+x0amsXNsxsVGglov5KxnYAA8dtkEZpt6EMggkcVDd5RI7sX3sv1zYAB+Yx JMqb6PCgaOSIxcT8LaNaW+Qw1HvOwzHQ0OExO0ZAeJCSXMbW1Ydz6hhFMUGbsoWYvLRm tFGm3aiOIcmEyvZfdseRccZlUtxg9Vke/lX4SQlUtx+xtS5Al09nTBuB73X4jSEQKhXH wMHaGOPPd5UOQMdEeoEQ7gf0Hgxfbhiv7mfTJQvKbxdstcD9DnHytEPVEdTVEkL1QPgW Ecfw== 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.194 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.194]) by gmr-mx.google.com with ESMTPS id cm26-20020a056a00339a00b00652de67f4d1si347033pfb.6.2023.06.11.08.54.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jun 2023 08:54:25 -0700 (PDT) Received-SPF: pass (google.com: domain of agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org designates 74.208.4.194 as permitted sender) client-ip=74.208.4.194; Original-Received: from [192.168.1.17] ([72.94.51.172]) by mrelay.perfora.net (mreueus004 [74.208.5.2]) with ESMTPSA (Nemesis) id 1MYusu-1qd5Y82CYK-00UpLp for ; Sun, 11 Jun 2023 17:54:24 +0200 In-Reply-To: Content-Language: en-US X-Provags-ID: V03:K1:1eJJDMUhIw5n7zbAzNZWjmVOC0yHa1qJb10aGc2sk+0YxOJaXu6 Xy+nrRTlKaHF84Jq+9LCLuk4zSTlO4iHrM5XtEaW7fKLoIwQiec0Owcg7MsCQwGJJANLePw 8f65zvpTuehd5TSvolDtmGLrNGchKkuEd0NmvTtgSZ/wQuOy0csUUgQTsmW/ZcT3ykdjrp0 yYEGui+5EWTtURT5NxzgA== UI-OutboundReport: notjunk:1;M01:P0:k0vI7rM/3L8=;0Iv8UyVr9UA4AtSELh7txl8s1i5 CLBo+v1VSUxlbyOBR2qASO99mq3tdcOBa5rT0ZVwcI4sH+wjKtX0KGJas6J9zlh4H+7ERUAQg JuD3qUxOsylWehA0kxFZ9BG03oF9wrB4j55KlROucj7qOc0f0dO5X5q5rShBfDzPmxUbO6Jsy jmigf4HKtL33OkHmij02Q71lDCeQhDF8UhSGtkrTuiuxtZ6Yc42ikZDlhHDngTwJgHHjiwo2i sF5/xOm3JzO+GfI+zTcboLHSk07rcc2XESahqSnFYDGngHdQQmlMinI0A5jCJhSuYodprp0LA 29XiN12y3DHAa1oP0dzAOVOV/KQ9aFRSL2CAwtI7G2QR7nQJOkyZFm7FY8U4BgJlNy5NC90ng N3b2/jFrr1Yo5xotPlxRd5WWwOZbz4CzZk4DqsGBVWuWD+ffk6b8eWF2O2P3MF4jMdxlCWbOg A18DqjARRrt4vMfQo/SdzvI3mqp9AUsg9CeI3NaXDsigpAIkWct1sBQpz4cuMvqdobI9rNHSn h8llQvzsfPxyo4tuX5w838IeMOfNzJKkTIJ0Mv/IM2QMjGJNS8ElkjRVlW8kTxLsRBBpL2sad s66YyBjlfJbQwwUuRdtBXUd/sW4FmSow/4bLM/1YEE9WYO05d8N5SzJF/F6ABjMEhFdZeMp2m IeqU35Oe5Izm+OnrSydkoOUlqY6CedeJSWqpDh00UA== 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.194 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:32791 Archived-At: This is a multi-part message in MIME format. --------------ABE4D0BAC27D81BF9546F90D Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On 06/11/2023 09:51 AM, BPJ wrote: > An image will be wrapped in a `
` when it is the only thing in a p= aragraph, 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 o= r used always to so to speak implement a better syntax where you clearly ma= rk 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 reall= y mean "writer"? >>> >>> In filters, you can use the 'traverse' field to force top-down trav= ersal. See https://pandoc.org/lua-filters.html#traversal-order >>> >>> In writers, you can choose to call doc:walk(), which will honour 't= raverse'. See=C2=A0https://pandoc.org/custom-writers.html#example-modified-= markdown-writer (and example below) >>> >>> However, if you use=C2=A0pandoc.scaffolding.Writer (as I think you = are?) then I suspect that you can't control the traversal order (but I'm no= t sure that it makes sense to do so, because, for example, surely you alway= s 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 con= sists of the single line 'Text' (and using my logging module ), you get this with the default 'typewise' traver= sal: >>> >>> (#) 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 blocks: Blocks[1] { >>> =C2=A0 =C2=A0 [1] Para { >>> =C2=A0 =C2=A0 =C2=A0 content: Inlines[1] { >>> =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 meta: Meta {} >>> } >>> >>> ...and this with 'topdown' traversal: >>> >>> (#) doc Pandoc { >>> =C2=A0 blocks: Blocks[1] { >>> =C2=A0 =C2=A0 [1] Para { >>> =C2=A0 =C2=A0 =C2=A0 content: Inlines[1] { >>> =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 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) >>> =C2=A0 =C2=A0 logging.temp(label, elem) >>> end >>> >>> -- 'typewise' (default) or 'topdown' >>> local traverse =3D 'topdown' >>> >>> function Writer (doc, opts) >>> =C2=A0 =C2=A0 local filter =3D { >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 traverse =3D traverse, >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Inline =3D function(inline) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 report('inline', inline) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 end, >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Inlines=3D function(inlines) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 report('inlines', inlines= ) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 end, >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Block =3D function(block) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 report('block', block) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 end, >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Blocks =3D function(blocks) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 report('blocks', blocks) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 end, >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Meta =3D function(meta) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 report('meta', meta) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 end, >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Pandoc =3D function(doc) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 report('doc', doc) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 end, >>> =C2=A0 =C2=A0 } >>> =C2=A0 =C2=A0 return pandoc.write(doc:walk(filter), 'html', opts) >>> end >>> >> Thank you for your thoughtful response. I realize I have used the te= rm '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 l= et the writer just output the resulting html. >> >> I may have to traverse the AST several times in my filter to accompl= ish the result since multiple
need to be added at different lev= els 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 m= ade some progress. > > I think the entire logic for adding
to achieve the desire= d 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 followi= ng 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)? --=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/b189960a-3e0d-19b8-91e2-c16dc88cd595%40meddatainc.com. --------------ABE4D0BAC27D81BF9546F90D Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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.


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 https://pandoc.org/lua-filte= rs.html#traversal-order

In writers, you can choose to call doc:walk(), which will honour 'traverse'. See=C2=A0https://pandoc.org/custom-wr= iters.html#example-modified-markdown-writer (and example below)

However, if you use=C2=A0pandoc.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), 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 blocks: Blocks[1] {
=C2=A0 =C2=A0 [1] Para {
=C2=A0 =C2=A0 =C2=A0 content: Inlines[1] {
=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 meta: Meta {}
}


...and this with 'topdown' traversal:

(#) doc Pandoc {
=C2=A0 blocks: Blocks[1] {
=C2=A0 =C2=A0 [1] Para {
=C2=A0 =C2=A0 =C2=A0 content: Inlines[1] {
=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 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)
=C2=A0 =C2=A0 logging.temp(label, elem)
end

-- 'typewise' (default) or 'topdown'
local traverse =3D 'topdown'

function Writer (doc, opts)
=C2=A0 =C2=A0 local filter =3D {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 traverse =3D traverse, =C2=A0 =C2=A0 =C2=A0 =C2=A0 Inline =3D function(inlin= e)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 report('inl= ine', inline)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 end,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Inlines=3D function(inlin= es)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 report('inl= ines', inlines)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 end,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Block =3D function(block)=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 report('blo= ck', block)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 end,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Blocks =3D function(block= s)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 report('blo= cks', blocks)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 end,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Meta =3D function(meta) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 report('met= a', meta)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 end,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Pandoc =3D function(doc)<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 report('doc= ', doc)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 end,
=C2=A0 =C2=A0 }
=C2=A0 =C2=A0 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 <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.somedomain.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 &= 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/b189960a-3e0d-19b8-91e2-c16dc88cd595%40meddatainc.com.
--------------ABE4D0BAC27D81BF9546F90D--