From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32851 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: H Newsgroups: gmane.text.pandoc Subject: Re: Wrapping sections of existing document in
Date: Tue, 20 Jun 2023 20:21:55 -0400 Message-ID: References: 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="21549"; 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+bncBCEIZSNSZ4IRBJMFZGSAMGQEU2L2R6A-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Jun 21 02:22:01 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-qt1-f191.google.com ([209.85.160.191]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1qBlbl-0005Jo-Aq for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 21 Jun 2023 02:22:01 +0200 Original-Received: by mail-qt1-f191.google.com with SMTP id d75a77b69052e-3ff2770311dsf26167631cf.2 for ; Tue, 20 Jun 2023 17:22:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687306920; cv=pass; d=google.com; s=arc-20160816; b=s4J54Ou6wbJB5PS5qUasx8McTIJQ7uUPpr4f+wLKcmNbNT+ioD6M6GmI6MvVLVRv3V VKOx7peztkq6KcAoa2C5uEIut6KDR061xWOnBdPbH9HVPsX9AZDc3DToF2mGtyxWLwWd FK3CLQ9F9CFhf+YTl0DO8++ZXpiEHNVxQ1bj+XXkF5f6y5gdsnPlE5VsMBDGHflL2da2 sj9pUU5bScfcvFiRepqpO+Py8yW9xrfAVrU7tX8/PtLAOLL4cPYiUNQ6TJKlHhlxWSzj Zfh0D7uGuo2jkQ/6/nQYePLeSLAHIJYXrqSb5GpfeuUzTgp4PpkZIyz2ivRUjCniA+uN lFUQ== 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:content-transfer-encoding:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject:sender :dkim-signature; bh=miI74/lj+tOuED02eUT4E6K5q2uGNtv9QZX3uLalSK0=; b=L+NE2M+I8AopxTFh0uL15Fnzsauj6aIxpjWZ0Gu8Af5uVNyy27EtN4GGYfoaShboBX oSGWnGON96nIHeSjf6MElPDgCo+ls8hbLVfXsNiGiNmynJqGefm8WfVxYpWDDvJUjW0e kjlowmDKIFiVtqQTeUBojsSpDHak2SZQ5R/nd2ETgrbeXg0mWMcXQ/o51IvrXh9uCLUb SeldQoTMieVg9zOrx9rZE6JwyNVxxzoMcm9gXRsCbTpUgIxR0mMNrveGEioaSQpEnYf8 nzdMceRb9cj8/IzUTCWEipAKMcNl9Ozmu+0fVkNEig1ZjfzgSrFo+4xZ/bgMT8/FRvM5 A1fg== 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.196 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=1687306920; x=1689898920; 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:content-transfer-encoding :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=miI74/lj+tOuED02eUT4E6K5q2uGNtv9QZX3uLalSK0=; b=PHn9azrR8oomYkIMSfNk3ZTMnZNpDe73kXd/r88r/dFgrpDiXlxZW1T38JoKd0bSXM DQJZdfGVqtN6xnuDcvff7Tak5sZzFpMAGSq4AicI3VuL3V6DdpWduG8ovifo5oxuX6lv 6s7oYJok5NuhlGZPduu9AvGanvHqYBqghGwPTFOTJk1ZYmZTZGwhXAxFmUjchixCmQOP yi2Wdqz2jOpsqdgQiMOLd4pzG7LpBPHDlUebZHoILwBgl2M2VMYZw43hOsYIjbaPlMde X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687306920; x=1689898920; 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:content-transfer-encoding :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=miI74/lj+tOuED02eUT4E6K5q2uGNtv9QZX3uLalSK0=; b=hSdEvC0TZO1OPN0H+3N+YUisDIKwJFAG8mfiXE5AZkAcxH8A39Lsg70XCtAXVFq6jP +dFDlAByY83a+kHLDS/dEINNVhWw3/52LYgYpFsT8bwRUPdIOncg4QoVkeEjZFj9cZIr 3/Gws954YcfoJZyvz7RyK3RZf9y8aX+isIHyTwhZIT9vE1bUozlOeFKdi23nLW8v5uB0 DD Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDzUPzNWB2mRvwnNlXBAAJehgikBDLTb9Co399dfOYOQM7EvZJ8J c3X5j1nfrbX1CY75RWTYXOQ= X-Google-Smtp-Source: ACHHUZ6eb8mP93xs/PbjqLshLy+UToDH0CfFc50CztbV1+mbR88DYifHisnqcqFPLJr0pVxB7p4RNw== X-Received: by 2002:ac8:5bd1:0:b0:3fd:ecdc:1e26 with SMTP id b17-20020ac85bd1000000b003fdecdc1e26mr10841997qtb.13.1687306920259; Tue, 20 Jun 2023 17:22:00 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:ac8:7388:0:b0:3ff:302c:774c with SMTP id t8-20020ac87388000000b003ff302c774cls1041805qtp.2.-pod-prod-07-us; Tue, 20 Jun 2023 17:21:57 -0700 (PDT) X-Received: by 2002:a05:622a:1c5:b0:3b9:e0b2:9a49 with SMTP id t5-20020a05622a01c500b003b9e0b29a49mr17453193qtw.60.1687306917268; Tue, 20 Jun 2023 17:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687306917; cv=none; d=google.com; s=arc-20160816; b=U31eGjZ1ojptbDSUelgZxPrpKpf0Ka1ayjL73hUtnMTuM/yTvyXisL1ZlXkNVjf+gJ GVMP6Z9eqDPiAkcLFm4gVrgRlqBlxtPa8AmgmLhnYw11oBJZH7KuHgwz6PXnRhEnlLu5 ko5GtyfIEozT2kI9HtkFzq2idAYIJggzCKJz30g8SVWjOa1yuDmJg1qYR93b7soC5WAl +7mOiK7Kaks5LAQM6/tdIWU9FZrkUJgNJkrqPQq6Q1UGueWeslOT19emERNxyS0cbNpj Og+yXurV/AMOQHfKTPmKNywi0rO7NsoFBwrL6qdz73eZuwzJ0FUkzPaTPVjYyLKvSd60 w5uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject; bh=jcF9l+4MFpiyjmSLX6ySnvkb91jINecHmgnzTyGdHMw=; b=dRXfBjFkXti92kc6tSzL7sjAJehfQ7aQdmADTOwz/GnEkelbJX1FcgFP0LoiT2MF1l URuVH7RgE1v2zFPuf4DXNjgLIehZyeCdWvVnMKJUP8lZmT/ZNMjzL6r74wms0pwaF9wd az8pWd48pZG9S0aafLv0guyHs2r2yGVfN8pZICYYLQJqySLc4mlp+fXLlkDSknzATm+f Aucwt34hweFaghNCIQ4AKEC6zdzvaJDJC3TSEv00nxwqufUTY1gLMmLujnD9opShsN9I e8a+A79PtDOvlY7p69zKFl2xoa+GvEsoG59pd8FVXh5a7mHoSnZWFs5unzGvmlsImvoz rXuw== 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.196 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.196]) by gmr-mx.google.com with ESMTPS id ff6-20020a05622a4d8600b003f9be821c79si364622qtb.5.2023.06.20.17.21.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 17:21:57 -0700 (PDT) Received-SPF: pass (google.com: domain of agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org designates 74.208.4.196 as permitted sender) client-ip=74.208.4.196; Original-Received: from [192.168.1.17] ([72.94.51.172]) by mrelay.perfora.net (mreueus002 [74.208.5.2]) with ESMTPSA (Nemesis) id 0McDIH-1qU7pz0xDr-00JbcW for ; Wed, 21 Jun 2023 02:21:56 +0200 In-Reply-To: Content-Language: en-US X-Provags-ID: V03:K1:TXXsw9QSjODE5g9eTOrsYPFmRLEozYl0c+TnJWWH5z1LOF2XT26 /FmPB40u1f2bH81RF+2Jti8jbrL6+cUk4P/HLpPsXMPCXqffgjvDLaGlr7yb3gs0EXDqpTN tl5NoEo30nQnJdNjBIki8ermhyS+MklVAClR0w1Vs2xSIG6niIMOZ36HoLTJikrGTsJxxNO XEhoSLewbcqmhkRoQfAHQ== UI-OutboundReport: notjunk:1;M01:P0:+aRdBbs0Ln4=;4oys6lIklybTtgdKo0KnkLOVHFz Fo/y/ChygTEUTri7WrbfQm3DJLTAndsMGGR4uWb7ptNKUvBptsCLoT/VvwPUb0BmgI0s+75zk B08atWFWpFPiwIDhmKCGCMpqQ54ea9kJ0qE0/ZT0JiqG1YRHyZvyq2ihNAgSv/3OvudTPiK3e 4yiuUToLkSV1Ed/+yzc/8Fxf/IwM6+17G845nQxf6TyDhEzouYB0w8aQafW0m9GcHoKMnWiJk y5Z2lmKElANm/KCrbQKGJisYgXGpjfpvsTvhFfCFNUaDdl3+F9cLBEnkBTjK0FdXJ+OKOVRX6 fiRWZPNn6ddqUIonPllz1UJfO/un/2CzuPHzrKASE7s5Bjv9FFEKUNSieCzK2MTaBh+xDAGjy 3ktEH6m2m4C4v9IM8lbkzGMKT93O5f91JdTJroyk/2/uvkolggw7LcmlbRTNZPjk/7dXhOOTF zwOFlfBz/d0xazvzQULPnBz5yPvVELFIVHejLhXDL2i1KWG86lLDnTjNn1zuk6mVnIa9JaIjV UJPsh3Lqr5gmI+d8iE788XOKhE7UX5ErKJHDcW2SkOST8cTIc6jrTwdqyKPX+AkYmRgTttHhr xSg4Vp0pDo2ojNUNPvdIyajskUVMcsEhaAyh3CVyiGx82JCaZY7Eh1Oc64Xt3CAAY2kHGLa+N 7W3wEOLWkfV9Yz4bRn1a+PHDQ26k7MHxRu5zT5Z/Jg== 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.196 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:32851 Archived-At: On 06/20/2023 06:37 AM, mf wrote: > Il 20/06/23 02:14, H ha scritto: >> On June 19, 2023 6:11:35 PM EDT, H wrote: >>> What is the "best" way of wrapping parts of an existing document in >>>
in a filter? >>> >>> Using insert.table(existingtable, pandoc.Div(existingtextblocks)) does >>> not work since the existing text blocks get duplicated in the output. >>> >>> I see two options but there might be others: >>> >>> - Surround existing text blocks with pandoc.RawInline(1, 'html, >>> '
') and pandoc.RawInLine('html', '
'). >>> >>> - Create a new table and use insert.table(newtable, >>> pandoc.Div(existingtextblock)) and also insert the rest of the >>> document. >>> > > This would apply only to HTML output. > >>> Are there other options? >> >> Replying to my own question, it seems the most "elegant" way of accompli= shing this requires this to be done be in two stages: >> >> - First, delete the blocks in question from the block list table, eg doc= .blocks. >> - Second, insert them into the same table using pandoc.Div(). >> >> Unfortunately it seems table.delete() does not accept a list of blocks, = only one block at a time, pandoc.Div, on the other hand, accepts a table. H= ere is a code example when I was trying it out: >> >> local temp =3D {} >> for i =3D 3, 1, -1 do >> =C2=A0=C2=A0 table.insert(temp, table.remove(doc.blocks, 5)) >> end >> >> table.insert(doc.blocks, 2, pandoc.Div(temp)) >> >> The above code removes blocks 5 through 7 from doc.blocks, then inserts = them, in the same order but surrounded by
, in position 2. >> >> If there is a better way of accomplishing this, I would appreciate heari= ng it. >> > > Consider using the Blocks function in the filter (see https://pandoc.org/= lua-filters.html#filters-on-element-sequences). > > The Blocks function is called on every sequence of blocks. > Here's an example: > > local my_filter =3D { > =C2=A0 { > =C2=A0=C2=A0=C2=A0 Blocks =3D function(blocks) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 local first_in_div, last_in_div =3D detect= _seq_for_div(blocks) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -- check if last is after first and the Di= v will not be empty > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if first_in_div and last_in_div and last_i= n_div - first_in_div > 1 then > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 local newblocks =3D pandoc.Lis= t() > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 local divblocks =3D pandoc.Lis= t() > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for i =3D 1, #blocks do > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if i < first_in_di= v or i > last_in_div then > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newblo= cks:insert(blocks[i]) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 divblo= cks:insert(blocks[i]) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if i = =3D=3D last_in_div then > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 local div =3D pandoc.Div(divblocks) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 newblocks:insert(div) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 end > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 end > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 end > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return newblocks > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 end > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -- if no meaningful sequence is detected, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -- no return statement to keep the current= blocks > =C2=A0=C2=A0=C2=A0 end, > =C2=A0 } > } > > You should write the detect_seq_for_div function that scans a list of blo= cks and returns two positive integers only if it contains a meaningful sequ= ence of blocks that you want to wrap in a Div. Otherwise it should return n= il. > > Those two integers are the indexes of the first and the last block you wa= nt to put in the Div. > Thank you! I will play around with the 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/de6bf20a-1e87-0005-3a2e-86c459ff9543%40meddatainc.com.