From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/31847 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:32:23 -0800 (PST) Message-ID: <7cabb17e-9a2b-4251-bd95-c5415140c9adn@googlegroups.com> References: <83eeff5c-8fc3-4ca3-862c-bb85790daabcn@googlegroups.com> <3ae58adb-8789-4398-8ab0-fe1e6928e292n@googlegroups.com> <24509d5ca5844dbda07b3e77d86ab3f4@unibe.ch> <2faac96e448d4303b3ea0e12ef05dfbe@unibe.ch> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_8078_1380127446.1670283143194" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37671"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDR3RNPJ3YORBCH7XGOAMGQEITAPL3Q-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Dec 06 00:32:28 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oi1-f191.google.com ([209.85.167.191]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p2Kwl-0009Zj-G1 for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 06 Dec 2022 00:32:27 +0100 Original-Received: by mail-oi1-f191.google.com with SMTP id bo36-20020a05680822a400b00359dee97833sf5838539oib.1 for ; Mon, 05 Dec 2022 15:32:27 -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=KHAOx0/YwXurfXrCAebroAjd4HBCF+wJpGx8oWSNrbU=; b=WcPJld457T6bWjonpWITu3Q9bRc7+k48q7PC62rlvlbe2YXR0slwM0u4uIGA2wpWlz bzesJIsnyLaTHAXk9jIhtmdH3KI+5NpYZYKZvMIE+glQCPUJGI8TLFV88FFvhfUUJRSF SeJrV7VomIYXbdSudwx+9Zo4lrm2//U9UaX+3eiRHbtOBhw5cMn/K1SyYrbdOMX8Jpki SLhptEL95SD9C5qb/DxDHks/+CnNYpE8YXdkw6qRODIc5m5Sp7rLnIpQmrL30iyvMcyE QNMU5ORxLV3LfAXp5pnMA3o38nbjpjDiXXWFg3cvxjU+YuyAmmSwDWkto3OHk8SnDdc3 eCfQ== 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=KHAOx0/YwXurfXrCAebroAjd4HBCF+wJpGx8oWSNrbU=; b=KX7bhsk/7ziny2Z8qahOWZgTNYZHtH3Etm3QQtJ5vmhgJ4BH7jE+CVU/5BJlmZCNUm 0Ky7wY81HUhWi/KSVy6/C7PaxHSgtLqSoN+FTdTnmnCuhtifVgp1y/GGjAWyRvkh03Wh cmL6qfHtHimuBN/tjB6ysmRNBkf6ESwClzvimZv68Rc/OWeJ6sBCZcWY2KMT2tORYC/Z 4OYGJ8a7MKucd67LtNCQ0E+1yDLsntbYaJagyGwQrut0z6T4aJg2e1ok8qmzW0akkFDI Nxoz3kuphvZpkxRZSyBLz7cbm+lUWLj7950RVlPTEZsG1Ei/HwI+IoQXeIiTJ2ALMRyL HdGg== 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=KHAOx0/YwXurfXrCAebroAjd4HBCF+wJpGx8oWSNrbU=; b=cbfAke0W9hN0S0PTYYTS/ADOUpfTAQy1nV7YaEY7t0zvK1BKvceGWN+sjaa20hYxMw /1KWD0T0WlnHmUV/U+tDTvBVOMf8GhDz7L2K9oS6VflllTKAdvR0PwjhT6KVqw05uLwR 84SeDCBpr7iE/DZdtouMG8ZYcq2ou3eSJtLQRi+fjXxeVb3+yUnN8R11A522INpewrSN QYMqSL11kmmZUDsVNoyq/d+MtFpRw6NZ+tXh+a0ngmCYWcbrHaM8SykFV34fSa6evso0 BJ4Y7foZXJkegat9cO5c8invBR7RUlSgjX6slAeXM0E5qIA7hLE9ipkfUvRFbe+IrvPe Xe4Q== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ANoB5plzCT6qcKnXPmVAYwH5dFevvfq8NGWfpY9jvKv9YWnp6PX79kw4 GYWdEFw3xS/cG4MFa62ulXo= X-Google-Smtp-Source: AA0mqf6gtr8WUdzTU1NYMKtgznIOvZEiehqXqPCw4Gg8hkJVDyECAdwK53+MSzeHeKQw8Q5wxLcfhA== X-Received: by 2002:a05:6870:89a1:b0:131:cba0:3b4a with SMTP id f33-20020a05687089a100b00131cba03b4amr45791657oaq.6.1670283146413; Mon, 05 Dec 2022 15:32:26 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6870:c395:b0:144:d97:cccb with SMTP id g21-20020a056870c39500b001440d97cccbls2006469oao.1.-pod-prod-gmail; Mon, 05 Dec 2022 15:32:24 -0800 (PST) X-Received: by 2002:a05:6870:9a8c:b0:144:9227:7292 with SMTP id hp12-20020a0568709a8c00b0014492277292mr4328958oab.10.1670283143912; Mon, 05 Dec 2022 15:32:23 -0800 (PST) In-Reply-To: <2faac96e448d4303b3ea0e12ef05dfbe-NSENcxR/0n0@public.gmane.org> 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:31847 Archived-At: ------=_Part_8078_1380127446.1670283143194 Content-Type: multipart/alternative; boundary="----=_Part_8079_721642052.1670283143194" ------=_Part_8079_721642052.1670283143194 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 wrote= : > Just your example filter: > > =20 > > ```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, > } > } > > ``` > > =20 > > 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. > > =20 > > If your target ist latex, you=E2=80=99ll need something like this: return= =20 > pandoc.RawBlock('latex','\\whatever{abc}') > > =20 > > ```cmd > > pandoc test.md -L filter.lua -t latex > > asf > > =20 > > \whatever{abc} > > =20 > > asf > > ``` > > =20 > > =20 > > *Von:* pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org *Im=20 > Auftrag 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=20 > converts, i.e. how do I do this with a filter? > > =20 > > 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! > > =20 > > 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. > > =20 > > ```cmd > > C:\Users\denis\Downloads\filter>cat test.md > > asf > > =20 > > {{helloworld}} > > =20 > > asf > > C:\Users\denis\Downloads\filter>pandoc test.md > >

asf

> >

{{helloworld}}

> >

asf

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

asf

> >
abc
> >

asf

> > ``` > > *Von:* pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org *Im=20 > Auftrag 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=20 > converts, i.e. how do I do this with a filter? > > =20 > > I've tried this:=20 > > =20 > > return { > { > Para =3D function (elem) > if elem.content[1].text =3D=3D "{{helloworld}}" then > return pandoc.RawBlock('html','
abc
') > else > return elem > end > end, > } > } > > =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 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. > > =20 > > I've tried this: > > 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 > 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=20 > > . > > --=20 > 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=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/7cabb17e-9a2b-4251-bd95-c5415140c9adn%40googlegroups.com. ------=_Part_8079_721642052.1670283143194 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
YES! that works! But can you tell me why it replaces the whole line? C= an't I do this in running text?
Thanks!
return {
&nbs= p; {
    Para =3D function (elem)
      if e= lem.content[1].text =3D=3D "{{helloworld}}" then
      &n= bsp; return pandoc.RawBlock('latex','abc')
      else
=         return elem
      end
&nbs= p;   end,
  }
}




On Tuesday, December 6, 2022 at 1= 2:09:13 a.m. UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:

Just your example filter:=

=C2=A0

```lua

return {
=C2=A0 {
=C2=A0 =C2=A0 Para =3D function (elem)
=C2=A0 =C2=A0 =C2=A0 if elem.content[1].text =3D=3D "{{helloworld}}&qu= ot; then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return pandoc.RawBlock('html','<= div>abc</div>')
=C2=A0 =C2=A0 =C2=A0 else
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return elem
=C2=A0 =C2=A0 =C2=A0 end
=C2=A0 =C2=A0 end,
=C2=A0 }
}

```

=C2=A0

The problematic line is this: return pandoc.RawBlock= ('html','<div>abc</div>')

This adds a raw block that will only come in to effe= ct when your output format is html.

=C2=A0

If your target ist latex, you=E2=80=99ll need someth= ing like this: return pandoc.RawBlock('latex','\\whatever{abc}&= #39;)

=C2=A0

```cmd

pandoc test.md -L filter.lua -t= latex

asf

=C2=A0

\whatever{abc}

=C2=A0

asf

```

=C2=A0

=C2=A0

Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...@googlegroups.c= om> Im Auftrag von paulschi..= .@gmail.com
Gesendet: Dienstag, 6. Dezember 2022 00:04
An: pandoc-discuss <pa= ndoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
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

No, my intended output is a PDF file. Does that chan= ge anything? Could you tell me what exactly you put in filter.lua?

Thanks!

=C2=A0

On Monday, December 5, 2022 at 11:56:39 p.m. UTC+1 <= a href data-email-masked rel=3D"nofollow"> denis...-NSENcxR/0n0@public.gmane.org wrote:

What exactly are you doing? You= r output format is html? I=E2=80=99ve just tested this and it seems to work.

=C2=A0

```cmd

C:\Users\denis\Downloads\filter>cat test.md

asf

=C2=A0

{{helloworld}}

=C2=A0

asf

C:\Users\denis\Downloads\filter>pandoc test.md=

<p>asf</p>

<p>{{helloworld}}</p>

<p>asf</p>

=C2=A0

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

<p>asf</p>

<div>abc</div>

<p>asf</p>

```

Von: pandoc-...-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.org= m <pandoc-..= .@googlegroups.com> Im Auftrag von paul= schi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Gesendet: Montag, 5. Dezember 2022 18:58
An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
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 tried this:

=C2=A0

return {
=C2=A0 {
=C2=A0 =C2=A0 Para =3D function (elem)
=C2=A0 =C2=A0 =C2=A0 if elem.content[1].text =3D=3D "{{helloworld}}&qu= ot; then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return pandoc.RawBlock('html','<= div>abc</div>')
=C2=A0 =C2=A0 =C2=A0 else
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return elem
=C2=A0 =C2=A0 =C2=A0 end
=C2=A0 =C2=A0 end,
=C2=A0 }
}

=C2=A0

but that only gets rid of {{helloworld}}, it doesn&#= 39;t replace it with 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 hi= ghlights "=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.

=C2=A0

I've tried this:

function Str (str)=C2=A0

str.text =3D string.upper(str.text)

return str

end

=C2=A0

But I can't even figure out where I'm meant = to put my own text?

=C2=A0

How do I rpelace =3D=3D with " "?

=C2=A0

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...@googlegro= ups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/3ae58adb-8789-4398-8ab0-fe= 1e6928e292n%40googlegroups.com.

--
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...-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.org= m.

--
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/7cabb17e-9a2b-4251-bd95-c5415140c9adn%40googlegroups.= com.
------=_Part_8079_721642052.1670283143194-- ------=_Part_8078_1380127446.1670283143194--