From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32564 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephan Meijer Newsgroups: gmane.text.pandoc Subject: Re: removing highlights and escape values Date: Tue, 9 May 2023 03:58:43 -0700 (PDT) Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_3727_1564828933.1683629923221" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31627"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCYOPL5A34MBBZGO5CRAMGQEMMCYSGI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue May 09 12:58:48 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oa1-f59.google.com ([209.85.160.59]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pwL3P-00083e-Lf for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 09 May 2023 12:58:47 +0200 Original-Received: by mail-oa1-f59.google.com with SMTP id 586e51a60fabf-192544d7c8csf3925882fac.3 for ; Tue, 09 May 2023 03:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1683629926; x=1686221926; 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=rZF2ATuG+me60RZk9YNBueqBIcP4XiyVJbS1PPAOBPY=; b=o0fLYV5wYJbdiRild4rKhHTjSpi3mkrm/5YxdsxJ1D4vpULodb70UCCTX0ZohFYvXi RO6wHy4pcUmFukiL8maHTliLkDrtniR/NUPZzWXTsZ8UUeow5oQJ68Y7lpwQcuV9ST+k YyhWTtdZ7cCP2mpbJXpbnQ3QUjWiQdiXz50oJnLOdImfVj/Qvw7LpPB1HBtuBcgkIZvk WuyE/LVElI5mqVidC96NJaJFtr81MpLsWmTzbOy7ZgLT8sMaecjlxM9l1mR8flp1/C4H U4rYMEPo/OPAQqFOpLAiDy5pOYQyjgHsMzwbTobAc5US0BZj7YjEdrWddmUbZvMZh62H 9VcA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stephanmeijer-com.20221208.gappssmtp.com; s=20221208; t=1683629926; x=1686221926; 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=rZF2ATuG+me60RZk9YNBueqBIcP4XiyVJbS1PPAOBPY=; b=ArhmvKiv9CcTRd75lvcdEq/rjdjUXl2jx3TRbVJDRcVdmtl+/3CKPp6PxWBGV1+mIx uMkcR5m9E3gu+B5SXv0aleZEvTN8CdKCNmhSnNhSWI8Qtw4fnWhx7q8yW3EFcy3u5HPt PQnxMb7nx+54W5eV/4Z95spOPnJFfn8OUQk4KakVwCWVr0CyTqeSkcNcP9SY4K5RQbPR KY7pPDzN+1r2PBZaD9LFvUG3WBbPyv4kpRHLhZAtw8aXSZYDyRljXDx2BpTl6VKuDy1N l/hcWkeba1Q38l47otOIrQVOGTOrI9hwCapuKLbpXqpwU3earRmUNH2uTYH0WVgYzDKt rTJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683629926; x=1686221926; 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-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=rZF2ATuG+me60RZk9YNBueqBIcP4XiyVJbS1PPAOBPY=; b=ZfgoPCPEhPo3+4lqvCDmmLzj4JT4gKC6Q3N25MhVL2YWXjMLIvTXOY6mO1kmzry003 jw6VBy4w8Lqvpyl8HHLas/LmxZkubjCGLfk4V0eVTzmEgAsqCSOM+DmP7hUgKo0ANvka 1igMAzrC5hA3wkltrx827Cwu3TttbyKlKPb74z1gsREGWB1SITuYOwhOh16hhm7f9ahP e2F8gokAP/AsEOphj9nwHNV6U83WmG25b67tyO06Zg3zL+WJFRlLKX0eK3rubjXvWBeD CRhx0Zf+jJTJoPRTsPe8DnY1n3rpWoYF/UBS3Mf0InQfHmXrsH Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDxIMheER7pYyMVo3c+sDNT3UWFbHBiWL9D2D9qNk1FMSicne0MG YeLYE0mJBj7gtnlC1SisMnI= X-Google-Smtp-Source: ACHHUZ4L9yfmt9RwY8MKaQSUWDktnwekCFMJ6aPKh3CAZgwNbDXSY6ZIA/NOatw5ICkyGTU7NWWKhA== X-Received: by 2002:a05:6871:4d8f:b0:193:2d1a:3660 with SMTP id uh15-20020a0568714d8f00b001932d1a3660mr5544687oab.3.1683629926515; Tue, 09 May 2023 03:58:46 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6870:a8b2:b0:187:af40:abce with SMTP id eb50-20020a056870a8b200b00187af40abcels7287oab.1.-pod-prod-00-us; Tue, 09 May 2023 03:58:44 -0700 (PDT) X-Received: by 2002:a9d:32e:0:b0:6a5:e464:f0b7 with SMTP id 43-20020a9d032e000000b006a5e464f0b7mr594155otv.3.1683629923807; Tue, 09 May 2023 03:58:43 -0700 (PDT) In-Reply-To: X-Original-Sender: me-nPKYAObcRdo6Blr+0TYHagC/G2K4zDHf@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:32564 Archived-At: ------=_Part_3727_1564828933.1683629923221 Content-Type: multipart/alternative; boundary="----=_Part_3728_815537900.1683629923221" ------=_Part_3728_815537900.1683629923221 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable *> Don't use ChatGPT to "write code"! You will get garbage which may harm= =20 your computer and/or files if you run it!* I am sure It won't damage your computer. It will probably be not perfect,= =20 but with some common sense you will be safe. On Monday, 8 May 2023 at 19:28:52 UTC+2 Mark Pinsley wrote: > Thank you! > > Yeah ChatGPT isn't really very good at writing code unless you already=20 > know what you are doing. Then you can modify it. For me, I was trying to= =20 > find a way to write this. Thank you! > > > On Mon, May 8, 2023 at 11:59=E2=80=AFAM BPJ wrote: > >> Don't use ChatGPT to "write code"! You will get garbage which may harm= =20 >> your computer and/or files if you run it! >> >> This filter will do what you want: >> >> ``````lua >> local str =3D pandoc.Str >> local function quote (q) >> return pandoc.RawInline('markdown', q) >> end >> local quote_pat =3D re.compile( >> [[ {| ( [^"']+ -> str / ["'] -> quote )* |} ]], >> { str =3D str, quote =3D quote } >> ) >> function Str (elem) >> return quote_pat:match(elem.text) >> end >> function Span (elem) >> if 1 =3D=3D #elem.classes and 'mark' =3D=3D elem.classes[1] then >> return elem.content >> end >> return nil >> end >> `````` >> >> /bpj >> >> Den m=C3=A5n 8 maj 2023 00:09Mark Pinsley skrev: >> >>> I have a bunch of docx that I want to convert to MD. >>> >>> The file contains highlighting and it also contains both quotes and=20 >>> double quotes >>> >>> For ease of someone being able to look at this MD, i want to remove the= =20 >>> escape sequece for the quotes and double quotes. >>> >>> I also want to remove the highlighting >>> >>> ChatGPT wrote this LUA for me but it doesn't seem to work. Are there=20 >>> alternatives >>> >>> function process_inlines(inlines) >>> local result =3D {} >>> for _, inline in ipairs(inlines) do >>> if inline.t =3D=3D "Str" then >>> inline.text =3D inline.text:gsub('\\"', '"'):gsub("\\'", "'= ") >>> elseif inline.content then >>> inline.content =3D process_inlines(inline.content) >>> end >>> table.insert(result, inline) >>> end >>> return result >>> end >>> >>> function process_blocks(blocks) >>> local result =3D {} >>> for _, block in ipairs(blocks) do >>> if block.content then >>> block.content =3D process_inlines(block.content) >>> end >>> table.insert(result, block) >>> end >>> return result >>> end >>> >>> function Pandoc(doc) >>> doc.blocks =3D process_blocks(doc.blocks) >>> return doc >>> end >>> >>> the command I used was: >>> pandoc "TestHighlightQuotes.docx" --lua-filter=20 >>> remove_escaped_quotes.lua --wrap=3Dnone --reference-links -o output.md >>> >>> Is there another way, or did I do something wrong? >>> >>> --=20 >>> You received this message because you are subscribed to the Google=20 >>> Groups "pandoc-discuss" group. >>> To unsubscribe from this group and stop receiving emails from it, send= =20 >>> an 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/ef709575-3717-493f-b6d= 8-62862c98d3d8n%40googlegroups.com=20 >>> >>> . >>> >> --=20 >> > You received this message because you are subscribed to a topic in the=20 >> Google Groups "pandoc-discuss" group. >> To unsubscribe from this topic, visit=20 >> https://groups.google.com/d/topic/pandoc-discuss/dF3psW96pkA/unsubscribe= . >> To unsubscribe from this group and all its topics, send an email to=20 >> 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/CADAJKhA_g%3D6gfAJONkb3= AwdQ9Xqn8PvwUg-fAVEjsKE56%2B%2BgFg%40mail.gmail.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/bc3186fd-822a-40da-99d2-9454caeabb3en%40googlegroups.com. ------=_Part_3728_815537900.1683629923221 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > Don't use ChatGPT to "write code"! You will get garbage which may h= arm your computer and/or files if you run it!

I am= sure It won't damage your computer. It will probably be not perfect, but w= ith some common sense you will be safe.

On Monday, 8 May 2023 at 19= :28:52 UTC+2 Mark Pinsley wrote:
Thank you!

Yeah ChatGPT isn't really very good at writing code unless you= already know what you are doing. Then you can modify it. For me, I was try= ing to find a way to write this. Thank you!


<= img width=3D"0" height=3D"0" alt=3D"" style=3D"display:flex" src=3D"https:/= /ci4.googleusercontent.com/proxy/FWMD169PODbu4bvmKwGPHm5N7wpu4rWXG5fyEVMYGT= 6UaATsaPGsbMLPAHt4ptiwXcvJA4b6WzSQe1NUL88c5HsWR18hcxZfcmfhhd6fJsV51ilSC8MnH= _xlYauSJiqVBAZ2zcLYrjSz=3Ds0-d-e1-ft#https://mailtrack.io/trace/mail/e67f55= 4c6cb684a07c66ff899766da2111087f5f.png?u=3D8226678">
On Mon, May 8, 2023 at 11:59=E2=80=AFAM BPJ <mel...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
<= /div>
Don't use Ch= atGPT to "write code"! You will get garbage which may harm your c= omputer and/or files if you run it!

This filter will do what you want:

<= /div>
``````lua
l= ocal str =3D pandoc.Str
local function quote (q)
=C2=A0 return pandoc.RawInline('markdown', q)
end
local quote_pat =3D re.com= pile(
=C2=A0 [[ {| ( [^"']+ -> str / [&q= uot;'] -> quote )* |} ]],
=C2=A0 { str =3D st= r, quote =3D quote }
)
functi= on Str (elem)
=C2=A0 return quote_pat:match(elem.tex= t)
end
function Span (elem)
=C2=A0 if 1 =3D=3D #elem.classes and 'mark' = =3D=3D elem.classes[1] then
=C2=A0 =C2=A0 return ele= m.content
=C2=A0 end
=C2=A0 r= eturn nil
end
``````

/bpj

Den m=C3=A5n 8 = maj 2023 00:09Mark Pinsley <m= a...-NHpudssogepBDgjK7y7TUQ@public.gmane.org> skrev:
I have a bunch of docx that I want to convert to MD.
The file contains highlighting and it also contains both quote= s and double quotes

For ease of someone being able= to look at this MD, i want to remove the escape sequece for the quotes and= double quotes.

I also want to remove the highligh= ting

ChatGPT wrote this LUA for me but it doesn= 9;t seem to work. Are there alternatives

function = process_inlines(inlines)
=C2=A0 =C2=A0 local result =3D {}
=C2=A0 =C2= =A0 for _, inline in ipairs(inlines) do
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if i= nline.t =3D=3D "Str" then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 inline.text =3D inline.text:gsub('\\"', '"'= ;):gsub("\\'", "'")
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 elseif inline.content then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= inline.content =3D process_inlines(inline.content)
=C2=A0 =C2=A0 =C2=A0= =C2=A0 end
=C2=A0 =C2=A0 =C2=A0 =C2=A0 table.insert(result, inline)
= =C2=A0 =C2=A0 end
=C2=A0 =C2=A0 return result
end

function pro= cess_blocks(blocks)
=C2=A0 =C2=A0 local result =3D {}
=C2=A0 =C2=A0 f= or _, block in ipairs(blocks) do
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if block.co= ntent then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 block.content =3D p= rocess_inlines(block.content)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 end
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 table.insert(result, block)
=C2=A0 =C2=A0 end
= =C2=A0 =C2=A0 return result
end

function Pandoc(doc)
=C2=A0 = =C2=A0 doc.blocks =3D process_blocks(doc.blocks)
=C2=A0 =C2=A0 return do= c
end

the command I used was:
=C2= =A0pandoc "TestHighlightQuotes.docx" --lua-filter remove_escaped_= quotes.lua --wrap=3Dnone --reference-links -o output.md

<= /div>
Is there another way, or did I do something wrong?

=

--
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= ...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discus= s/ef709575-3717-493f-b6d8-62862c98d3d8n%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Goog= le Groups "pandoc-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pandoc-discuss/dF3psW96pkA/un= subscribe.
To unsubscribe from this group and all its topics, send an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.<= br> To view this discussion on the web visit https://groups.= google.com/d/msgid/pandoc-discuss/CADAJKhA_g%3D6gfAJONkb3AwdQ9Xqn8PvwUg-fAV= EjsKE56%2B%2BgFg%40mail.gmail.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 pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d= /msgid/pandoc-discuss/bc3186fd-822a-40da-99d2-9454caeabb3en%40googlegroups.= com.
------=_Part_3728_815537900.1683629923221-- ------=_Part_3727_1564828933.1683629923221--