From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32556 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: BPJ Newsgroups: gmane.text.pandoc Subject: Re: removing highlights and escape values Date: Mon, 8 May 2023 17:59:00 +0200 Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000015087e05fb30b87d" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26671"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCWMVYEK54FRBTNY4SRAMGQEMHWN2WQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon May 08 17:59:13 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-qk1-f190.google.com ([209.85.222.190]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pw3Gb-0006lF-3U for gtp-pandoc-discuss@m.gmane-mx.org; Mon, 08 May 2023 17:59:13 +0200 Original-Received: by mail-qk1-f190.google.com with SMTP id af79cd13be357-74e3f0a830csf283650085a.0 for ; Mon, 08 May 2023 08:59:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683561552; cv=pass; d=google.com; s=arc-20160816; b=B5Ra2D6NRJzNqbFn06BVaW+4BeEGgKLCs8IN8pfMyVdInEBxrxFyeC/K1PKQkuJaNk p4MrazzbMeORsfFstckQCO/vXKELIhNEf72XMW6pNUH1k4gh2tiEDPMQyyhsVq0HIcPx W/P6uiDWqdPmywT3whVWbdcmpA8K5pCvqX2MJ5B9KeezBGeAObQt4viM8KfhYnK4EC9a 8bi6vgMz3eN9yr4cNcEnBF1FxiMS/j8Qu/z0Ca31ciUYk9rNSAo4d1v0zdhxSxUvJ1d6 jl6Cxv0O/VN/kCP4hjtG6DzD1gxEc6XRftBewlypkXPxAku+NWqzGF/i38UFT0RlOAf0 zBZg== 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 :dkim-signature; bh=XxMpW7wXpvMrUKBNMmxgWk9+fCq/3uzmezfzVq27UPs=; b=xz8NaofuB3HCfr/Vi5h84Lf/7FL98vyErwYjxfp7jRakG6lvVWNUTjEb3UPqvTMOWp 6N0qhOZqNaBwGg2zyX+u2f2VKZdMf/WkJY4FycZfyFbQdF/hKrpZ0i2zDndM4rV183fG RfoRQ07M8y1NiRySH9xEZPzLKFCuzwCOeeEEivBk9FKFcbtRgomZpgNI8hUDe2spRchx SIuS0T5+Erp+NqiVUZhxvBSy27xn4c7s27fnwllmoawRtGGf4Zc+33fyPNRZINnwVKlf QtjX2KbtPZfU/Ri2tmf/x/TBk0AbGaeQSJABt9HhF3RST1HE81LtQyvvVhv04WWKOJyU 5E3A== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=F8JQZyZk; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::1135 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1683561552; x=1686153552; 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=XxMpW7wXpvMrUKBNMmxgWk9+fCq/3uzmezfzVq27UPs=; b=s24JdabGYIRDK1G+jnSuVksVwINldyZeP8FKrkx4VITHDBPIjryYdf+xRi1iryzEBw rV/65wK9GxYk5c34nftVRTRLtjBxlvRTMKUpjwjWr9Y1HHIPOeTUF7Yd4PMpxRBnM7zX KUBaaLpxj8qKcGsoowOKyr84/GX235Vv2A0HSwOIsM+oaVR0Vic2Fv8766/Sa7pfBik4 67KoCA7aFdy02sKgsHcdGFYX+GeaVHPiJ4jMRZcriakn7eBeJGQciBtMlnEYcURyvaWT vkwMpGcIlSoCZyu79kuClU8TaHVWUoQnjLoCl9JLY5WNiCAuKq/0z7c958APTD/IhKIR DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683561552; x=1686153552; 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:from:to:cc :subject:date:message-id:reply-to; bh=XxMpW7wXpvMrUKBNMmxgWk9+fCq/3uzmezfzVq27UPs=; b=J961+TemmkecwgAt3IUNuaLaykNy0mT8QVK8MzRK2eNF/DvCMvl7AcWF28SDncuZhX PYtTP8LLTd2P5HCpmMvru+qpmTuiJwJ+xR+yvx3TnEugLHTrJ15LM+8veiQnDSKtkEbW xOH68F/KdlX0LMVV7sZqnyGKk3ObvJdunkbkzhMLxfNTUsLzNuKG/rdMNGC8UoRJ4BNY V8uogDVmEHWRz9ZzGv00pkVTXdNKdltHwKeuUbXyU/0AR3WCE1B23OlrCLTrFH+fXidx 4NSt2qGtbbuYyHmkDaOY95zzI+J8nZQNGmcU35kOqO7/xLvEdRqjgi2YvdRCZ0srZ3MD IQ+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683561552; x=1686153552; 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=XxMpW7wXpvMrUKBNMmxgWk9+fCq/3uzmezfzVq27UPs=; b=jeAnSvLSR2CTglUS+R4FYqmW5BIz8V3aX2V6o+AXUVft12ZnXSyFOfh8MLeY6DmyEf M/vdlVcA57Iuo17dObUhj73eQT2idNH6gJXpcu/QGCm45BLCfydkq54Q2ibPCpWuQjWT NDhZHNfSXKOV7+JiySr18nPw0oCnhb/ak9bsNQEA9oUFK8UFz8me4oNzuneX1/NOiNaO guYzqg4W2+Bb2gjfdLMnShKsbqASdixxiTrCzeUAQfue+B5H6+B23+6MXhXkZV0pTeCA fnWL7u Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDw8c91pAc2hiZ/qc0Im7UbxHJhb3/+P3C+ofRikboorJ5hNFFbw 4FCog3mmJgg2Wazrj5tAItz15A== X-Google-Smtp-Source: ACHHUZ4rrnfEpnPikakLbBEtSrrYezGXLLSIT1U43jv5qGMN/ZiyuLxheI06MieglPOgO/TDw9fUfg== X-Received: by 2002:a05:622a:1999:b0:3f3:6708:c7cf with SMTP id u25-20020a05622a199900b003f36708c7cfmr4747325qtc.2.1683561551985; Mon, 08 May 2023 08:59:11 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6214:5786:b0:5a2:29c1:b542 with SMTP id lv6-20020a056214578600b005a229c1b542ls17545102qvb.10.-pod-prod-gmail; Mon, 08 May 2023 08:59:09 -0700 (PDT) X-Received: by 2002:a05:6214:4115:b0:61b:580c:8ef6 with SMTP id kc21-20020a056214411500b0061b580c8ef6mr14745542qvb.36.1683561549397; Mon, 08 May 2023 08:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683561549; cv=none; d=google.com; s=arc-20160816; b=vCsBT6twpXbVydMZSCuyVu5rWGrJQP9Wuokm8FZ81oOwFbketuliQeu/1Pthf0e8D9 l7hG4bACWCx8j3ezN0eiLMImcETYR4u8/M4MbHJ9ECiV7RGgvp+vBqGEYM1PqzPw4F+9 orXR1gmCS4zXos+wmJyoXMzIR1/y13xbY1RuPM3XRQ1Ry5AsPKNgm4iZu23yy+ohsu5T n+cFWzKEwPuxBuwDLLLfIfCedWa6YxZFQhNRRlXgBYO5zmvUaz36fC1s65aCaCb7tbcG p+oxwqzVMmYK4ocLebH9lhh4toomYb3FPVQdfqiYcxgf6zZ4PAKcwhWJMYX2m0t3Dvvr cb9A== 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=ibyLqQ1aIiuuLOWNiJRejfbeEi6ma557qLNpeYD8AoQ=; b=cD9B97+PKtzpfQgdCIECcWvha/t0p/dbMol3cQXjkopCSLbqFf+6DmsB8KCEpa7fXH HpC+1dd9S4+wos+/ROdv7gMfv1koWlF+PnQrqW6RuZ3hO2q8+KXfeeh+eVu9cCv/2aia I8wf2LXTuTfEJhvIxqQRr10cNuaJzi/lU+AlfUQRzAtXC1sYJ824s3cWUvHQ2C/IDls6 rzGWL+peUITwAGw6jpo8LZQWaGGHozZMdEWHE7pDUQ+6DIxHHJkoMw9rrPyHJ88sd9DS KSDzQs2WqTKmP/lMA0DSCC3lLt5TnOPSp+E4bXU1Q1ZQQbydCDD8aG/RCko02ZRWJcqY Nk8w== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=F8JQZyZk; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::1135 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com. [2607:f8b0:4864:20::1135]) by gmr-mx.google.com with ESMTPS id l15-20020a0ce84f000000b0061b5f12678asi12355qvo.5.2023.05.08.08.59.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 May 2023 08:59:09 -0700 (PDT) Received-SPF: pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::1135 as permitted sender) client-ip=2607:f8b0:4864:20::1135; Original-Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-559de1d36a9so67557547b3.1 for ; Mon, 08 May 2023 08:59:09 -0700 (PDT) X-Received: by 2002:a25:4f0b:0:b0:b8f:4bff:d54d with SMTP id d11-20020a254f0b000000b00b8f4bffd54dmr11014042ybb.63.1683561548940; Mon, 08 May 2023 08:59:08 -0700 (PDT) In-Reply-To: X-Original-Sender: melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=F8JQZyZk; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::1135 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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:32556 Archived-At: --00000000000015087e05fb30b87d 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 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 doubl= e > 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.lua > --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 Groups > "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, 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/ef709575-3717-493f-b6d8-= 62862c98d3d8n%40googlegroups.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/CADAJKhA_g%3D6gfAJONkb3AwdQ9Xqn8PvwUg-fAVEjsKE56%2B%2BgFg%40= mail.gmail.com. --00000000000015087e05fb30b87d 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 harm your computer and/or files if you run it!<= /div>

This filter will do what= you want:

``````lua
local str =3D pandoc.Str
local function quote (q)
=C2=A0 return pa= ndoc.RawInline('markdown', q)
end
local quote_pat =3D re.compile(
=C2=A0 = [[ {| ( [^"']+ -> str / ["'] -> quote )* |} ]],
=C2=A0 { str =3D str, quote =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 elem.classes[1] then
=C2=A0 =C2=A0 return elem.content
= =C2=A0 end
=C2=A0 return nil
= 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 conver= t to MD.

The file contains highlighting and it also cont= ains both quotes and double quotes

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

I also want to remo= ve the highlighting

ChatGPT wrote this LUA for me = but it doesn'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 inline.t =3D=3D "Str" then
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 inline.text =3D inline.text:gsub('\\"', &= #39;"'):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(resul= t, inline)
=C2=A0 =C2=A0 end
=C2=A0 =C2=A0 return result
end
function 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 bloc= k.content =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 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 doc
end

the command I used was:<= /div>
=C2=A0pandoc "TestHighlightQuotes.docx" --lua-filter re= move_escaped_quotes.lua --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 Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pandoc-discuss+unsubscribe-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.org= m.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/ef709575-3= 717-493f-b6d8-62862c98d3d8n%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 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/CADAJKhA_g%3D6gfAJONkb3AwdQ9Xqn8Pvw= Ug-fAVEjsKE56%2B%2BgFg%40mail.gmail.com.
--00000000000015087e05fb30b87d--