From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/31300 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Albert Krewinkel Newsgroups: gmane.text.pandoc Subject: Re: Help with lua filter for docx to latex conversion Date: Fri, 26 Aug 2022 22:09:18 +0200 Message-ID: <36B1ABBF-804C-4785-BB14-E29AEE6423E4@zeitkraut.de> References: <0df70b72-8e13-4e1c-986f-6a54ef352f6cn@googlegroups.com> <7fc77e34-86e4-48a2-8642-e226d1ae08ben@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=----T36HIZTJ3SR97VDDKRQ9EKIZ5QJ2N5 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2547"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCZJF7XJTILRB5OQUSMAMGQEH3ICI3Y-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Aug 26 22:09:28 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wm1-f55.google.com ([209.85.128.55]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oRfdw-0000Th-LG for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 26 Aug 2022 22:09:28 +0200 Original-Received: by mail-wm1-f55.google.com with SMTP id a17-20020a05600c349100b003a545125f6esf4527357wmq.4 for ; Fri, 26 Aug 2022 13:09:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1661544568; cv=pass; d=google.com; s=arc-20160816; b=iCNzkH77jZjLIFfN/torKhmP8NcSyO5oXN2/l6A1KJDNue9TQsuKVQZ+WlJtqATOPL RHQissKxraXOirrs0+3KNJnHlR7pG8RnXmsU6I85lxc1LQ7ufBVyIx4O1azieMeorxXR nBcKj3rwjkIjRd2iF+5UgOuEnUUPjMa/JYr9iYt4d4TYOQY1b77+W22yVqixwP1zoyJb a9YkQrlKUmivHdw5CGi3drUF2d7immJaeSQHBG+NxWd0AMMNkg8eDcDBN49DvlKg1K9A tgYzZpB4D3biLXWG3BtbK73AlVA4W7xD+9BsUGmW1kt3ZO7Cimt7Ep2TDn5Fo/Z+GWLR akWA== 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:content-transfer-encoding :mime-version:message-id:references:in-reply-to:subject:to:from:date :sender:dkim-signature; bh=RGWQ1bdWPcZ8bGXJCYG4pnr6ZcVXUoUJhT6RIm0HvrM=; b=qZvI6E50OFyqToneQGHbXTJagJYbV2FPQ/5HXDFgC6SEaV3XrbHeuiM4D8Sd3z2Xqn bvNIERDKIOtvSo651nPGneTmTza2qawA9IHFrJeSs8UTv8QLSmHj0o3BWHnNVRSpTV/v YT0f5DfGxQgfGrz4UqyFMkYEdVu39xN0RIc+TKEvNCBOtYowJz6lUw51UMl3h49fKuwh ASsmCCV2m6vpivg5CYU5KdKpVNISZmcIMV6Rf0YkBltGrgUwdMN5ecBOBRsPm7vp0sj4 s46QBAh/7rmCqGrC0OXhd8zcqgFk4xHp6EiRpyNWsOmhQiJerUwV9++i3L1bAkum1/Gz g3aA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 2001:67c:2050:0:465::201 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org 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-authentication-results:x-original-sender :content-transfer-encoding:mime-version:message-id:references :in-reply-to:subject:to:from:date:sender:from:to:cc; bh=RGWQ1bdWPcZ8bGXJCYG4pnr6ZcVXUoUJhT6RIm0HvrM=; b=SXfksHJGG/7BgKQV43WZzV1wfpc1nWMb8eD6G3YkgXV4JiV4HbvHZT064y4yoWIqq9 gOF0tTQtmOVFHifnw6/NnEl/OosS/YWqQbZ8RICUG61xTcIRfA+4c1dZF8rwYay2XTNw HdqdrSGdKz6YJpdcLefwGRsQZuu6eMCrK4Gkhrk1wv5QJJolBMi7x+CQq3eKbWXjbzXm 82qf6FSuPbbZrpuir9cuPW+a5ibSTTudAYxTg57vcrPrXGibgp61U8DxAoVv/P/OuFv6 WI47Qhq+OEVffrFqODcnGzHsEVfos82VCV2y3XxD+uzY8OiNavmxzK+IuOciA/0lsiC3 qaSw== 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-authentication-results:x-original-sender :content-transfer-encoding:mime-version:message-id:references :in-reply-to:subject:to:from:date:x-gm-message-state:sender:from:to :cc; bh=RGWQ1bdWPcZ8bGXJCYG4pnr6ZcVXUoUJhT6RIm0HvrM=; b=aHUMPoA8/zK7tiah9pSaJ9bpaUQ/CORc2Ua2fqaQTjz2d6SVcTg8JFumKrKigFOGfh SVcR3RHHxnsoOsD4+syPg77wWBtl9qd5CRj9hMXG7t9krhf5YomU4BhAsvw1GsuJA5OI je0qA410/erHN2TQwerhothiBq7/fHTZVAdJ7rRHTRhc8sCMtZ3g94ADqG5N/fcZX4en bdd8bGp3Szm/JqlmgMi6Lv5ZmEp/1GYoiNEtjwiVk5Q2QrcOEtaiV90Gv4wtEWAxZHJS laCYGtEzQ97A9kAfzPOra7SpmbWEwtykLCWbAEHK75EvbdweFBmUw Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ACgBeo3IrCsDRe47H3feSCmqFqsNtq8ArRK2dlJZPAe5NTvtxNe7SaRg fiUv/q5ecCHMT6UgzKmzAMM= X-Google-Smtp-Source: AA6agR5xXKV+LyCm71ccUD8tFxOAHII8bXyBzBVT3B61s9hpU+JS0+FG/msTmuzLBVv1phw1PxmBZQ== X-Received: by 2002:a5d:4452:0:b0:226:c784:10d5 with SMTP id x18-20020a5d4452000000b00226c78410d5mr695760wrr.382.1661544568174; Fri, 26 Aug 2022 13:09:28 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:adf:e4ce:0:b0:225:6559:3374 with SMTP id v14-20020adfe4ce000000b0022565593374ls1247580wrm.2.-pod-prod-gmail; Fri, 26 Aug 2022 13:09:24 -0700 (PDT) X-Received: by 2002:a5d:4443:0:b0:225:8759:c160 with SMTP id x3-20020a5d4443000000b002258759c160mr646284wrr.199.1661544563856; Fri, 26 Aug 2022 13:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661544563; cv=none; d=google.com; s=arc-20160816; b=dpxyCuZGHG11wimjAhdpot3OpXhNGj6/MU3Q+VIpGlxn0lE4ITuHzsSzaISnnFEPZN VrAdFY+kxDoSCTZvN0VO34qzwP57CYAxiJFXZLeQUMzBuMjb5pDljcRzG9zpa0plRnA9 lB169jmw/umOJxAOVzqxczY2MEMDW/tkdVFAI9fu7ZCPKzPOsxMILCVRy+Xiz+B/QFE2 9c2q0agPVtItW1rCH1mb/8VLp/y2fg4U0m6kL93K9ZAUPqBcddTX51kUf4S7yrTbi9Nw bSy6ItU5p7xJRrKYCDCkQQlXWWkITv5oCgwRDfY+ThrBF6zdvII1y1jMjqptKn+cjRLB HK+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:subject:to:from:date; bh=zRUP0U/n9T7OsVjLmr9OlYnP1nRjNQ3Musu5zS6S+Us=; b=Tg4fOZRl0nGMQgR/72PRgdvqRJtc7VgzjYhWNY0gkeR8h+4TC03WpZX3sH0ZqsRPG1 bPOzbB98sYkXGSDRxGANJ/PTVwZIm6NpCAXfcWApJU3UbP3hV8LiUaQqmOMoZ1j7GfHT ejPauc/r2Rornbbe/Ns4a4OfeW8LSzfEAhfAhAuvxuel30XdoQCD0GwgOR4xTwDF4Wz6 XUyZ9XB0SKidWbHAqqgu8rK7uwbPgqc/NTtKjcRetNVmeIj8z8atfKAQIai9+VOWCRyY GuwiwoqA0cQXTBD90a+mGaH4vvS9bAt3KKxR8fcJGI/fvDJr7fpDMVQrvtDtYfBT3GAU zA2A== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 2001:67c:2050:0:465::201 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org Original-Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org. [2001:67c:2050:0:465::201]) by gmr-mx.google.com with ESMTPS id u9-20020adfdd49000000b0022555dd2b9bsi20878wrm.4.2022.08.26.13.09.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 13:09:23 -0700 (PDT) Received-SPF: pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 2001:67c:2050:0:465::201 as permitted sender) client-ip=2001:67c:2050:0:465::201; Original-Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4MDrX11Q4pz9sVt for ; Fri, 26 Aug 2022 22:09:21 +0200 (CEST) In-Reply-To: <7fc77e34-86e4-48a2-8642-e226d1ae08ben-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Original-Sender: albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 2001:67c:2050:0:465::201 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@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:31300 Archived-At: ------T36HIZTJ3SR97VDDKRQ9EKIZ5QJ2N5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Lua patterns have a nice feature for this, try '\\cite%b{}' This should match everything between the starting and closing curly braces. Sandra Martin hat am 26.08.2022 21:23 CEST geschrieb= en: Hi Bastien,=20 Thank you for your quick reply! I got it to work with: "\\cite{%w+}" The only left is that this only matches one reference but doesn't work when= there's multiple, for example "\cite{reference, referecen2, reference3}" I've been playing around with "\\cite{%w+%p?%s?%w+}" but I can't get it to = work with the space after the comma. Would you know a solution? Thanks a lot!! Bastien Dumont schrieb am Freitag, 26. August 2022 um 19:41:08 UTC+2: In `"\\cite[{](%w+)[}]"`, `(%w+)` is a capture. When the pattern in string.= match() specifies a capture, it is returned instead of the whole match, so = `citekey` has the value of the *content* of `\cite{...}` instead of the who= le macro. I guess that it should work if you remove the parentheses.=20 Le Friday 26 August 2022 =C3=A0 10:08:50AM, Sandra Martin a =C3=A9crit :=20 > Hello all,=20 >=20 > I have trouble writing the correct lua filter for my pandoc conversion of= docx=20 > to latex.=20 >=20 > In short, I have citations in the format "\cite{reference}" (csl style fr= om=20 > Better Bibtex) in my docx file, which I would like to preserve and keep= =20 > unchanged during pandoc conversion.=20 >=20 > When calling "pandoc --to=3Dnative test.docx", I see that pandoc reads th= ese=20 > entries as strings and I've tried writing filters with pandoc.RawInline t= o=20 > preserve these strings. However, using for instance this function keeps t= he=20 > reference keys but gets rid of all the latex formatting (the backslash an= d the=20 > curly brackets):=20 > function Str(el)=20 > local citekey =3D el.text:match("\\cite[{](%w+)[}]")=20 > if citekey then=20 > return pandoc.RawInline('latex', citekey)=20 > end=20 > end=20 >=20 > How do I keep my latex-styled reference strings as they are during pandoc= =20 > conversion?=20 >=20 > Thanks in advance!=20 > Sandra=20 >=20 > --=20 > You received this message because you are subscribed to the Google Groups= =20 > "pandoc-discuss" group.=20 > To unsubscribe from this group and stop receiving emails from it, send an= email=20 > to [1]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org=20 > To view this discussion on the web visit [2]https://groups.google.com/d/m= sgid/=20 > pandoc-discuss/0df70b72-8e13-4e1c-986f-6a54ef352f6cn%40googlegroups.com <= http://40googlegroups.com>.=20 >=20 > References:=20 >=20 > [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org=20 > [2] https://groups.google.com/d/msgid/pandoc-discuss/0df70b72-8e13-4e1c-9= 86f-6a54ef352f6cn%40googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter= =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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org . To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/7fc77e34-86e4-48a2-8642-e226d1ae08ben%40googlegroups.com . --=20 Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet= . --=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/36B1ABBF-804C-4785-BB14-E29AEE6423E4%40zeitkraut.de. ------T36HIZTJ3SR97VDDKRQ9EKIZ5QJ2N5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Lua patterns have a nice feature for this, try '= \\cite%b{}'

This should match everything between the starting and cl= osing curly braces.

Sandra Martin <sandrushba-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> hat a= m 26.08.2022 21:23 CEST geschrieben:

Hi Bastien,

Thank you = for your quick reply! I got it to work with: "\\cite{%w+}"

The only = left is that this only matches one reference but doesn't work when there's = multiple, for example "\cite{reference, referecen2, reference3}"

I'v= e been playing around with "\\cite{%w+%p?%s?%w+}" but I can't get it to wor= k with the space after the comma. Would you know a solution?

Thanks = a lot!!

Bastien Dumont schrieb am Freitag, 26. August 2022 um 19:41:= 08 UTC+2:

In `"\\cite[{](%w+)[}]"`, `(%w+)` is a capture. When the p= attern in string.match() specifies a capture, it is returned instead of the= whole match, so `citekey` has the value of the *content* of `\cite{...}` i= nstead of the whole macro. I guess that it should work if you remove the pa= rentheses.

Le Friday 26 August 2022 =C3=A0 10:08:50AM, Sandra Marti= n a =C3=A9crit :
> Hello all,
>
> I have trouble writi= ng the correct lua filter for my pandoc conversion of docx
> to late= x.
>
> In short, I have citations in the format "\cite{refere= nce}" (csl style from
> Better Bibtex) in my docx file, which I woul= d like to preserve and keep
> unchanged during pandoc conversion. >
> When calling "pandoc --to=3Dnative test.docx", I see that p= andoc reads these
> entries as strings and I've tried writing filter= s with pandoc.RawInline to
> preserve these strings. However, using = for instance this function keeps the
> reference keys but gets rid o= f all the latex formatting (the backslash and the
> curly brackets):=
> function Str(el)
> local citekey =3D el.text:match("\\cite= [{](%w+)[}]")
> if citekey then
> return pandoc.RawInline('la= tex', citekey)
> end
> end
>
> How do I keep my= latex-styled reference strings as they are during pandoc
> conversi= on?
>
> Thanks in advance!
> Sandra
>
> = --
> You received this message because you are subscribed to the Goo= gle Groups
> "pandoc-discuss" group.
> To unsubscribe from th= is group and stop receiving emails from it, send an email
> to [1]pa= ndoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the we= b visit [2]https://groups.google.com/d/msgid/
> pandoc-discuss/0df70= b72-8e13-4e1c-986f-6a54ef352f6cn%40googlegroups.com <http://40googlegroups.com>.
>
> Ref= erences:
>
> [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > [2] https://groups.google.com/d/msgid/pandoc-discuss/0df70= b72-8e13-4e1c-986f-6a54ef352f6cn%40googlegroups.com?utm_medium=3Demail&= utm_source=3Dfooter

--
You received this message because y= ou are subscribed to the Google Groups "pandoc-discuss" group.
To unsubs= cribe from this group and stop receiving emails from it, send an email to p= andoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <mailto:pandoc-discuss+unsubs= cribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
To view this discussion on the web visit https://groups.google.com/d/msgid/p= andoc-discuss/7fc77e34-86e4-48a2-8642-e226d1ae08ben%40googlegroups.com = <https://groups.google.com/d/msgid/pandoc-discuss/7fc77e34-86= e4-48a2-8642-e226d1ae08ben%40googlegroups.com?utm_medium=3Demail&utm_so= urce=3Dfooter>.
--
Diese Nach= richt wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.

--
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/msgi= d/pandoc-discuss/36B1ABBF-804C-4785-BB14-E29AEE6423E4%40zeitkraut.de. ------T36HIZTJ3SR97VDDKRQ9EKIZ5QJ2N5--