From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32745 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, 6 Jun 2023 15:14:11 -0400 Message-ID: <7878b22d-bf64-2d25-1136-d9f9cf5e135b@meddatainc.com> 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> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------7FAF6CC8E08CDA79202DC86F" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39047"; 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+bncBCEIZSNSZ4IRBBUL72RQMGQE737HGOY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Jun 06 21:14:18 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-yw1-f183.google.com ([209.85.128.183]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1q6c8I-0009v2-Et for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 06 Jun 2023 21:14:18 +0200 Original-Received: by mail-yw1-f183.google.com with SMTP id 00721157ae682-564fb1018bcsf105546017b3.0 for ; Tue, 06 Jun 2023 12:14:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686078857; cv=pass; d=google.com; s=arc-20160816; b=PkkAOp6o3Oir7W3Q2fRgrjswr+bhUe+qJtD6DxCwQbDdAq75uC6z2VcGDxzHquQMKm LBZlGhj+V/0XWW/vvSpdjW9IPD5G/yfVNRrApY0voRDsW4hhxjaJXsjnFJ/OXCTgR/Ur tHDmYYVb2O/I9QUUmbsNkanTJkW1XIo7p/6Vdcsytm3gluAAEEmR8zpnYuZvipNGX/pM kAN4JTH/gRZJhqZB7ojHX63Ebt+YuSILTMt29lanDFDZi8fhJPcrcYb70qvDCC7kDxQN b17JyJRGcd6JLEFK7wEwUme1cwe4xWyko1f25c4Mapkt1CSq+/ESks9IDl5Oxi04fezA xyUg== 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=32G4UuJpf4Nge5c3/jHVTYN1J7z4xA28Dio1gZbfuQw=; b=KrF1SqFOJEthAaQStb34V7sozCidW8445HR1VJtACQnfrD9QcbcrC/TojJQtoU1G3S fLRipj70H/8y8zftjX9xYBZw6xVCuM59UkzHc9S5zkaXqetptm8uGrO3TPeMc52rMAcs DKvm3RMMH6xU4+olzKBx0YoA8aenkUJsY7nHLsdgTEHp66Mi4xAijLqj4RpLaGNDXR0h xw7MQtxR49Mci629PLNeExL/5JzCE9mCe6FGObyRsFTdKFAv4DDWCMbzkjKz9WihKe0T NeztbX70HAHnCROB10om4qHR2Mmak+xHAJ6x1oy1/IJs8CvcLiyEpGA7L6B7yIi7cCMM y5SQ== 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=1686078857; x=1688670857; 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=32G4UuJpf4Nge5c3/jHVTYN1J7z4xA28Dio1gZbfuQw=; b=IFypZ/wWgTwBf12feHjp3f/AfEHKylHErzAkuQJv92rq4Cxg2j26s50ApE0sYU3n4S d5EKym9WgQL1JuVjw4n4Ho6mebtEivekpffNR3Vl3I2/4rDbL7gqR74dYyshbmImSZWP dxxQ/JUjw7Dr5KMiD3oBwLObA7RgcJW5V15fKDDMQDUdzyntI+R2BHDE6ZXk/+OjqgUU 1XCHXrXk/x7f/bP3DHqR/0+IxQVvs0axcGUns6fr8qgKSSNlx02M+GwBM6Isx/bwmEdj 9H0l/JEf5krHJ+Xwo X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686078857; x=1688670857; 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=32G4UuJpf4Nge5c3/jHVTYN1J7z4xA28Dio1gZbfuQw=; b=NZyTiazsaEFCc1KR7tCMIUXNRG54Z45GyWLX3YUINqaq6zf1XJPfojmz5ucGQV/e70 YZR79KuZXlUnXWYEisGlqJ7vDDUiFECYO8lLGKpKbrvLu0UWPzMn9GRLB8yBMuuh+Mq2 B2ZYsZHWvppNLhzd9UiogLCD4ufLy1vt0uUne5F5y+J5jW5N0SyABsyWk643J7q9wvvh HTGh09VOnQ0sL9VJLR0lCr5km/4u Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDziDzNT5WoPU2dGsOB3zxH+s9C9hdeuxLwXeDVeY91HaXmLkjJG 7LGlZe8Ts2TD2uhJD6lFv/M= X-Google-Smtp-Source: ACHHUZ5PpL/LwlbMUJ4nMIqEgOH6ra7cU55dG/8vVvVop1OymMT7vSCKY+EhQbUQZYUIr8SoiEYNow== X-Received: by 2002:a81:6546:0:b0:568:b10a:e430 with SMTP id z67-20020a816546000000b00568b10ae430mr3441971ywb.25.1686078857188; Tue, 06 Jun 2023 12:14:17 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a25:506:0:b0:bad:1018:2419 with SMTP id 6-20020a250506000000b00bad10182419ls1490766ybf.1.-pod-prod-07-us; Tue, 06 Jun 2023 12:14:13 -0700 (PDT) X-Received: by 2002:a81:7306:0:b0:565:ead5:a126 with SMTP id o6-20020a817306000000b00565ead5a126mr3296239ywc.46.1686078853604; Tue, 06 Jun 2023 12:14:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686078853; cv=none; d=google.com; s=arc-20160816; b=CXKImzFVigdvlJm0r+MZHp4qyHaL082NOOciVeoPdxvLy5fJ/JBWtkvDBvvnHWiPmP gmaShM2tyQZnPGObGYV4dXhu1+Uf8wXga8Cnbg11VgpGXlNVH2CuepXQcZv49ewSATzU 85YzAJ1TSm/FikSLXf9U4lAwQvioJQ20CBZ6kQ310UiQwwcA2TaN8n3k7FMyRjH4j1/3 C6ssmdZiDDRO4K7Du2VNInFmuzdfrgAknpAer2oeDXQZ3+2+UyRV7NRSTqZpXLsmO91W H/ylSqv18tIEv7WVVYaPLaQx+Q32Xlgi0v8x4QylPeF2mtZVWrvW/fvSXhzvAPqUw52v LfkQ== 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=c0yHO0BccPKtaJmFhUvu66QrsvdaM2uPhqHJbMTZ62k=; b=TGwYp/4u5KXr55oL7DDhVX6HIlhv74q9d7LY8d8unBQHxLm0wF12FfHu6J3eZCUhp0 +DgMhHlfgA5arkjnobBHzJJEI3Wr7sbkCjhvzJRgwXxMT+CRWDTtpYrU7Neq1XvT9MKF N9TqqXYjYuJb4y+NeghmvH7DWu8GvjSpQfui4478SoD9lZnIKlJV4OCarct3T8MUiuOr gQop/aoBHn9OGpSU6fKibVrpCSXdg6ernEJ1w9UccthUtH2s8tLv4cjCuHVANx+kDmHq 94kJvhTYernwEHKjHKA2qqUScZLWngJJmJX+ukQ3l+p5UCppwtB185KaBHowDoi00K3N vjSg== 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 cl27-20020a05690c0c1b00b0056974f3f27dsi744086ywb.4.2023.06.06.12.14.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 12:14:13 -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 (mreueus003 [74.208.5.2]) with ESMTPSA (Nemesis) id 0M6Syb-1qGkKl27WF-00yUXy for ; Tue, 06 Jun 2023 21:14:12 +0200 In-Reply-To: Content-Language: en-US X-Provags-ID: V03:K1:oFSFLik8MNw+3SXD/HHdaA/rJYhgtiNWItTOMZPU2+OGnGP68XB aUPhuqOBjLFyS3SkpAfRekcnzBbDub0fvoBOFPoMKPhIqaPTwcasfSxCvZoG7ZuWke91PJi +L/e0N9dIR7Wpvl0HfQPIgOef4HoBkJxGeg1PKowuKYwTFwR2mf9c2jSsXVU2nqhjdeE/Ts tH7uEUp7zSmT4tRokUFZQ== UI-OutboundReport: notjunk:1;M01:P0:W+tK+1D1yUI=;rZUipf1nGm6TkCESEepT2crMx4u Mln6aFfWRb/AqkccvWioXiJ0KG1yluvV095LAs2ufD6MhQBZneYHAyvbeNQRic3Fxz/RNRHFB f0R6RgkVMBolxwuUUIFkDNlqrqsVdCecZChFDB5nF+SxczXw8iNoPOp62IAPNZZb/SLL17Hiu Ul9QkWmCgUwMhs4H/9gEXJnN3dWwLiZZ6UtVMm2+HjjCUuqD6JnTmVE7iP9aLJaR/KRK7ted/ Q3my4BQ9SgsmrNEUkpYv0EP1XMjzV6p+2LVoNXjtqCFiYfpAT+tmfTvhe0jNmSEDg39TPkxz3 4qCEprxpCmde48mWkBuC7MiJAeVv3YDIicm7fHGBnrlxuk21ueIOsJyo5mJub6Wdm0D62jO2m ggVcaRodMNSOKER6LcKY+XRUCfHHm5dl72i/NPEM/doEfO3+vBbWCH5JZ461XMQdrwDpO8kcR j64hrd3dlNNkvSljEGMqGTcvPj1FxxUOE6KmtVHQ1A+mH7Da7WN6hX5+AXAj2E088jxqo1UDH d5ewGIaPMQIDHfcaufh09Adi/SSFS5UQuxXxNJ+2sUpx8mvZqHcWs17hk9JINLDSezj/RfSuQ 2WYXeky2HEBwigXSo+oIfmIfX3IdTkwqRobmCy4xR+4ZvNdBHdYUpG7daBEpGPxb/6q1YClXg WtF5UkOg8Lqg1fjCqcezDLOWZ1DupAZduozq8/gjUw== 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:32745 Archived-At: This is a multi-part message in MIME format. --------------7FAF6CC8E08CDA79202DC86F Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 'travers= e'. See=C2=A0https://pandoc.org/custom-writers.html#example-modified-markdo= wn-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
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 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 > > On Tue, 30 May 2023 at 20:23, H > wrote: > > On 05/30/2023 02:30 PM, H wrote: >> On 05/29/2023 12:31 AM, H wrote: >>> On May 28, 2023 8:50:56 PM EDT, H wrote: >>> >>> On 05/26/2023 03:43 PM, H wrote: >>>> No CSS (I had mentioned that in a previous message), also no m= odifications to the markdown file so the entire interpretation of layout, a= dding style information etc. needs to be in my custom PDF writer. This cust= om writer will - obviously - be specific for this single dedicated use by m= yself. >>>> >>>> Any pointers (links, code fragments to look at etc.) as to how= I should traverse the tree to be able to output my custom PDF would be gre= atly appreciated since this will be my first pandoc writer. >>>> >>> I am making some progress working on my custom writer for my de= sired html output layout. I am using the 3.0 syntax where the output functi= on looks like >>> >>> Writer.Pandoc =3D function(doc) >>> =C2=A0=C2=A0=C2=A0 return Writer.Blocks(doc.blocks) >>> end >>> >>> At the start of my document I also have >>> >>> Writer =3D pandoc.scaffolding.Writer >>> >>> with customization added for inlines and blocks added. >>> >>> In the Writer.Pandoc function above, is there a way I can see e= xactly in which order the document is evaluated? I am interested in explori= ng traverse =3D 'topdown' vs. traverse =3D 'typewise' as I think the topdow= n traversal will be required to add the necessary
and
in the c= orrect locations to my final document. >>> >>> Again, please bear in mind that I will do /all/ processing in t= his my custom lua writer. >>> >>> Thanks. >>> >>> >>> Upon further reading, it looks like the traverse directive might on= ly be applicable to filters when the AST is being processed >>> >>> Is this correct? If so, is there anyway I can view the traversal pr= ocessing sequence in my filter when I am writing and debugging it?=20 >> >> Hoping someone can shed some light on the 'traverse' directive and h= ow I can debug my filter using different 'traverse' directives. >> >> Thanks. >> > Upon further experimentation, it looks like outputting to 'native' fo= rmat, ie the AST tree after running a filter will show me what the modified= tree looks like. > > It would have been nice to have some version of 'verbose' to apply to= a filter to see in which order elements are processed. > > > --=20 > You received this message because you are subscribed to the Google Gr= oups "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, sen= d 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/05ba5663-1578-d555-8539-d6a2bdff6743%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= email 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/CAEe_xxhTjZJRuNZFtYMqh1eSNM9yobfgs_YTj2muxs1px0ygjg%40mail= .gmail.com . Thank you for your thoughtful response. I realize I have used the term 'fil= ter' 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
. --=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/7878b22d-bf64-2d25-1136-d9f9cf5e135b%40meddatainc.com. --------------7FAF6CC8E08CDA79202DC86F Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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#tr= aversal-order

In writers, you can choose to call doc:walk(), which will honour 'traverse'. 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 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(inline)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 report('inline', inli= ne)
=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', inl= ines)
=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', bloc= ks)
=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)<= br> =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', opt= s)
end


On Tue, 30 May 2023 at 20:23, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:
On 05/30/2023 02:30 PM, H wrote:
On 05/29/2023 12:31 AM, H wrote:
On May 28, 2023 8:50:56 PM EDT, H <agents@m= eddatainc.com> wrote:
On 05/26/2023 03:43 PM, H wrote:
No CSS (I had mentioned that in a previous message), also no modifications to the markdown file so the entire interpretation of layout, adding style information etc. needs to be in my custom PDF writer. This custom writer will - obviously - be specific for this single dedicated use by myself.

Any pointers (links, code fragments to look at etc.) as to how I should traverse the tree to be able to output my custom PDF would be greatly appreciated since this will be my first pandoc writer.

I am making some progress working on my custom writer for my desired html output layout. I am using the 3.0 syntax where the output function looks like

Writer.Pandoc =3D function(doc)
=C2=A0=C2=A0=C2=A0 return Writer.Blocks(doc.blocks) end

At the start of my document I also have

Writer =3D pandoc.scaffolding.Writer

with customization added for inlines and blocks added.

In the Writer.Pandoc function above, is there a way I can see exactly in which order the document is evaluated? I am interested in exploring traverse =3D 'topdown' vs. traverse =3D 'typewise' as I think the topdown traversal will be required to add the necessary <div> and </div> in the correct locations to my final document.

Again, please bear in mind that I will do /all/ processing in this my custom lua writer.

Thanks.


Upon further reading, it looks like the traverse directive might only be applicable to filters when the AST is being processed

Is this correct? If so, is there anyway I can view the traversal processing sequence in my filter when I am writing and debugging it?

Hoping someone can shed some light on the 'traverse' directive and how I can debug my filter using different 'traverse' directives.

Thanks.

Upon further experimentation, it looks like outputting to 'native' format, ie the AST tree after running a filter will show me what the modified tree looks like.

It would have been nice to have some version of 'verbose' to apply to a filter to see in which order elements are processed.


--
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 https://groups.googl= e.com/d/msgid/pandoc-discuss/05ba5663-1578-d555-8539-d6a2bdff6743%40meddata= inc.com.
--
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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.org= m.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-d= iscuss/CAEe_xxhTjZJRuNZFtYMqh1eSNM9yobfgs_YTj2muxs1px0ygjg%40mail.gmail.com= .

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


--
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/7878b22d-bf64-2d25-1136-d9f9cf5e135b%40meddatainc.com.
--------------7FAF6CC8E08CDA79202DC86F--