From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32557 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mark Pinsley Newsgroups: gmane.text.pandoc Subject: Re: removing highlights and escape values Date: Mon, 8 May 2023 13:28:34 -0400 Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000094e36f05fb31f894" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4879"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBC54T4OPXIARBUHC4SRAMGQE24Z7YMA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon May 08 19:28:52 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wm1-f58.google.com ([209.85.128.58]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pw4fM-00013H-Ey for gtp-pandoc-discuss@m.gmane-mx.org; Mon, 08 May 2023 19:28:52 +0200 Original-Received: by mail-wm1-f58.google.com with SMTP id 5b1f17b1804b1-3f33f8ffa37sf17980535e9.2 for ; Mon, 08 May 2023 10:28:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683566932; cv=pass; d=google.com; s=arc-20160816; b=IslXmrFMCE3H/HkXTNE3QM6V5VWrHUTVNAmx45I6EXc+mY3JsBl9danhVYcQaMnFW5 TsAqNca1yODsw82Rk4UQ/hxns9dEJ7SmF5YOt/ZsEVDDoFQUuFyMGYIukInetGBuVluL qe7GTBRsAVSUsPZMIxEaDAC31Rbnck/U7JlhN5hsYuLyTo6TkEujbFKIHIYh6GZbPx25 BN1BBea6MQldoTizZPdmkQSl1tPP6t6I/sXRfq5wbCS5F0ujidHJqnjwMJucsOEqplgz 92sdQNaJciuUVXdSr8GXJAz1ZFqZLznEpJoRnKiK1qbzEtKH8wS0b103Nz0XHUuHh61D LoEg== 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:to:subject:message-id:date :from:in-reply-to:references:mime-version:sender:dkim-signature; bh=CPFlFNK9fOSYuSfqE8BRCMee37NGEsC2ZHS1g1j/ofc=; b=aXokjbS0aL96f8B9HoOy6OKa7ecECOSN/F5A4y/pBQzBKDFoXBRszZA3zlr0+GAtUr OzVvzCfUoNPNtWfInrtHMtZD+DknDEyhzAT5kfdRS/LKU2lwtqHYzAMA+5B09Hfrb0EO fOwRC5g8TpO66DGVWL8l+3nHITHeUENwdWZot9wzkjFQgymBI6SlIeUJxEHux27BSVV6 5RBAzNYbjJeGZWIT7rUDFr6IWMOWzXDng9Tq/3K87CgVrs0BBVoWafMFsv8Kr5GufqYJ /fb0NgKp25SS2RuP0fGVSBKaGIT7aXP9vN0OfjjB9cAmaTyuOIZ3g+kmoWRtUIIu6N8k CZlA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@pinsley-com.20221208.gappssmtp.com header.s=20221208 header.b="AiJ/C5SK"; spf=neutral (google.com: 2a00:1450:4864:20::234 is neither permitted nor denied by best guess record for domain of mark-NHpudssogepBDgjK7y7TUQ@public.gmane.org) smtp.mailfrom=mark-NHpudssogepBDgjK7y7TUQ@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1683566932; x=1686158932; 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:to:subject :message-id:date:from:in-reply-to:references:mime-version:sender :from:to:cc:subject:date:message-id:reply-to; bh=CPFlFNK9fOSYuSfqE8BRCMee37NGEsC2ZHS1g1j/ofc=; b=DA5iHJELwcKcn5iJDm9xt38APOJ8Jrm+THEX2zRVE2XmHHakKYdocRwxmLWmQDvibY gtI9KFFRkCFc5YVkK9wrO6Mq1SsGgHFquITZZE0p0faqwFCTdZQ+pj0QVhTYGoEC51g8 QB1DxujGWyKg0msigPq9EVkTKkW1yBF0e4dGfNJ+NqPDwM5NFo5Rxy7HnfbVZsuBN+VR ZMbivjeFDKGriiXi6y/kqsmI6zBhBeIKJO8h9CNiyVQVNExC+Ii+XZpP6GaE6XXTMq0d bYwbprKpb7AAwKWujoO9BG2wKbva3k30N9nqGxR7jdqovcfCorOZ7A/gadl8YO/GARFR X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683566932; x=1686158932; 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:to:subject :message-id:date:from:in-reply-to:references:mime-version :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=CPFlFNK9fOSYuSfqE8BRCMee37NGEsC2ZHS1g1j/ofc=; b=SBoZHlZoH37WII0+zWWNZ63fPK4CMvjiBO8XP7cBbcVRAPI5uG+39NYjsnN4KC8UeY 1AB+upT6SRNTJ0z2T3viFdZDWr/+3BeKy3SJ4y06y6lIlqjUOLFt9nvAb+GcGz66tYki HNMTj5lyNV8JyIj4x12Y5fGtBUnHKpF7f2Hnl+U/XxtvhZFSf7Ltn0GadNMkYFAZkVW/ hFyWOdSY4WC7KsCQj3kX7GWcZVkHveunXwPZCuhy88BSZmJ6BV01O7aOvuZKg+ZmY7yJ QLor6Y Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDx99stI4pf9jAngqDZFQ2sy32f8OgbZCWCO3kXsusZZc/A+c+w8 G6dQPgGYQ6qM9+tEYoqJu0U= X-Google-Smtp-Source: ACHHUZ5yEWkVux51nTFxKuKSos/Cpb/4+TEPrfo1TOMzWAb71x3GjbPGHHW0CETofQP8eaaeBNxfdA== X-Received: by 2002:a05:600c:2310:b0:3f0:9845:6994 with SMTP id 16-20020a05600c231000b003f098456994mr1985800wmo.7.1683566932130; Mon, 08 May 2023 10:28:52 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a5d:5e93:0:b0:2f4:1b04:ed8f with SMTP id ck19-20020a5d5e93000000b002f41b04ed8fls1771992wrb.1.-pod-prod-gmail; Mon, 08 May 2023 10:28:48 -0700 (PDT) X-Received: by 2002:adf:eec8:0:b0:306:2656:66d4 with SMTP id a8-20020adfeec8000000b00306265666d4mr7630668wrp.58.1683566927964; Mon, 08 May 2023 10:28:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683566927; cv=none; d=google.com; s=arc-20160816; b=Ce3dFH6gV/kVE2Key7xcxWPn6ugcGFwge98dBT4pjnnBU5Mwir8r/hd7xKHuRzWgmw 3R4A2ki4k1lDdRpg6V139yE95cRwRVrhhs5TGXxz9GaZJH5LqwjqScIiQX+dGAElLx/n xqYocVq5x01epjhArO2vX74sau1KtRRhC+DzIImgTQv2suE1KzNX/SPnVRG+iFqmRePP m+wKk5UEHqjYCWYVD8qNbQzz9wucO5gd22eeGYJXMv/xq0S+TaogTG0n+ZcX2HKowO8S 8RX9K1mShDpp+Tu1E9yrwfjUtzwp8Ois2d1sLzB21gT4oOL4WZOs3rulhHAHnPXGEyDW 7xjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Y4NNKAtNka7Sa3HSLp8/t3poWedvezrY/z6eJ5tpSKg=; b=nOkjig11Ph4Awz2GiQ6ZjzOpvdVtkvXk9yffiAAGco+BOYe4VUiPC3XmHKpbuWKOnm YKmQugvKWmEMOwlpKfa3gIu0vUWApzYWpRtjFt29xM0bbKJKpG9Xfwu3CUBhMcowHKfu eKKxnhHv5GQ/+LHy+ljj9+UIM4HzjZFppER3Tp2qeIMfhf53VdYSTRZvtQgFBtoQJH1s BDSxxpEZEYyFDGf2HEHludptObE8CcE3ues7v6PVBfFvvDzrKQUGQk35MzfEF8Trj04+ kPjxKvjgPY9TMOSZioyTv0XhKFI7sg4CeuJDM746sTPG82ESatcUPjRerf+yUG+MoRMB jNdA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@pinsley-com.20221208.gappssmtp.com header.s=20221208 header.b="AiJ/C5SK"; spf=neutral (google.com: 2a00:1450:4864:20::234 is neither permitted nor denied by best guess record for domain of mark-NHpudssogepBDgjK7y7TUQ@public.gmane.org) smtp.mailfrom=mark-NHpudssogepBDgjK7y7TUQ@public.gmane.org Original-Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com. [2a00:1450:4864:20::234]) by gmr-mx.google.com with ESMTPS id cc5-20020a5d5c05000000b002f419cfd872si533717wrb.3.2023.05.08.10.28.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 May 2023 10:28:47 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:4864:20::234 is neither permitted nor denied by best guess record for domain of mark-NHpudssogepBDgjK7y7TUQ@public.gmane.org) client-ip=2a00:1450:4864:20::234; Original-Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2ac89e6a5a1so41397781fa.0 for ; Mon, 08 May 2023 10:28:47 -0700 (PDT) X-Received: by 2002:ac2:4151:0:b0:4ec:6251:fcb4 with SMTP id c17-20020ac24151000000b004ec6251fcb4mr2524916lfi.38.1683566926024; Mon, 08 May 2023 10:28:46 -0700 (PDT) In-Reply-To: X-Original-Sender: mark-NHpudssogepBDgjK7y7TUQ@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@pinsley-com.20221208.gappssmtp.com header.s=20221208 header.b="AiJ/C5SK"; spf=neutral (google.com: 2a00:1450:4864:20::234 is neither permitted nor denied by best guess record for domain of mark-NHpudssogepBDgjK7y7TUQ@public.gmane.org) smtp.mailfrom=mark-NHpudssogepBDgjK7y7TUQ@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:32557 Archived-At: --00000000000094e36f05fb31f894 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 trying to 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 > 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 >> 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 highlighting >> >> ChatGPT wrote this LUA for me but it doesn't seem to work. Are there >> 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 remove_escaped_quotes.lu= a >> --wrap=3Dnone --reference-links -o output.md >> >> Is there another way, or did I do something wrong? >> >> -- >> You received this message because you are subscribed to the Google Group= s >> "pandoc-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send a= n >> email 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/ef709575-3717-493f-b6d8= -62862c98d3d8n%40googlegroups.com >> >> . >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "pandoc-discuss" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/pandoc-discuss/dF3psW96pkA/unsubscribe. > To unsubscribe from this group and all its topics, send an email 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/CADAJKhA_g%3D6gfAJONkb3A= wdQ9Xqn8PvwUg-fAVEjsKE56%2B%2BgFg%40mail.gmail.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/CAOtJyj5-%2Bo3%3Dw-dT1wYbusgTsRv%3D0JA5J3LE96mN53sAE9eQkg%40= mail.gmail.com. --00000000000094e36f05fb31f894 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you!

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


3D""
On Mon, May 8, 2023 at 11:59=E2=80=AFAM BPJ <melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Don't use ChatGPT t= o "write code"! You will get garbage which may harm your computer= and/or files if you run it!

This filter will do what you want:

``````lua
local st= r =3D pandoc.Str
local function quote (q)
=C2=A0 return pandoc.RawInline('markdown', q)
end
local quote_pat =3D re.compile(
=C2=A0 [[ {| ( [^"']+ -> str / ["= 9;] -> quote )* |} ]],
=C2=A0 { str =3D str, quot= e =3D quote }
)
function Str = (elem)
=C2=A0 return quote_pat:match(elem.text)
end
function Span (elem)
=C2=A0 if 1 =3D=3D #elem.classes and 'mark' =3D=3D e= lem.classes[1] then
=C2=A0 =C2=A0 return elem.conten= t
=C2=A0 end
=C2=A0 return ni= l
end
``````

/bpj

Den m=C3=A5n 8 maj 2023= 00:09Mark Pinsley <mark-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 quo= tes and double quotes

For ease of someone being ab= le to look at this MD, i want to remove the escape sequece for the quotes a= nd double quotes.

I also want to remove the highli= ghting

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

functio= n 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 i= f inline.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, inlin= e)
=C2=A0 =C2=A0 end
=C2=A0 =C2=A0 return result
end

functi= on process_blocks(blocks)
=C2=A0 =C2=A0 local result =3D {}
=C2=A0 = =C2=A0 for _, block in ipairs(blocks) do
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if = block.content then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 block.conte= nt =3D process_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 e= nd
=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 retur= n doc
end

the command I used was:
=C2=A0pandoc "TestHighlightQuotes.docx" --lua-filter remove_esca= ped_quotes.lua --wrap=3Dnone --reference-links -o output.md
<= br>
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-discuss+unsubscribe@googlegroups.c= om.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/ef709575-371= 7-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://g= roups.google.com/d/topic/pandoc-discuss/dF3psW96pkA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to p= andoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhA_g%3D= 6gfAJONkb3AwdQ9Xqn8PvwUg-fAVEjsKE56%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://g= roups.google.com/d/msgid/pandoc-discuss/CAOtJyj5-%2Bo3%3Dw-dT1wYbusgTsRv%3D= 0JA5J3LE96mN53sAE9eQkg%40mail.gmail.com.
--00000000000094e36f05fb31f894--