From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32307 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Bernardo C. D. A. Vasconcelos" Newsgroups: gmane.text.pandoc Subject: Re: Lua Filter for \citeauthor and \citetitle in HTML Date: Thu, 9 Mar 2023 06:37:08 -0800 (PST) Message-ID: <555cddba-b706-48f6-acb8-07465e5487a2n@googlegroups.com> References: <51e71797-b029-4438-be64-6a8a15dd500an@googlegroups.com> <4865a325-42c0-4245-b992-b4fbdeab576en@googlegroups.com> <9786B5A5-9022-4E5B-85DE-39D4A2CAFD8F@gmail.com> <4641cd0b-adb7-408f-b025-f56a0b293be5n@googlegroups.com> <87pm9i6qmx.fsf@zeitkraut.de> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_16672_1815985996.1678372628404" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24548"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDUKFWODQ4ARBFW6U6QAMGQEGZFJEAI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Mar 09 15:37:13 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-qv1-f56.google.com ([209.85.219.56]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1paHOL-0006AX-Bc for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 09 Mar 2023 15:37:13 +0100 Original-Received: by mail-qv1-f56.google.com with SMTP id fb18-20020ad44f12000000b0056ed45f262dsf1267886qvb.11 for ; Thu, 09 Mar 2023 06:37:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; t=1678372632; 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=ydVbe1hKBh5MOcRXNkFVbzbQj7sDXLzEUSp5ao85Uvk=; b=lfhVaoKLzdi/Ke+z0SHQwr4vwwUw1QMXqN3l+YwvxGhLQwh3fWg+gYSRL0XcdGt92a +i9MRny95E0h8FqXORg45Alp5bItQMB8034Kmc97J46mCLPJj9LrQsZvyUoz1lcCRfJ7 hnoTxP9kMqU8ruNhnsHGzI/GhuM/DzxBVRQjvzwD4NMg5Opb3hMZFBlkyF8EXE/x+ThP bpXgMRFUP1ABEUHUYRimQ2N1zX2m3wKrW/aWI2gjIXUuvQ2ie/YMypH75d38jhWLaP7k DDYYlaJL+bl3sPcVX5Z9agadVYNYiIAAEgHLKDzzKWPiPa4vcHXZwEEcC8oKbk1vw83Q D2fA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678372632; 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=ydVbe1hKBh5MOcRXNkFVbzbQj7sDXLzEUSp5ao85Uvk=; b=noHNeO5W+f1semK0Zcih+B9yvqtZl8ooqKgpa3DoIPX6iyybFND0aV41jZ3dY/mSMs wOnpbGLMeZjSuVKxNfOUVZ32vu1GceAuTddv2gbdH2gIkmZVrqo8qQW0u8tTVe97Ipby QTZp/GMQcc9LJrais+LqpOoUxVfYEVbKJv2gFjFfJSf+KQMmYWtEMVO5xrdLEK4nVRyj 7N2OwccNImpjjgj4AghE1AVHxT7AvWVs66+xJD4T3aeUvVQYLQMV/yynFC8+zveZgKFt /8vDGZOa44gUo5yQWEObJs/ybcLiXHiQiiL7Xich+0dKWdkgBdBM3bws5d1ryn5NDrPr eR/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678372632; 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=ydVbe1hKBh5MOcRXNkFVbzbQj7sDXLzEUSp5ao85Uvk=; b=OtzkX7wDYrtK6vbaCxhIHxoKr7rMTBtGG0xqcQvW0n7eN7GIpZsUJmg2Y1bAGX/ZHI Kdwuonxdff0ASxLQKTuPEjhVXVY/kLbyFd/MXRs2nzEjQwXowiowhXvKm6gveLUgPP/D 4ugDF/JA52l5uQgLrXeNJFv+lntgK+gLI3gWgC4xDgQ/ocV1piS3CHVUAjnpSKRx+zLW gSe1zALDsLj825fqE6szCbDQJTQ5ux7pgHAVVXWej1m7qPW5uNqvPMkV5HaLeWWddNXF gWi2XHARblda2kSsSRunibtbuJefhQfFHmyCVtFbRnQyOwRx8OQ0k0Q75zXLpYrXZEwq Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AO0yUKWGRvXhvGPZhuoWs7WsJj76Q2ALkPBQQ/Ua9WNOFMvg8QER6SPv vZmfdXo+ieO3O+cqEd83y3o= X-Google-Smtp-Source: AK7set9vcpJ2owZVX5FRaQbDFdLZIgs8YgYfuAAneMRHhLns3fCkYm+dms68JrQrz8lPCb8uzuxbNg== X-Received: by 2002:a05:620a:2114:b0:742:919f:e93 with SMTP id l20-20020a05620a211400b00742919f0e93mr6426470qkl.0.1678372632284; Thu, 09 Mar 2023 06:37:12 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:622a:a0d:b0:3bd:1b92:edd1 with SMTP id bv13-20020a05622a0a0d00b003bd1b92edd1ls2416692qtb.9.-pod-prod-gmail; Thu, 09 Mar 2023 06:37:09 -0800 (PST) X-Received: by 2002:ac8:1e98:0:b0:3bd:134f:6490 with SMTP id c24-20020ac81e98000000b003bd134f6490mr6591953qtm.9.1678372629193; Thu, 09 Mar 2023 06:37:09 -0800 (PST) In-Reply-To: <87pm9i6qmx.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> X-Original-Sender: bernardovasconcelos-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:32307 Archived-At: ------=_Part_16672_1815985996.1678372628404 Content-Type: multipart/alternative; boundary="----=_Part_16673_1577504993.1678372628404" ------=_Part_16673_1577504993.1678372628404 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Albert, that is vexingly short, but the syntax is perfectly clear. Thank you! Since= =20 I toiled at this for a while, your filter will provide me with some=20 interesting learning opportunities. I will play around with it and see how= =20 it behaves with the other Lua filters. Thanks again, B. On Thursday, March 9, 2023 at 9:44:30=E2=80=AFAM UTC-3 Albert Krewinkel wro= te: > > "Bernardo C. D. A. Vasconcelos" writes: > > > A filter that seems close enough is the bibexport filter at https:// > > raw.githubusercontent.com/pandoc/lua-filters/master/bibexport/ > > bibexport.lua which I reproduce below: > > Newer pandoc versions allow to shorten this to > > ``` > function Pandoc (doc) > doc.meta.references =3D pandoc.utils.references(doc) > doc.meta.bibliography =3D nil > return doc > end > ``` > > Here's a "quick n' dirty" filter that should make your `[@key]{.title}` > syntax work: > > ``` > function Pandoc (doc) > doc.meta.references =3D pandoc.utils.references(doc) > doc.meta.bibliography =3D nil > return doc:walk{ > Span =3D function (span) > -- check that the span contains only a single cite object > local cite =3D span.content[1] > local citations =3D cite and cite.citations or nil > if #span.content =3D=3D 1 and cite.t =3D=3D 'Cite' and #citations =3D=3D = 1 then > local cite_id =3D citations[1].id > local ref =3D doc.meta.references:find_if( > function (r) return cite_id =3D=3D r.id end > ) > if ref and span.classes[1] then > -- replace the span with a specific citation field > return ref[span.classes[1]] > end > end > end > } > end > ``` > > It's a bit condensed and not well documented, so let me know if you have > questions. > > > --=20 > Albert Krewinkel > GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 > --=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/555cddba-b706-48f6-acb8-07465e5487a2n%40googlegroups.com. ------=_Part_16673_1577504993.1678372628404 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Albert,
that is vexingly short, but the syntax is perfectly clear. Than= k you! Since I toiled at this for a while, your filter will provide me with= some interesting learning opportunities. I will play around with it and se= e how it behaves with the other Lua filters.
Thanks again,
<= div>B.

On Thursday, March 9, 2023 at 9:44:30=E2=80=AFAM UTC-3 = Albert Krewinkel wrote:

"Bernardo C. D. A. Vasconcelos" <bernardov...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> A filter that seems close enough is the bibexport filter at https:= //
> raw.githubusercontent.com/= pandoc/lua-filters/master/bibexport/
> bibexport.lua which I reproduce below:

Newer pandoc versions allow to shorten this to

```
function Pandoc (doc)
doc.meta.references =3D pandoc.utils.references(doc)
doc.meta.bibliography =3D nil
return doc
end
```

Here's a "quick n' dirty" filter that should make you= r `[@key]{.title}`
syntax work:

```
function Pandoc (doc)
doc.meta.references =3D pandoc.utils.references(doc)
doc.meta.bibliography =3D nil
return doc:walk{
Span =3D function (span)
-- check that the span contains only a single cite object
local cite =3D span.content[1]
local citations =3D cite and cite.citations or nil
if #span.content =3D=3D 1 and cite.t =3D=3D 'Cite' and #c= itations =3D=3D 1 then
local cite_id =3D citations[1].id
local ref =3D doc.meta.references:find_if(
function (r) return cite_id =3D=3D r.id end
)
if ref and span.classes[1] then
-- replace the span with a specific citation field
return ref[span.classes[1]]
end
end
end
}
end
```

It's a bit condensed and not well documented, so let me know if you= have
questions.


--=20
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124

--
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/555cddba-b706-48f6-acb8-07465e5487a2n%40googlegroups.= com.
------=_Part_16673_1577504993.1678372628404-- ------=_Part_16672_1815985996.1678372628404--