From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/31849 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: - Newsgroups: gmane.text.pandoc Subject: Re: 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 15:51:09 -0800 (PST) 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: multipart/mixed; boundary="----=_Part_7066_2051308443.1670284269569" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8324"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDR3RNPJ3YORB3UHXKOAMGQE37OZL5Q-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Dec 06 00:51:17 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ot1-f60.google.com ([209.85.210.60]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p2LEy-0001y7-Oy for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 06 Dec 2022 00:51:16 +0100 Original-Received: by mail-ot1-f60.google.com with SMTP id ca5-20020a056830610500b0066ea21701cesf3900196otb.7 for ; Mon, 05 Dec 2022 15:51:16 -0800 (PST) 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-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=Cdggc9offMkUwpu27+yQWMWroeTkrrZCAQ/dzRJAVXA=; b=kpQq7VczLsfxnfvnuWQh88JDqp381Q9SjK9eARig+wJVGZBR7lLBTM8xtJVuj0H23k oIEmyU1ceEK53nx/zQiSy2ux/wUxgYGCoh4hIM/X4BXcmoZKVHQtjJC7JbkqwwWimnq9 saQATg0EZJuGYU1q26rfKn+F7ZW7q2HQa8PaG00WemNG0JtGPtQQoskPcKd3AWRtNSM8 5GImC9lullsoL1i4VBARjsZPnF15dXBMtNyuvL3zD2Byf/9SJURASD/kvwXShJC5/RhY BuE/q5mq9+S1fWNa/mb/ATykI9nf4WV2NjHWgEtbTKG+mkYcZVxLTS/OOitmZRbuDbTh TF/w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=Cdggc9offMkUwpu27+yQWMWroeTkrrZCAQ/dzRJAVXA=; b=JS85RsjN3G5zobPWOQqNp0QMOzGX8igMgmQK0E9ND329m/wdk+srvlWShbF230B4aA F4xjwVYwA2y/ZWYqkNF2UmsoSIBV+w9AqNnd7RZizT2vU4nnsQLjL5am87xLp8ehoO2T LaHLtHNmAMCsh6Zr3tWiUH7E0bh+q9DJZN15Xqw96yH/5Qtsmpek98F1IXDo75nfIGS6 M3K/22KEyZfnRxRH3UTFm5XYQYTGQ1iHthbiBDdVB9CIfdiXWvBnuejB4xGRz/alWvJm QW+VyYtIMokPFwuy2TPRWmYR3f5lVz4f7dFq0moZQs0Bl4UqF1m+1yM9wHIJ0KVT6T+i ueEQ== 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-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-gm-message-state:sender:from:to:cc :subject:date:message-id:reply-to; bh=Cdggc9offMkUwpu27+yQWMWroeTkrrZCAQ/dzRJAVXA=; b=bdI/o31hqi/1P+mDnauDLyZEswsyKYLm4uOja2brvXEVoFIAPJxOran4S3ZulDuP+5 ffe1adye7vZrNnCcxjCMU8kjdDw0ENEgB+cIAs9p7/OKBGpaFnZhwks18NJxKv6XO1Xz QbZFm+ZLgEBDrXSb0v5CfqXq8dDLU2Z9zCen56+wiMkqQAtyYX4zs0wr8l9NgEc11Yfl fnqE1Ni7VC8Epx/nxAz88UIrtXs4iWpx7wMt/haf0fh46KN1iYVj+upzwJjjogrK4lTZ JV9+P1P+qs9tRPaDjFeJ5SuAIo+VDv8od/UgEfxGevdOc/DYYQqti8+m/ldFLKsrjUej b/1A== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ANoB5plj024kzmATNFpMFRTpYWRiF2wwrVp7ln1hPj3Nk8oTUC/SysIG W/Fi9uCSs3QqC5CfSRlJR60= X-Google-Smtp-Source: AA0mqf6pLYd+AUlX0i0GyyOf/X5Q6Iecj0HZuj9RYIxX8yJ6PsvsjRMPmPLXEP0mNVgdn/e6VlH0AA== X-Received: by 2002:aca:2b16:0:b0:350:ff3d:297d with SMTP id i22-20020aca2b16000000b00350ff3d297dmr31937405oik.183.1670284275590; Mon, 05 Dec 2022 15:51:15 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a4a:88a1:0:b0:4a0:7390:5683 with SMTP id j30-20020a4a88a1000000b004a073905683ls254611ooa.5.-pod-prod-gmail; Mon, 05 Dec 2022 15:51:10 -0800 (PST) X-Received: by 2002:a4a:b0c4:0:b0:49b:dd0d:58ab with SMTP id l4-20020a4ab0c4000000b0049bdd0d58abmr26622490oon.82.1670284270211; Mon, 05 Dec 2022 15:51:10 -0800 (PST) In-Reply-To: X-Original-Sender: paulschillinger93-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 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:31849 Archived-At: ------=_Part_7066_2051308443.1670284269569 Content-Type: multipart/alternative; boundary="----=_Part_7067_1705400490.1670284269569" ------=_Part_7067_1705400490.1670284269569 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I just tried that, thanks! That works :) But this doesn't appear to work=20 for characters, like "=3D=3D" which was the original goal. Am I missing som= e=20 sort of escape characters? On Tuesday, December 6, 2022 at 12:49:46 a.m. UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote= : > You are matching against the whole paragraph (para). So, when the first= =20 > element in your paragraph matches your search string, you'll replace the= =20 > whole paragraph with the return value of your function. (Which is a block= =20 > element, not an inline element.) > > Use the example from here instead: > https://pandoc.org/lua-filters.html#macro-substitution > ________________________________________ > Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org im Auftrag= =20 > von paulschi...-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,= =20 > 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=20 > 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=20 > 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=20 > pandoc.RawBlock('html','
abc
') > This adds a raw block that will only come in to effect when your output= =20 > format is html. > > If your target ist latex, you=E2=80=99ll need something like this: return= =20 > pandoc.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= =20 > von 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,= =20 > i.e. how do I do this with a filter? > > No, my intended output is a PDF file. Does that change anything? Could yo= u=20 > 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=20 > wrote: > What exactly are you doing? Your output format is html? I=E2=80=99ve just= tested=20 > 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= =20 > von 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,= =20 > 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=20 > anything. Sadly this doens't work for "=3D=3D", i.e. those don't disappea= r. > 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 = with=20 > something that LaTeX can use e.g. \hl or just delete it/replace it with= =20 > 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= =20 > "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an= =20 > email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit=20 > https://groups.google.com/d/msgid/pandoc-discuss/3ae58adb-8789-4398-8ab0-= fe1e6928e292n%40googlegroups.com > < > https://groups.google.com/d/msgid/pandoc-discuss/3ae58adb-8789-4398-8ab0-= fe1e6928e292n%40googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter > >. > -- > You received this message because you are subscribed to the Google Groups= =20 > "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an= =20 > email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit=20 > https://groups.google.com/d/msgid/pandoc-discuss/e9cb34ca-b760-4ef6-9432-= 91d37f5e45c5n%40googlegroups.com > < > https://groups.google.com/d/msgid/pandoc-discuss/e9cb34ca-b760-4ef6-9432-= 91d37f5e45c5n%40googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter > >. > > -- > You received this message because you are subscribed to the Google Groups= =20 > "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an= =20 > email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>. > To view this discussion on the web visit=20 > https://groups.google.com/d/msgid/pandoc-discuss/7cabb17e-9a2b-4251-bd95-= c5415140c9adn%40googlegroups.com > < > https://groups.google.com/d/msgid/pandoc-discuss/7cabb17e-9a2b-4251-bd95-= c5415140c9adn%40googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter > >. > --=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/e0806b27-10df-48cd-ab8a-7806ac1c8039n%40googlegroups.com. ------=_Part_7067_1705400490.1670284269569 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I just tried that, thanks! That works :) But this doesn't appear to work fo= r characters, like "=3D=3D" which was the original goal. Am I missing some = sort of escape characters?

On Tuesday, December 6, 2022 at 12:49:46 a.m. UTC+= 1 denis...-NSENcxR/0n0@public.gmane.org wrote:
You are matching against the whole paragraph (para). So, when= the first element in your paragraph matches your search string, you'll= replace the whole paragraph with the return value of your function. (Which= is a block element, not an inline element.)

Use the example from here instead:
https://pandoc.org/lua-filters.html#macro-substitution
________________________________________
Von:
pandoc-...@googlegroups= .com <pandoc-...@googlegr= oups.com> im Auftrag von = paulschi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <pa= ulschi...-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? Ca= n'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','<div>abc</d= iv>')
else
return elem
end
end,
}
}
```

The problematic line is this: return pandoc.RawBlock('html',= 9;<div>abc</div>')
This adds a raw block that will only come in to effect when your output= format is html.

If your target ist latex, you=E2=80=99ll need something like this: retu= rn pandoc.RawBlock('latex','\\whatever{abc}')

```cmd
pandoc test.md -L filter.lua -t latex
asf

\whatever{abc}

asf
```


Von: pandoc-...@googlegroups= .com <pandoc-...@googlegr= oups.com> Im Auftrag von = paulschi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Gesendet: Dienstag, 6. Dezember 2022 00:04
An: pandoc-discuss <pando= c-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
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 ju= st tested 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
<p>asf</p>
<p>{{helloworld}}</p>
<p>asf</p>

C:\Users\denis\Downloads\filter>pandoc test.md -L filter.lua
<p>asf</p>
<div>abc</div>
<p>asf</p>
```
Von: pandoc-...@googlegroups= .com <pandoc-...@googlegr= oups.com> Im Auftrag von = paulschi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Gesendet: Montag, 5. Dezember 2022 18:58
An: pandoc-discuss <pando= c-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
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','<div>abc</d= iv>')
else
return elem
end
end,
}
}

but that only gets rid of {{helloworld}}, it doesn't replace it wit= h anything. 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 with 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 Grou= ps "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send = an email to pandoc-discus...@goo= glegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/3ae58adb-8789-= 4398-8ab0-fe1e6928e292n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss= /3ae58adb-8789-4398-8ab0-fe1e6928e292n%40googlegroups.com?utm_medium=3Demai= l&utm_source=3Dfooter>.
--
You received this message because you are subscribed to the Google Grou= ps "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send = an email to pandoc-discus...@goo= glegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/e9cb34ca-b760-= 4ef6-9432-91d37f5e45c5n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss= /e9cb34ca-b760-4ef6-9432-91d37f5e45c5n%40googlegroups.com?utm_medium=3Demai= l&utm_source=3Dfooter>.

--
You received this message because you are subscribed to the Google Grou= ps "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send = an email to pandoc-discus...@goo= glegroups.com<mailto:pand= oc-discus...-/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<https://groups.google.com/d/msgid/pandoc-discuss= /7cabb17e-9a2b-4251-bd95-c5415140c9adn%40googlegroups.com?utm_medium=3Demai= l&utm_source=3Dfooter>.

--
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= /msgid/pandoc-discuss/e0806b27-10df-48cd-ab8a-7806ac1c8039n%40googlegroups.= com.
------=_Part_7067_1705400490.1670284269569-- ------=_Part_7066_2051308443.1670284269569--