From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32308 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 18:56:03 +0000 Message-ID: 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> <555cddba-b706-48f6-acb8-07465e5487a2n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_CY4PR08MB3495899DCBA5868E92EE0F0CF2B59CY4PR08MB3495namp_" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29718"; mail-complaints-to="usenet@ciao.gmane.io" To: "pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org" Original-X-From: pandoc-discuss+bncBDUKFWODQ4ARBRWXVCQAMGQEVF56AAQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Mar 09 19:56:11 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-io1-f64.google.com ([209.85.166.64]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1paLQv-0007So-HG for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 09 Mar 2023 19:56:09 +0100 Original-Received: by mail-io1-f64.google.com with SMTP id g21-20020a6be615000000b0074cb292f57dsf1287125ioh.17 for ; Thu, 09 Mar 2023 10:56:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1678388168; cv=pass; d=google.com; s=arc-20160816; b=C0f0Ibw4WkXYn+nCAcgdcYjqAsrtMVzBJ8M2oM4hgEWTF0uJusOUVSLdaXEKXm1xoO +8AgD2GDwQDpgRlBjt43NSALccX8YERCdKTQkUDEn03zWBiVZNWsEmbipyx8qCbryyLA Q0PMUoURqAv2B9EqbOjVbu6uLkg6Pc/Jr01lEdF5LeRMFMhKiF/HdVNpZXFoojGWaAkz 8+IrunkEgBMS2hpu4vuQ8Lzs8pS1aQ7SJjBvejMTvBhN2Hi/h/SoB9iDxh0s3BabhAGp +WPtTpXxIYXsLQTgTSlcfUxM3qU+q7RI05YM3TNtgTIYJkUCut+je1TvExAM4FB0JXZj ekiA== 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:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:from:sender :dkim-signature:dkim-signature; bh=dDE8wPY1GSJyVOToH04FU707n0b4GTtNGqGf9OWTPHA=; b=QgEWN9a3cShcs6kxSzzyc614P+TzD+NLTe4Rh5GO9BiqS02eVS/pbGDE7LTVRVTkm/ uRGNZPwzvEx2OtKEu+nABSE1265JZgO6lKSfFw3342IytYaKpMbNhrxWdpNFfQlIEJwK MCvrKWHwtAWcbSmLnd8zF0vjLPZmsfiEhdsYo6KYWoXKBsPXU612cgOSgSkqk+DmGtm0 1GLeIh+8ml9MmJaH5jtqKg/GrzDVhvm7YUyqet6AL8A/shDpQy1up9MYlX04GlOeG066 q22ExGZM9QuZa8nWkuIj2p8lw9XPLCUL+q/ajeLM0BATmeWNCVSFe/d0D7L5bwG8Nfbn lU1Q== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WIWAa1VP; spf=pass (google.com: domain of bernardovasconcelos-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::633 as permitted sender) smtp.mailfrom=bernardovasconcelos-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=20210112; t=1678388168; 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:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=dDE8wPY1GSJyVOToH04FU707n0b4GTtNGqGf9OWTPHA=; b=Pa5hX7HRMa0Y4koIVX8Fx9egDioQEwt+aEDDhrIrp1cD7wRCbWUijuCKazWw0fIms3 uKN8XeoIAVkYwfh5XD+TMX0j8dGL/MnxUeoleU1eg3kSiYofhrw3faXuzm0IoDaSpT7n xp7mYiXJjTXmKVUDFvxnpOLhfMnW4R2KIGXu/9d9f+hZj8llwnAMXCIgB5XHex4ZtUCz JeGfBEEa0oatmGS/PFNRyow2VI9/T8UsmGoeiRGeQUD5TP+JmIeSeP9kJcywH5xHewnh b1S47qXfwqTC7nwKnA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678388168; 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:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=dDE8wPY1GSJyVOToH04FU707n0b4GTtNGqGf9OWTPHA=; b=QjwMRzaLkBCTIhWNzdly6z6WRG7lS/CLTzuBlsqQ8XsV3QYyhndlE8lEvh5BPzyzff LAM17c/cf9K6xoGZazVGdS4E7tb0D/H+kHqFttCevx8qdcQ/GurLqmaE21EYfInOajRH /bq1abGo4IODYMzBg+FpqM0mLChhqkVFrk0gquBNI8p2C75Xb/Q34dIOR2hZQAsY/WJC Zsh36mlDBm+dAFkDQEeHQ3hlXCyRaZ3goAWul8oHb11izB3Kglxj+jTKzzsMS+JcMcjV zXyQJSPC2vMb46izR1W/cGYPZ92VWB5v X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678388168; 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:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:from:x-gm-message-state :sender:from:to:cc:subject:date:message-id:reply-to; bh=dDE8wPY1GSJyVOToH04FU707n0b4GTtNGqGf9OWTPHA=; b=L5bh4W5e0BhJZcXYrFWe6MvA0odx6FMwh4BCwgsiGzRRYshaDL2tKWJb8vL1ceOjAI 0JSIte0nGO2hsrwo4h8AkdlS6p5bS3RMy+C41lrR0KyVPwqr9BE5ppNGRjDY3pVeIfEd GH9/rnVtMhXAdYdJBoNIlRELKrYRMw+yZ4y/xVeDCiDkjKs7VYA86sVzRiy3vRjgUINQ m0GWHWIpgLJ/kHQhB7qpTbVbGPpDIApy+1M0GyTHYgiD/pPagxJ Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AO0yUKX29PvfzfyNPphyCmzBk0uJemLpp1DVrHj1B0qpvXKgEJb0In76 hfg9Y4StoJqWCAyapAFQ4tE= X-Google-Smtp-Source: AK7set/Tzx0cL271bM2oKvhisgfMR+WSyi/d0F7b2GqHb3AvKMtvl5GuUnMQOAM9hV3FbxILr5afJQ== X-Received: by 2002:a05:6602:22d1:b0:74a:f3d:3cc5 with SMTP id e17-20020a05660222d100b0074a0f3d3cc5mr10921997ioe.4.1678388168401; Thu, 09 Mar 2023 10:56:08 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6e02:550:b0:317:979d:93b3 with SMTP id i16-20020a056e02055000b00317979d93b3ls657951ils.9.-pod-prod-gmail; Thu, 09 Mar 2023 10:56:05 -0800 (PST) X-Received: by 2002:a05:6e02:1b09:b0:315:90a1:a8f7 with SMTP id i9-20020a056e021b0900b0031590a1a8f7mr19214552ilv.25.1678388165650; Thu, 09 Mar 2023 10:56:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678388165; cv=none; d=google.com; s=arc-20160816; b=WEDxVUBuCDLHAj+RZ5H1wvNuYEhV6u7Ue0TqU6vaT57C8KqyTbanaQyLV0ykfuJ6tl 7A5fCXLT2M8bUuxKKLUKnARYZ49IhTgeyn0zSBOXMpvgeHAhNlngDuXxgGqxp2rJ/BC0 LeqomiUDrcT6MiW4Ka0lPduhY/Y3yxXWn9aR+jOrpPg26K/MJhjPPFwEu/CGXAkrHlKa Nzdro/4h8a9aK9RzwCA2fcAFPpTY9d/LPvf8IVYIUX670MNokfg9wWDhq2C2AToUltUu HwYOz5wxw7udv7sr8V/a1s8CUhIjEHYUTA4HUHIGUeOGkvCZ7HE1N73/farF5VRUzJsT OV2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-language:accept-language:in-reply-to :references:message-id:date:thread-index:thread-topic:subject:to :from:dkim-signature; bh=qjB3Ta6By9kDS6+l33vtIM010XWJJTVKMPhitVwXgxQ=; b=Wv0fkVDbFrR8UqVSdr6k8SzgmPE9rdHE1BDI+h2onHmD7OyyKX3V9lnPtGE9DMykSr Sy6dLqMAv1Q0LwlUMb5DuKK2vvjiRXymeDwuYJWhssiM3Tp9wpR8vvi4qNV1VOKxyDg1 ohbBDiEiozQrTkASjJ+Zs4Y8rCuLjMKGXO+xyBw6zY8R64EOFv6SYLi1Rf3okf+Gr8mH zxodSlcnxFNf2MoTD14igKgHG29ggQKpaQML3fgOqfU5wzOHQ9Y6+e3qXVHYQ0r+50lY IU/hw3kjvz3Tfv4HWVU44Bh6G0srz6I2Iw8DqW8gdaLYBG7QZTb93xEb03K1wfdbXDn1 ebSg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WIWAa1VP; spf=pass (google.com: domain of bernardovasconcelos-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::633 as permitted sender) smtp.mailfrom=bernardovasconcelos-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com. [2607:f8b0:4864:20::633]) by gmr-mx.google.com with ESMTPS id r9-20020a056638130900b003f6e4b44e5csi1131797jad.6.2023.03.09.10.56.05 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Mar 2023 10:56:05 -0800 (PST) Received-SPF: pass (google.com: domain of bernardovasconcelos-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::633 as permitted sender) client-ip=2607:f8b0:4864:20::633; Original-Received: by mail-pl1-x633.google.com with SMTP id i3so3021252plg.6 for ; Thu, 09 Mar 2023 10:56:05 -0800 (PST) X-Received: by 2002:a05:6a20:bf25:b0:cc:8a62:d0d5 with SMTP id gc37-20020a056a20bf2500b000cc8a62d0d5mr20585145pzb.55.1678388164554; Thu, 09 Mar 2023 10:56:04 -0800 (PST) Original-Received: from CY4PR08MB3495.namprd08.prod.outlook.com ([2603:1036:906:77::5]) by smtp.gmail.com with ESMTPSA id 11-20020aa7910b000000b005ad9e050512sm11461485pfh.121.2023.03.09.10.56.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2023 10:56:04 -0800 (PST) Thread-Topic: Lua Filter for \citeauthor and \citetitle in HTML Thread-Index: AW41NDQt3iUGR+V+nQ5jqAcN0LSw1nBTNWxqbmUyMi1hTmdKOEZBRDQ1bmI1MC1mZnhxaW5lODgtv+9W7dA= X-MS-Exchange-MessageSentRepresentingType: 1 In-Reply-To: <555cddba-b706-48f6-acb8-07465e5487a2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Accept-Language: en-US Content-Language: en-GB X-MS-Exchange-Organization-SCL: -1 X-MS-Exchange-Organization-RecordReviewCfmType: 0 X-Original-Sender: bernardovasconcelos-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WIWAa1VP; spf=pass (google.com: domain of bernardovasconcelos-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::633 as permitted sender) smtp.mailfrom=bernardovasconcelos-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:32308 Archived-At: --_000_CY4PR08MB3495899DCBA5868E92EE0F0CF2B59CY4PR08MB3495namp_ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable It works wonderfully. I made some minor modifications to allow it to work m= ore like a `citefield` filter in general, and to avoid an error due to inva= lid field names passed as args. I think we could call it ready unless anyon= e else has suggestions. For fields with names such as authors, editors and = translators, it seemed enough to get the family name of the first name, but= other could prefer it to behave differently, of course. ``` local function get_keys(t) local keys=3D{} for key,_ in pairs(t) do table.insert(keys, key) end return keys end stringify =3D require 'pandoc.utils'.stringify 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 ) local the_arg =3D span.classes[1] local the_result =3D "" if ref and the_arg then if string.find(stringify(get_keys(ref)), the_arg) then -- replace the span with a specific citation field if the_arg =3D=3D "author" or the_arg =3D=3D "editor" or the_ar= g =3D=3D "translator" then the_result =3D stringify(ref[the_arg][1]["family"]) else if the_arg =3D=3D "title" then the_result =3D pandoc.Emph{stringify(ref[the_arg])} else the_result =3D stringify(ref[the_arg]) end end else -- return the span unchanged the_result =3D span end return the_result end end end } end ``` Um abra=C3=A7o, Bernardo From: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org on = behalf of Bernardo C. D. A. Vasconcelos Date: Thursday, 9 March 2023 11:37 To: pandoc-discuss Subject: Re: Lua Filter for citeauthor and citetitle in HTML Albert, that is vexingly short, but the syntax is perfectly clear. Thank you! Since= I toiled at this for a while, your filter will provide me with some intere= sting learning opportunities. I will play around with it and see how it beh= aves 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. -- Albert Krewinkel GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 -- 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/pan= doc-discuss/5gb64T4OU9Q/unsubscribe. To unsubscribe from this group and all its topics, send an email to pandoc-= 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. --=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/CY4PR08MB3495899DCBA5868E92EE0F0CF2B59%40CY4PR08MB3495.nampr= d08.prod.outlook.com. --_000_CY4PR08MB3495899DCBA5868E92EE0F0CF2B59CY4PR08MB3495namp_ Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

It works wonderfully. I made some minor modifications to a= llow it to work more like a `citefield` filter in general, and to avoid an = error due to invalid field names passed as args. I think we could call it ready unless anyone else has suggestions= . For fields with names such as authors, editors and translators, it seemed= enough to get the family name of the first name, but other could prefer it= to behave differently, of course.

 

 

```

local func= tion get_= keys= (t)<= o:p>

  loca= l ke= ys= =3D{= }

  for<= /span> key,= _ in pair= s(t) do<= /o:p>

  &n= bsp; t= able.insert(keys, key)

  end<= /span>=

  retu= rn k= eys

end

 

stringify =3D<= /span> requ= ire 'pan= doc.utils'.stringify

 

function Pand= oc (doc= )

  doc<= /span>.meta= .references =3D<= /span> p= andoc.utils.references(doc)

  doc<= /span>.meta= .bibliography =3D<= /span> nil<= /span>=

  retu= rn doc<= /span>:<= /span>w= alk{=

  &n= bsp; Span =3D<= /span> func= tion (spa= n)

  &n= bsp;   -= - check that the span contains only a single cite object<= /p>

  &n= bsp;   loca= l ci= te =3D<= /span> span= .con= tent[1]<= o:p>

  &n= bsp;   loca= l ci= tations =3D<= /span> cite and<= /span> cite= .citations or nil<= /span>=

  &n= bsp;   if #span.conten= t =3D= =3D 1 and<= /span> cite= .t =3D= =3D 'Cit= e' and<= span style=3D"font-size:13.5pt;font-family:Hack;color:#CCCAC2"> #citatio= ns =3D= =3D 1 then=

  &n= bsp;     loca= l ci= te_id =3D<= /span> cita= tions[1]= .id

  &n= bsp;     loca= l re= f =3D<= /span> doc<= /span>.meta= .references:find_if(

  &n= bsp;       func= tion (r)<= /span> retu= rn c= ite_id =3D= =3D r.id end<= /span>=

  &n= bsp;     )

  &n= bsp;     loca= l th= e_arg =3D<= /span> span= .cla= sses[1]<= o:p>

  &n= bsp;     loca= l th= e_result =3D<= /span> &quo= t;"

  &n= bsp;     if ref and<= /span> the_= arg then=

  &n= bsp;       if s= tring.find(s= tringify(get_keys(ref)), the_arg) then

  &n= bsp;       -= - replace the span with a specific citation field

  &n= bsp;         if the_a= rg =3D= =3D &quo= t;author" or the_arg =3D= =3D &quo= t;editor" or the_arg =3D= =3D &quo= t;translator" then=

  &n= bsp;           the_result =3D<= /span> stri= ngify(ref[the_arg][1]["family"])

  &n= bsp;         else= if the_a= rg =3D= =3D &quo= t;title" then= =

  &n= bsp;            = ; the_result =3D<= /span> p= andoc.Emph{s= tringify(ref[the_arg])}

  &n= bsp;           else=

  &n= bsp;            = ; the_result =3D<= /span> stri= ngify(ref[the_arg])

  &n= bsp;           end<= /span>=

  &n= bsp;         end<= /span>=

  &n= bsp;       else=

  &n= bsp;       -= - return the span unchanged

  &n= bsp;       the_result =3D<= /span> span=

  &n= bsp;       end<= /span> = ;      

  &n= bsp;       return the_result

  &n= bsp;     end<= /span>=

  &n= bsp;   end<= /span>=

  &n= bsp; end<= /span>=

  }<= /o:p>

end

```

 

Um abra=C3=A7o,

Bernardo

 

From: pandoc-discuss@goog= legroups.com <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> on behalf of Bernardo = C. D. A. Vasconcelos <bernardovasconcelos-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Thursday, 9 March 2023 11:37
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: Lua Filter for citeauthor and citetitle in HTML

Albert,<= /span>

that is vexingly sh= ort, but the syntax is perfectly clear. Thank you! Since I toiled at this f= or a while, your filter will provide me with some interesting learning oppo= rtunities. I will play around with it and see how it behaves with the other Lua filters.

Thanks again,<= /o:p>

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:// <= br> > 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]{.t= itle}`
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.


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

--
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/5gb64T4OU9Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
pandoc-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-07= 465e5487a2n%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 htt= ps://groups.google.com/d/msgid/pandoc-discuss/CY4PR08MB3495899DCBA5868E92EE= 0F0CF2B59%40CY4PR08MB3495.namprd08.prod.outlook.com.
--_000_CY4PR08MB3495899DCBA5868E92EE0F0CF2B59CY4PR08MB3495namp_--