From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32795 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: Mon, 12 Jun 2023 17:18:31 -0400 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: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35333"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: K-9 Mail for Android To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCEIZSNSZ4IRBV4XT2SAMGQEUYCQ35Q-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon Jun 12 23:19:24 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-pg1-f186.google.com ([209.85.215.186]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1q8owe-0008tr-GP for gtp-pandoc-discuss@m.gmane-mx.org; Mon, 12 Jun 2023 23:19:24 +0200 Original-Received: by mail-pg1-f186.google.com with SMTP id 41be03b00d2f7-53fa00ed93dsf3382955a12.3 for ; Mon, 12 Jun 2023 14:19:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686604763; cv=pass; d=google.com; s=arc-20160816; b=e6lug3wKQ0/cDfTCsccCz4GBiobQhTFinKV6UatdvEK2nWmnYl/S5F5xwDvwiZyDla 0R1sQyb4dB5K6LWphn9DR2MnzQoS2OBCRKlv98UL5FovUF/P0YaakqD0vadc+jDfJ5Fr D6qu+bsY0brE0FqSrdr+DJf01OLt7Cl0PZJdScfQZ8jYSAqaOV4aZ3RMGlkNcR49o4kV 5Ic4MOp4/biHq65jSw1WQe7MDfuwqoDOOHz/70AHcot8b1EsNIgPS2YpVp6/duAeF5Ic u3btPlz7XRBWaSGuikYmlu9q8ROVmuTSkIS/KrT2JHxf50ijQoOAFOepEMpteCpdPUj2 yR+A== 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 :message-id:from:to:subject:content-transfer-encoding:mime-version :references:in-reply-to:user-agent:date:sender:dkim-signature; bh=FwxietwEQOos6L/vrFaMxICFmjOqAjgPtC7c5kczjgI=; b=qoZI+rKv4Ii/H7YtDba/JJpUc795Jz2RioMX5oWBv7wmMsVWZy/xvJKKFU8B42Naym bS+eNhai3hbnz6LtO594aXI5dm6VUZok5ik2R/iHNztvuNQXNMwLyjTY0R865xj1iZdR f0P8uzqhKANoMMtQQLUyfFaWXbgQapm6cjt5V9m7gv2Xe8MjgvZCyW1h+brOUdzCEuvt hfLNlYZYTRkx8q0XUxsJ9mWxISsT9mgK0kEUKqonevYfsmcVTOxTeuDSvopRbzSWOkGp G0ZWpXTD7gzSSfj/eOR2VPE0+uMMk7RXh5t9eUee6QsJDUw9JW2SSEYCHX8Rdbk7Mr2u 5KPg== 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=1686604763; x=1689196763; 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:message-id:from:to:subject :content-transfer-encoding:mime-version:references:in-reply-to :user-agent:date:sender:from:to:cc:subject:date:message-id:reply-to; bh=FwxietwEQOos6L/vrFaMxICFmjOqAjgPtC7c5kczjgI=; b=gC5K8DzEjrU00pWRrtTkQQYLfjE+xzsdAVlP+YEueCsi5eobj+uwoD+y3/ZkurezGC GDg413trN+5z2hULRUPx9kuOiY7SbxA/upp7ToY1MLH5JciyyK5MkcUbczHFO3hRMApq NTbOFN5X51dWueQxEOegE8WOQt9pddG/XVMOvEnAWGhQOsLiwaxJSnkzkkQr4rEomQcd 3ht9bb+vNiFkHEovY+OqahVT/+NJ79SGlilL9ZR9D0aZNdOjudblHIr3Q/wo6JWeMmTk uhUuLG8M X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686604763; x=1689196763; 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:message-id:from:to:subject :content-transfer-encoding:mime-version:references:in-reply-to :user-agent:date:x-beenthere:x-gm-message-state:sender:from:to:cc :subject:date:message-id:reply-to; bh=FwxietwEQOos6L/vrFaMxICFmjOqAjgPtC7c5kczjgI=; b=F4W6Q8dztiKx8yDwGwFWAlvCHFy3ZQl0FNLVy9ZOX9TWiTf8x37bF1pGuGLwbys4UN xx6UpETdGOLQu8vXwceviTLcYmRHCIxZEpzCP4rV4aeoymPM0peY7sw8G83mOgRJLIJ1 xnnv9R1Vb8hMGKvjzo3rn9U/cwIIFk56Y2oN5Z+pPIUj6VAXQcbcXDAywzIg+UjJn8fI n4djFHCLqd8fiDpErnT Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDzlF3hjft639PedIB96VL/zxOKMk+ocrzJpRZFvo6YN5PnMFTCp Cl7cGWZdGbhrNG+rMatQAG4= X-Google-Smtp-Source: ACHHUZ4/yHZL1uk52rv8zi3AYwalnihIxA6HKx7lDV+l7rLuFaPLCtX3Vwd/y38WUXfXjbmtijXhOQ== X-Received: by 2002:a17:902:ea01:b0:1ac:4735:45d7 with SMTP id s1-20020a170902ea0100b001ac473545d7mr9543163plg.6.1686604762806; Mon, 12 Jun 2023 14:19:22 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a25:4885:0:b0:ba7:3e84:475f with SMTP id v127-20020a254885000000b00ba73e84475fls2082770yba.0.-pod-prod-03-us; Mon, 12 Jun 2023 14:19:18 -0700 (PDT) X-Received: by 2002:a81:93c4:0:b0:565:a3d1:be19 with SMTP id k187-20020a8193c4000000b00565a3d1be19mr12114509ywg.31.1686604758503; Mon, 12 Jun 2023 14:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604758; cv=none; d=google.com; s=arc-20160816; b=ovJkDfJkwmdboHGleznJBnhwRSEy69uJtvNxMURtE1f567z2Ol3yGe20PKM7P7+JVN yp8DE/RNw3N1KcR1aGuIyCN8T1NgWtciUxgTg/BUph6nJgGpQ/3869wePQpRu/EHdODy 2XONNitaBW214xG7vbdBusMn5uF4sdOy2jaRevqnzMH7LBAz4OzoGEOFMDOzrgUqmMje kke5Z0TrK1rFOI/nsmYKzzrXDCuSRvRO0yaLBScE3WgDKJ4OwJQGynTZpYVNL2KIRGo7 4AEmS41ZUajTmOVpiJwVx68LN/92r2fFZduuURVqR2gVW3idh0Orz/jFQSM3/bBw+7M+ rGIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:message-id:from:to:subject :content-transfer-encoding:mime-version:references:in-reply-to :user-agent:date; bh=EWO6vz3kiheQeRXQotB1pIf0xOJZNNY/TD7lk2LZ/1s=; b=WELxLBPusoFq2i17bLaV1hwrMe7I44ejuHxDbAvnx3UGFSrXg+sAotgNfQsA6iOFhK hDFQZ3PfpscosgI2bTg9zKLOfcXwvcXFN4y0k42HG5sTXsl1UhSS9LVVC3i+qN76giSo 4vnrqQ9pXQr68bu66KMI12IBzIXpsrnnoEmjRBQQ92nSv5d2hjUYb0Z4q53pQHivahlJ V4bVuxZ1eLJKrOlNW7W3JwtZeZZXF+wVW2zbVtV3rPmiCV+b4Hp1edZgEtt4ZX7vIud3 hfVO0mKT9tcs5tSCfscwpKn4E+GvgjdXLmk46UVSwIQY+Tw1Zlyshz/uWY/x5nhDaD7+ 1Jow== 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 fq5-20020a05690c350500b00565aabff14bsi700529ywb.0.2023.06.12.14.19.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 14:19:18 -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 android-4fca939f1c4b7497.home ([72.94.51.172]) by mrelay.perfora.net (mreueus003 [74.208.5.2]) with ESMTPSA (Nemesis) id 0LkeyA-1pYOC92T8m-00aTww for ; Mon, 12 Jun 2023 23:19:17 +0200 In-Reply-To: X-Provags-ID: V03:K1:3lQyGFt1fLRg/LF4VWd41tX6+8EVKUMiiWN6unV4ufxc6ac4XVp 5jgln3BOzs23/O9+bppzBWZ3557+KMgpxwlxdSenvgiG48g6fQS+XC3diok8Mafcb+Vz0eB zOHTVWAGWmDE0MMakX54vB0RtHDKw6dA4cckFsqQ+VRLCNbRm245u1rzqUKb0/celaUyTrq DWNvIxYFe9sQ+OKUu7drg== UI-OutboundReport: notjunk:1;M01:P0:uGbOu1M46oc=;9xjC73Bu/Gd39v3DroT0qYAQgay wafKlwFuPq+/UIuVmViZ1kgfLi7numco1t13eGBuwCNbiSLKElzImBurdsUbUGyRrBTctOQU9 298A1ZTlT1wLSERuYMoL9WbVQXpADkVOtjgka8Y/HjzH7Sdv72nUlrYpgwsIz0vgPWVZWfByd GmsjMdBhg0J8qN+IimgtaWsvlSqqr5bm+bxLJSpo58Lt+sC3PuYBgPt+9+ErR9ldTIdqPNBYH cXbpvtkiN6+ySQafqGttlvECVNMCBicJteDq7PvQ0hnGIT5NNa9s80AE+T0qHs6Yc8mTjbH9F a06ExqeOrynf0hWnYQsoDbkYZaB6dzFVd3NCrNk2cxmKoEQNRnFNrGXZO7qUJurCC/RlCf3aq A13PrM3Ztum1K4sF3RUv8XzZ1gFC4XS/FkjT0McR7pchH0I7MqaU1XHi27PjuMbuawWre8Piu yOc7q/BByhPomSMgAUgd71khVJvXJSWzZaGFY4lybXFpyPG0me0JwYeKUL1iUsWvDd7tQoPhS amDOm3VU1PPuV78fNHG0b1wmaflkQwuMLRxt7yT7zSo5kUlWGH/L/N4op6K33XX0TaDJg0zf/ 3/7RIBhcdIVGFDEnt8mL+dayKeimq1bDvw/CrrWDHHJy5OTFsiBTsFH5Sxnk26sQFrICo8xgF RnkzWcCHtOe5q9wF2au1FuEqvLDCw27DHtpOGpx1rA== 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:32795 Archived-At: On June 12, 2023 5:09:20 PM EDT, 'William Lupton' via pandoc-discuss wrote: >I'm not sure whether this helps in your situation, but if the image has >no >alt text then there'll be no caption in the HTML (and no figure element >either). This document: > >![test](https://www.somedomain.tld/test.jpg) > >![](https://www.somedomain.tld/test.jpg) > >...gives this HTML: > >
>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-c= 16dc88cd595%40meddatainc.com >> > >> . >> It does have alt text and I do want to keep that. I do, however, want to ge= t rid of the text - is this doable? --=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/EAF5063B-4655-48B3-8961-AF664AE3C94F%40meddatainc.com.