From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/31848 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.text.pandoc Subject: AW: How do I replace a string in all text that pandoc converts, i.e. how do I do this with a filter? Date: Mon, 5 Dec 2022 23:49:38 +0000 Message-ID: References: <83eeff5c-8fc3-4ca3-862c-bb85790daabcn@googlegroups.com> <3ae58adb-8789-4398-8ab0-fe1e6928e292n@googlegroups.com> <24509d5ca5844dbda07b3e77d86ab3f4@unibe.ch> <2faac96e448d4303b3ea0e12ef05dfbe@unibe.ch>,<7cabb17e-9a2b-4251-bd95-c5415140c9adn@googlegroups.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="1094"; mail-complaints-to="usenet@ciao.gmane.io" To: Original-X-From: pandoc-discuss+bncBCZ27W53TUFBBFMHXKOAMGQEN7TMCLA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Dec 06 00:49:47 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lj1-f192.google.com ([209.85.208.192]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p2LDX-000AeX-ET for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 06 Dec 2022 00:49:47 +0100 Original-Received: by mail-lj1-f192.google.com with SMTP id bn17-20020a05651c179100b0027905fa8e48sf3411998ljb.15 for ; Mon, 05 Dec 2022 15:49:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670284187; cv=pass; d=google.com; s=arc-20160816; b=JeV/qy+1S4y90Xo+jtvQPkJZMYEALGaQR5gtUItZG9NixZu6+Ac1ZzU+9WhjJVxug0 RVyYBDIDQf3YZk3nmd8Mwt9GtOjusY3KFlIheVlSMxMAMuFW4mdCsK62YO3XGDmQi67r BfLEDq3yoYKPSZnrsKTFM7hjbhQ260Zh82pDBLJCsc/x0yuIGRI4/TgtRnVY4c25nqew DeT+juQ1UTv47ZrOgvDS8Hg47LEFOwtAhgPHWVz8iUikj4wMInhurnd+AvmfPn+6KbWT upldWI/b+ZCt+0F1No1MM/YM5CmxeazumVVjWvwMBOUoa2vY1RdX0lZ2TYO8h7+VyYUL QNsA== 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:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:to:from:sender:dkim-signature; bh=O9w2y6WVulSFenrbUGARvLCDgiYOYzBW/iREsdk9p0I=; b=NCKRm2Z6eAH573QvGvqdducHpRZbuKCLwuAPN/QKoLoJZC5T/v2fE603TwGFAmV1vb xcheth5swxS0e6OkTrfZqPmw5WpwVYGq5uPNAKNaGNA9dGryZz4LLGv7DVsGU+FZabWp pPOProeZk0qo+nUKDJytUtKpOIQoi2JKQwcdOJcps0sJ/8jVM7kUExdFD/H1zQkB4kQb zDDv3mAfz24cpOH1113hXQ9BqIzIjKzSbcA/LYPP6/J7mL62ERpRwoxmBT+Ay+HWc/pT Q5n5BL+HNv6JRLEfb0eRDL5yYTHgD3cWQ7G7fPsPGrcAn/KV81OfirKN6iJzDVEd5mCu ikMg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@unibe.ch header.s=mgwsel1 header.b=GXEPT6ra; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.82 as permitted sender) smtp.mailfrom=denis.maier-NSENcxR/0n0@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=unibe.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; 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:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=O9w2y6WVulSFenrbUGARvLCDgiYOYzBW/iREsdk9p0I=; b=UTdDc3Sz88f/TLJEvixN617v3gLWl5aEbPdpzPnAudQGtwgEC30WNNzpN5X9km8fOK MUJ28FbZWFz5hx/Txv7f09JGaeEPoYybHsRnjbWa//o8nFp1/m8oYIzFgJbqrZS2svuq bcDnbH8I9PbHSI6qSuqoVWqiO9M3X6x9E1/wShL6bS7xnDhay5rHZxvC2UnTj8chwTxi 8TXBfytAJ3dPNCPbgGKxHqJGJCLV5JKFXV3OQbdcQbBKv4GM9BsVLUWk9pYCJvR3FsV8 rEBfXZ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:to:from:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=O9w2y6WVulSFenrbUGARvLCDgiYOYzBW/iREsdk9p0I=; b=38t6IFjiob9u5lnZyiQi7yGlo5FWLcgWdLSjnUoBJcNJH8lzqjhhqxtzvzwHhdmr0l 5+L8XrK2X5IXwrcUj/WRBffIrAPc9OGmguOJwz0j8z7iIbLk+sxsMNJe8ezSlZX550zg uG8crioMZlmUpMCiAyZt8+z2rp2aH+t8pCvmgRFGoXtIKuF6LMV1Vuxay8tYnPu1uAeH 0PTsuKAQ9hyJxqUAotsx8hgKkNnJ2 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ANoB5pn8rMFpuopn9Gp0xhWmDkIlWqrxTzQNfb2pdw095Gp3sADJF5Kg c0wRAGRC4GacZTBuGNsukOM= X-Google-Smtp-Source: AA0mqf4YAK5LLBaS/Fa1UmTlKwpSpraWVdWWIUApph3jS6DCv4XDBat2ajNyHxn5Rb6DcUyK1GXmiw== X-Received: by 2002:a2e:8853:0:b0:27a:925:4871 with SMTP id z19-20020a2e8853000000b0027a09254871mr994983ljj.434.1670284186765; Mon, 05 Dec 2022 15:49:46 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a2e:8ecb:0:b0:26c:56b2:1383 with SMTP id e11-20020a2e8ecb000000b0026c56b21383ls1235921ljl.4.-pod-prod-gmail; Mon, 05 Dec 2022 15:49:40 -0800 (PST) X-Received: by 2002:a2e:865a:0:b0:279:f24b:e68f with SMTP id i26-20020a2e865a000000b00279f24be68fmr3109406ljj.34.1670284180611; Mon, 05 Dec 2022 15:49:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670284180; cv=none; d=google.com; s=arc-20160816; b=c1xAZWp1xVcKmsDsCCHZ7eojjQg8PmWnGSiq1y4UAqlEqcvw/uKksakcro7uR1WOc2 4hwEOpM1UghpUJxGm5BX9W7eSoDwGiYmDf0sw4cpUgPjgdXQOFfwVaadd6Otd7c2H8uy gRbq297L4qIF/axMZkasGBqO+soxL9TYeaRun1lwE9pwddlEL7oPlMlDHE+ARLpo/F4D As1EdlcR2VHCgXREQgxKNwZ6OKb0udpuKvBRzuIP9uXPbITjBKGMjeo2HL16pIlLd27N 86NLohbM9HDLtLFUXtwl7Tm702suv4TA8yUpB+vIQya6+X80crmRcOLtQqHS34b0wPu2 Bw/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:to:from:dkim-signature; bh=6UFJKvlDTC/mw+HlLO1yUBEYw6nJtQjntN7grxf9Sks=; b=q7/2hbwDMtTBlyejBSi4kb5RLXH3Nq7iYtCnqTPdAoMIpfI5Jpeu8/xICjpTl5J3I/ A2wdq29+JPkqroj3/N9CrPf8CVABInZBxTUsYW/dKQkXRQM8Wfy15pLZyXGzKAp1cTHY xvRTgJEB5k820bqKtIg44m4p7Dg/iThPPa/NA2FQmp2dOzphtEUG/TYeqZFm/1zSC8t8 sx5KT7SBXtWQMAmRSNzXwmb4lK8hmVl3VTmYv2wI9xBTWTtnoa7m06GBR9KpeA4Dz/hK kA67tvS7jZNOFXh2gHOLlAHYvA/qynhc3wX5HGN3mBShuJe/PAt+7zIAX2UN1zsuPvut rD/w== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@unibe.ch header.s=mgwsel1 header.b=GXEPT6ra; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.82 as permitted sender) smtp.mailfrom=denis.maier-NSENcxR/0n0@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=unibe.ch Original-Received: from mailhub-lb1.unibe.ch (mailhub-lb1.unibe.ch. [130.92.0.82]) by gmr-mx.google.com with ESMTPS id v17-20020a05651203b100b00499b6fc70ecsi746386lfp.1.2022.12.05.15.49.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 15:49:40 -0800 (PST) Received-SPF: pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.82 as permitted sender) client-ip=130.92.0.82; X-Virus-Scanned: By University of Bern - MGW Original-Received: from mail.campus.unibe.ch (aai-edge-04.campus.unibe.ch [130.92.13.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailhub-lb1.unibe.ch (Postfix) with ESMTPS id ED986500085 for ; Tue, 6 Dec 2022 00:49:38 +0100 (CET) Original-Received: from aai-mail-03.campus.unibe.ch (130.92.13.41) by AAI-EDGE-04.campus.unibe.ch (130.92.13.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256) id 15.1.2507.16; Tue, 6 Dec 2022 00:49:36 +0100 Original-Received: from aai-mail-03.campus.unibe.ch (130.92.13.41) by aai-mail-03.campus.unibe.ch (130.92.13.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256) id 15.1.2507.16; Tue, 6 Dec 2022 00:49:38 +0100 Original-Received: from aai-mail-03.campus.unibe.ch ([172.18.73.17]) by aai-mail-03.campus.unibe.ch ([172.18.73.17]) with mapi id 15.01.2507.016; Tue, 6 Dec 2022 00:49:38 +0100 Thread-Topic: How do I replace a string in all text that pandoc converts, i.e. how do I do this with a filter? Thread-Index: AQHZCNHjf/ZLvnEKSku8rNPhS+hfuK5fg9cAgABjBzD///KPAIAAEQug///2x4CAABQqJg== In-Reply-To: <7cabb17e-9a2b-4251-bd95-c5415140c9adn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Accept-Language: de-CH, en-US Content-Language: de-CH x-originating-ip: [130.92.13.161] X-Original-Sender: denis.maier-NSENcxR/0n0@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@unibe.ch header.s=mgwsel1 header.b=GXEPT6ra; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.82 as permitted sender) smtp.mailfrom=denis.maier-NSENcxR/0n0@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=unibe.ch 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:31848 Archived-At: You are matching against the whole paragraph (para). So, when the first ele= ment in your paragraph matches your search string, you'll replace the whole= paragraph with the return value of your function. (Which is a block elemen= t, not an inline element.) Use the example from here instead: https://pandoc.org/lua-filters.html#macro-substitution ________________________________________ Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org im A= uftrag von paulschillinger93-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Gesendet: Dienstag, 6. Dezember 2022 00:32:23 An: pandoc-discuss Betreff: Re: How do I replace a string in all text that pandoc converts, i.= e. how do I do this with a filter? YES! that works! But can you tell me why it replaces the whole line? Can't = I do this in running text? Thanks! return { { Para =3D function (elem) if elem.content[1].text =3D=3D "{{helloworld}}" then return pandoc.RawBlock('latex','abc') else return elem end end, } } On Tuesday, December 6, 2022 at 12:09:13 a.m. UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote= : Just your example filter: ```lua return { { Para =3D function (elem) if elem.content[1].text =3D=3D "{{helloworld}}" then return pandoc.RawBlock('html','
abc
') else return elem end end, } } ``` The problematic line is this: return pandoc.RawBlock('html','
abc
= ') This adds a raw block that will only come in to effect when your output for= mat is html. If your target ist latex, you=E2=80=99ll need something like this: return p= andoc.RawBlock('latex','\\whatever{abc}') ```cmd pandoc test.md -L filter.lua -t latex asf \whatever{abc} asf ``` Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Im Auftrag v= on paulschi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Gesendet: Dienstag, 6. Dezember 2022 00:04 An: pandoc-discuss Betreff: Re: How do I replace a string in all text that pandoc converts, i.= e. how do I do this with a filter? No, my intended output is a PDF file. Does that change anything? Could you = tell me what exactly you put in filter.lua? Thanks! On Monday, December 5, 2022 at 11:56:39 p.m. UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: What exactly are you doing? Your output format is html? I=E2=80=99ve just t= ested this and it seems to work. ```cmd C:\Users\denis\Downloads\filter>cat test.md asf {{helloworld}} asf C:\Users\denis\Downloads\filter>pandoc test.md

asf

{{helloworld}}

asf

C:\Users\denis\Downloads\filter>pandoc test.md -L filter.lua

asf

abc

asf

``` Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Im Auftrag v= on paulschi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Gesendet: Montag, 5. Dezember 2022 18:58 An: pandoc-discuss Betreff: Re: How do I replace a string in all text that pandoc converts, i.= e. how do I do this with a filter? I've tried this: return { { Para =3D function (elem) if elem.content[1].text =3D=3D "{{helloworld}}" then return pandoc.RawBlock('html','
abc
') else return elem end end, } } but that only gets rid of {{helloworld}}, it doesn't replace it with anythi= ng. Sadly this doens't work for "=3D=3D", i.e. those don't disappear. On Monday, December 5, 2022 at 6:49:08 p.m. UTC+1 - wrote: I've been trying to replace markdown/Obsidian highlights "=3D=3D" either wi= th something that LaTeX can use e.g. \hl or just delete it/replace it with = nothing, but I can't figure out how to do this. I've tried this: function Str (str) str.text =3D string.upper(str.text) return str end But I can't even figure out where I'm meant to put my own text? How do I rpelace =3D=3D with " "? Thanks! -- 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/3ae58adb-8789-4398-8ab0-fe1e6928e292n%40googlegroups.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 e= mail to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/e9cb34ca-b760-4ef6-9432-91d37f5e45c5n%40googlegroups.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 e= mail to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/7cabb17e-9a2b-4251-bd95-c5415140c9adn%40googlegroups.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 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/a5cc6e61614f4133870d4dabfa85d5fa%40unibe.ch.