From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/31855 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: Tue, 6 Dec 2022 03:51:31 -0800 (PST) Message-ID: <282dc553-743a-4623-9f68-897468f97a7bn@googlegroups.com> 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> <272ed09b-4245-4128-94a2-50cf5f67e10dn@googlegroups.com> <6d25bb08-224d-4f01-8eba-3f1c55d19e83n@googlegroups.com> <3db81523c80944f3a81a18f25166124f@unibe.ch> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_9224_1114009941.1670327491970" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4361"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDR3RNPJ3YORBROZXSOAMGQEYZOSEII-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Dec 06 12:51:38 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f64.google.com ([209.85.161.64]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p2WU4-0000s7-Mx for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 06 Dec 2022 12:51:36 +0100 Original-Received: by mail-oo1-f64.google.com with SMTP id c8-20020a4a87c8000000b0049f149a83fdsf5537938ooi.19 for ; Tue, 06 Dec 2022 03:51:36 -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=eKZZl/aEWht8K49EBAc3bWb7mC9d9nHpBARvaGz3gZc=; b=kDxcw+cVSWDbWJEGNLDgnRXR4vDEo7/9b4V+tVaMuEbw6yyUizlVt9k2btIVB4By5t Yx/CYIBoJd8aqRWzey8MCfyXh/s8pLWIKt+tqZNlnqEo+7iJFxKtgR33j9tupw2XOTKL T8g7MfoBGBgzYmKLqoCdo34LZ1pHBL9Sr+FLwK9f+gqjVn5UJA+xQKMnjUpHvoGkwRWu 0KyAKGk/YSNlpcG1Vfj6YLX2OQomxro4zghUjWevcTSHoCRdNjI7ImK1ltsSZvCibPas 8yqqMJZBYQPAp113BYxzCNEY2PnwX0VXsIb03i+tOv8gj2RvGj3fGpdwbGhHmugakJ6j mQ6g== 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=eKZZl/aEWht8K49EBAc3bWb7mC9d9nHpBARvaGz3gZc=; b=FtMW+LOpe2s5MwfpPxByvEGzn++DYGZ7yVWdc8qD+06ngWiW5QerDWvKf5u/3I7mdw sbbAG5Jg1y3Z+1Y42S6C8DHI2uqO975xqKPoKpFS1crb19GW3FtY0MJK0TQOrhKIZl04 oCAcoZ2xXK4gehSiGcSxstg8fvLsVdg1on/1ZWGF9zbkuao3ggVdNlbVSpupi89FC6R+ wGx1cOqaH44TzNgHDWD9aySO826e9dwhSSgV9ITAM8Ztc5bjRYcMvevfh47qClkShAWV CYRly+1C8W/bG/uPxAO/iP4bRd6ce+qwGfUIb/HSSqsgzsBzbTFug0rAo46iFX5ztDSb z3RA== 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=eKZZl/aEWht8K49EBAc3bWb7mC9d9nHpBARvaGz3gZc=; b=HfVQmPr3wF10q3MyBiur0BOcvaSkX+sWdgSVgs5H+vb144/hFCozg9eP0r4pQGvq1q jUJMbvhG9qhQQ1lo45OAZFhS4ANDkt9TnDQbErUda6bNv5R2RTmFgBCnTMBQIvPIyJJg ymiyJJmRKcvwQZfZ2l6sl6wbsVlbGRvvdUuO7sH+zRUJuOUCmmxymRq6qPguarNafjqX nQvSB0o+BJuHJ0NQYB1Ho62dppuh22IgKY6QW2e4xR2DAa5sJjCzzihTpU+JYhqp3tvW dyP/Lc+OtEI/59HtB0qdYWqJ/pkgddLTZYTBLwt7vuAyzmowwkOpsIKUatPru9Cbx5+c 4vvg== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ANoB5pm0ITdE8TqvtPiUV3o6I/rYv9jdSeNI3KT6pb2IWl1BbABQytqq 3QVpjKUdHQiPpfoHJkXXF2w= X-Google-Smtp-Source: AA0mqf7w2DzugN1OnE0a5hHJIn8wGUVkRQ2T7QahqX5DaFq+tk3R7N9tePa8VnTH+16oa1j/2s8HHw== X-Received: by 2002:a05:6870:ab0a:b0:143:fa7f:2b29 with SMTP id gu10-20020a056870ab0a00b00143fa7f2b29mr16191106oab.116.1670327495464; Tue, 06 Dec 2022 03:51:35 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6830:246a:b0:668:d7a2:6181 with SMTP id x42-20020a056830246a00b00668d7a26181ls1398118otr.11.-pod-prod-gmail; Tue, 06 Dec 2022 03:51:33 -0800 (PST) X-Received: by 2002:a05:6830:6505:b0:66c:fb5b:4904 with SMTP id cm5-20020a056830650500b0066cfb5b4904mr43290063otb.237.1670327492736; Tue, 06 Dec 2022 03:51:32 -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:31855 Archived-At: ------=_Part_9224_1114009941.1670327491970 Content-Type: multipart/alternative; boundary="----=_Part_9225_54120354.1670327491970" ------=_Part_9225_54120354.1670327491970 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable IT HAS BEEN SOLVED :) Using the lua.filter here:=20 https://gist.github.com/tarleb/a0646da1834318d4f71a780edaf9f870 and this=20 filter: function Span (span)=20 if span.classes:includes 'mark' then=20 return {pandoc.RawInline('latex', '\\hl{')} .. span.content ..=20 {pandoc.RawInline('latex', '}') }=20 end=20 end And now it works, but only because I updated pandoc. In the version that=20 Linux Mint's repo had it wouldn't work. On Tuesday, December 6, 2022 at 11:55:17 a.m. UTC+1 - wrote: > OK, so I have markdown text that includes =3D=3Dhighlighted=3D=3D words l= ike that.=20 > I would like to convert =3D=3Dhighlighting=3D=3D either to \hl{highlighti= ng} so=20 > LaTeX can handle it, or to highlighting, i.e. remove the symbols, so that= =20 > they just don't appear. > > Thanks to you, I now have a working filter that looks like this: > > return { > { > Str =3D function (elem) > if elem.text =3D=3D "highlighting" then > return pandoc.Emph {pandoc.Str "highlighting"} > > else > return elem > end > end, > } > } > > This filter takes all instances of highlighting and turns them into=20 > *highlighting*. However, ONLY if that's a whole word. If it's=20 > =3D=3Dhighlighting=3D=3D it doesn't touch it because that's seemingly tec= hnically=20 > another word as it contains other characters. In my case I would like to= =20 > replace only the "=3D=3D" but since they're attached to other characters,= i.e.=20 > the actual word, the filter doesn't touch them. > > That's where I'm at right now. I'm now looking for a modification of that= =20 > filter so it also applies to parts of a word. > Any ideas on that? > > Thanks! > > On Tuesday, December 6, 2022 at 11:00:09 a.m. UTC+1 denis...-NSENcxR/0n0@public.gmane.org=20 > wrote: > >> Sorry, I haven=E2=80=99t been following from the beginning. Can you prov= ide a=20 >> complete example. What=E2=80=99s your input ? What=E2=80=99s the desired= output ? >> >> =20 >> >> *Von:* pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org *Im=20 >> Auftrag von *paulschi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >> *Gesendet:* Dienstag, 6. Dezember 2022 01:03 >> *An:* pandoc-discuss >> *Betreff:* Re: How do I replace a string in all text that pandoc=20 >> converts, i.e. how do I do this with a filter? >> >> =20 >> >> I've narrowed it down! The issue isn't the characters but that they're= =20 >> technically "part" of the word. How do I replace PART of a word? >> >> Thanks! >> >> =20 >> >> On Tuesday, December 6, 2022 at 12:52:05 a.m. UTC+1 - wrote: >> >> Barring that, can't I use something like "> =3D string.gsub("Hello banan= a",=20 >> "banana", "Lua user")", if so how would I do that? I got that example fr= om=20 >> http://lua-users.org/wiki/StringLibraryTutorial >> >> On Tuesday, December 6, 2022 at 12:51:09 a.m. UTC+1 - wrote: >> >> 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 = some=20 >> sort of escape characters? >> >> On Tuesday, December 6, 2022 at 12:49:46 a.m. UTC+1 denis...-NSENcxR/0n0@public.gmane.org=20 >> 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 bloc= k=20 >> element, not an inline element.)=20 >> >> Use the example from here instead:=20 >> https://pandoc.org/lua-filters.html#macro-substitution=20 >> ________________________________________=20 >> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org im=20 >> Auftrag von paulschi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org =20 >> Gesendet: Dienstag, 6. Dezember 2022 00:32:23=20 >> An: pandoc-discuss=20 >> 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?=20 >> >> YES! that works! But can you tell me why it replaces the whole line?=20 >> Can't I do this in running text?=20 >> Thanks!=20 >> return {=20 >> {=20 >> Para =3D function (elem)=20 >> if elem.content[1].text =3D=3D "{{helloworld}}" then=20 >> return pandoc.RawBlock('latex','abc')=20 >> else=20 >> return elem=20 >> end=20 >> end,=20 >> }=20 >> }=20 >> >> >> >> >> On Tuesday, December 6, 2022 at 12:09:13 a.m. UTC+1 denis...-NSENcxR/0n0@public.gmane.org=20 >> wrote:=20 >> Just your example filter:=20 >> >> ```lua=20 >> return {=20 >> {=20 >> Para =3D function (elem)=20 >> if elem.content[1].text =3D=3D "{{helloworld}}" then=20 >> return pandoc.RawBlock('html','
abc
')=20 >> else=20 >> return elem=20 >> end=20 >> end,=20 >> }=20 >> }=20 >> ```=20 >> >> The problematic line is this: return=20 >> pandoc.RawBlock('html','
abc
')=20 >> This adds a raw block that will only come in to effect when your output= =20 >> format is html.=20 >> >> If your target ist latex, you=E2=80=99ll need something like this: retur= n=20 >> pandoc.RawBlock('latex','\\whatever{abc}')=20 >> >> ```cmd=20 >> pandoc test.md -L filter.lua -t latex=20 >> asf=20 >> >> \whatever{abc}=20 >> >> asf=20 >> ```=20 >> >> >> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Im=20 >> Auftrag von paulschi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org=20 >> Gesendet: Dienstag, 6. Dezember 2022 00:04=20 >> An: pandoc-discuss =20 >> 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?=20 >> >> No, my intended output is a PDF file. Does that change anything? Could= =20 >> you tell me what exactly you put in filter.lua?=20 >> Thanks!=20 >> >> On Monday, December 5, 2022 at 11:56:39 p.m. UTC+1 denis...-NSENcxR/0n0@public.gmane.org=20 >> wrote:=20 >> What exactly are you doing? Your output format is html? I=E2=80=99ve jus= t tested=20 >> this and it seems to work.=20 >> >> ```cmd=20 >> C:\Users\denis\Downloads\filter>cat test.md=20 >> asf=20 >> >> {{helloworld}}=20 >> >> asf=20 >> C:\Users\denis\Downloads\filter>pandoc test.md=20 >>

asf

=20 >>

{{helloworld}}

=20 >>

asf

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

asf

=20 >>
abc
=20 >>

asf

=20 >> ```=20 >> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Im=20 >> Auftrag von paulschi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org=20 >> Gesendet: Montag, 5. Dezember 2022 18:58=20 >> An: pandoc-discuss =20 >> 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?=20 >> >> I've tried this:=20 >> >> return {=20 >> {=20 >> Para =3D function (elem)=20 >> if elem.content[1].text =3D=3D "{{helloworld}}" then=20 >> return pandoc.RawBlock('html','
abc
')=20 >> else=20 >> return elem=20 >> end=20 >> end,=20 >> }=20 >> }=20 >> >> 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 disappe= ar.=20 >> On Monday, December 5, 2022 at 6:49:08 p.m. UTC+1 - wrote:=20 >> 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.=20 >> >> I've tried this:=20 >> function Str (str)=20 >> str.text =3D string.upper(str.text)=20 >> return str=20 >> end=20 >> >> But I can't even figure out where I'm meant to put my own text?=20 >> >> How do I rpelace =3D=3D with " "?=20 >> >> Thanks!=20 >> --=20 >> You received this message because you are subscribed to the Google Group= s=20 >> "pandoc-discuss" group.=20 >> To unsubscribe from this group and stop receiving emails from it, send a= n=20 >> email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org=20 >> 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>.= =20 >> >> --=20 >> You received this message because you are subscribed to the Google Group= s=20 >> "pandoc-discuss" group.=20 >> To unsubscribe from this group and stop receiving emails from it, send a= n=20 >> email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org=20 >> 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>.= =20 >> >> >> --=20 >> You received this message because you are subscribed to the Google Group= s=20 >> "pandoc-discuss" group.=20 >> To unsubscribe from this group and stop receiving emails from it, send a= n=20 >> email to=20 >> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.=20 >> >> 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 >> >> >> --=20 >> You received this message because you are subscribed to the Google Group= s=20 >> "pandoc-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send a= n=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/6d25bb08-224d-4f01-8eba= -3f1c55d19e83n%40googlegroups.com=20 >> >> . >> > --=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/282dc553-743a-4623-9f68-897468f97a7bn%40googlegroups.com. ------=_Part_9225_54120354.1670327491970 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
IT HAS BEEN SOLVED :)
Using the lua.filter here: https://gis= t.github.com/tarleb/a0646da1834318d4f71a780edaf9f870 and this filter:
function Span (span)=
 if span= .classes:includes 'mark' then
<= /div>
 return {pandoc.RawInline('la= tex', '\\hl{')} .. span.content .. {pandoc.RawInline('latex', '}')
}
e= nd
end
And now it works, but only because I = updated pandoc. In the version that Linux Mint's repo had it wouldn't work.=

On Tuesday, December 6, 2022 at 11:55:17 a.m. UTC+1 - wrote= :
OK, so= I have markdown text that includes =3D=3Dhighlighted=3D=3D words like that= . I would like to convert =3D=3Dhighlighting=3D=3D either to \hl{highlighti= ng} so LaTeX can handle it, or to highlighting, i.e. remove the symbols, so= that they just don't appear.

Thanks to you, I= now have a working filter that looks like this:

r= eturn {
=C2=A0 {
=C2=A0 =C2=A0 Str =3D function (elem)
=C2=A0 =C2= =A0 =C2=A0 if elem.text =3D=3D "highlighting" then
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 return pandoc.Emph {pandoc.Str "highlighting"}<= /div>

=C2=A0 =C2=A0 =C2=A0 else
=C2=A0 =C2=A0 =C2=A0 =C2=A0 retu= rn elem
=C2=A0 =C2=A0 =C2=A0 end
=C2=A0 =C2=A0 end,
=C2=A0 }
}<= /div>

This filter takes all instances of high= lighting and turns them into highlighting. However, ONLY if that'= ;s a whole word. If it's =3D=3Dhighlighting=3D=3D it doesn't touch = it because that's seemingly technically another word as it contains oth= er characters. In my case I would like to replace only the "=3D=3D&quo= t; but since they're attached to other characters, i.e. the actual word= , the filter doesn't touch them.

That's wh= ere I'm at right now. I'm now looking for a modification of that fi= lter so it also applies to parts of a word.
Any ideas on that?

Thanks!

=
On Tuesday, December 6, 2022 at 11:0= 0:09 a.m. UTC+1 denis...@unibe.c= h wrote:

Sorry, I haven=E2=80=99t been following from t= he beginning. Can you provide a complete example. What=E2=80= =99s your input=C2=A0? What=E2=80=99s the desired output=C2=A0?

=C2=A0

Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von paulschi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Gesendet: Dienstag, 6. Dezember 2022 01:03
An: pandoc-discuss <pandoc-...@googlegroups.c= om>
Betreff: Re: How do I replace a string in all text that pandoc conve= rts, i.e. how do I do this with a filter?

=C2=A0

I've narrowed it down! The issue isn't the c= haracters but that they're technically "part" of the word. Ho= w do I replace PART of a word?

Thanks!

=C2=A0

On Tuesday, December 6, 2022 at 12:52:05 a.m. UTC+1 = - wrote:

Barring that, can'= ;t I use something like "> =3D string.gsub("Hello banana"= , "banana", "Lua user")", if so how would I do tha= t? I got that example from http://lua-users.org/wiki/StringLibraryTutorial

On Tuesday, December 6, 2022 at 12:51:09 a.m. UTC+1 = - wrote:

I just tried that, th= anks! That works :) But this doesn't appear to work for characters, lik= e "=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, y= ou'll replace the whole paragraph with the return value of your functio= n. (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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag von paulschi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <pauls= chi...-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= 9;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</div>')=
else
return elem
end
end,
}
}
```

The problematic line is this: return pandoc.RawBlock('html','&l= t;div>abc</div>')
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 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von paulschi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Gesendet: Dienstag, 6. Dezember 2022 00:04
An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org&= gt;
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
<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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von paulschi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Gesendet: Montag, 5. Dezember 2022 18:58
An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org&= gt;
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</div>')=
else
return elem
end
end,
}
}

but that only gets rid of {{helloworld}}, it doesn't replace it with an= ything. Sadly this doens't work for "=3D=3D", i.e. those don&= #39;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&q= uot; either with something that LaTeX can use e.g. \hl or just delete it/re= place 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 &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/3ae58adb-8789-4398-8ab0-fe= 1e6928e292n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/3ae58adb-878= 9-4398-8ab0-fe1e6928e292n%40googlegroups.com?utm_medium=3Demail&utm_sou= rce=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 pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/e9cb34ca-b760-4ef6-9432-91= d37f5e45c5n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/e9cb34ca-b76= 0-4ef6-9432-91d37f5e45c5n%40googlegroups.com?utm_medium=3Demail&utm_sou= rce=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 pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.c= om>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/7cabb17e-9a2b-4251-bd95-c5= 415140c9adn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/7cabb17e-9a2= b-4251-bd95-c5415140c9adn%40googlegroups.com?utm_medium=3Demail&utm_sou= rce=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 pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.

--
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/282dc553-743a-4623-9f68-897468f97a7bn%40googlegroups.= com.
------=_Part_9225_54120354.1670327491970-- ------=_Part_9224_1114009941.1670327491970--