From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32827 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephan Boltzmann Newsgroups: gmane.text.pandoc Subject: Re: Modifying metadata elements with Lua filter Date: Thu, 15 Jun 2023 08:17:16 -0700 (PDT) Message-ID: <64f0f40b-5c49-47fa-97f5-f824735f6cebn@googlegroups.com> References: <19962c60-238b-4ef4-bad6-a8200ca9a3cen@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_6312_1749575981.1686842236518" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20003"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCZ25UWY24ERB7OWVSSAMGQEMUWRFIQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Jun 15 17:17:22 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f55.google.com ([209.85.161.55]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1q9oiv-0004v1-D2 for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 15 Jun 2023 17:17:21 +0200 Original-Received: by mail-oo1-f55.google.com with SMTP id 006d021491bc7-558b7c65e3bsf1228566eaf.0 for ; Thu, 15 Jun 2023 08:17:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1686842240; x=1689434240; 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=SXOquuM66tDqWcZqs6boAn8XENqvfdn5AzovLW3egS0=; b=NnucivK6ZvFmTcd/9W1S+yNfjU/tGMEnxdAZ/mYXtZ4kqeqHVjJ6i3wsqNYDm5ZHrs F37+iXfEbyiJZinu+8NYxPc4ionWhasyWJpm30kL75v3r5HtIF7uwyZBDjr6Ozk1DQ6r 9u96wuwXyF0kqozijEE2zdKPQjXrN4PosS0wly1ksON+1kldwATjXViTaq0W1aXp14MU OsIQYSE9Uw4xRoaLsM5g4e15l2tnFw7duDG47UOzWWveE7Hf6jk6I7csmmvyQSFin2gu mxq0z8ayxAjqsNS+ZwN14tlZj+o2oHwEGpCORmTYNReTtqzL/Qwg0VXeAgRLA6F9DS6h dgow== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686842240; x=1689434240; 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=SXOquuM66tDqWcZqs6boAn8XENqvfdn5AzovLW3egS0=; b=H0WAltsxB1VSZUDYwhAF9ZxQ35zQ4eeBjQe3N45uil1mnn99jFx0CNBtATWL4QKZ9D HMpt05EZFJlklH0D660g6GLBYQtzEIWsXmPRf2QWpY2gKJ4A8PotZ+YqIUrfQvHGpNm5 cV2/X1G/usIUZBu9puQ2six0pLf4St0U6XmOASUjp5aWmt+ZGETyaQNe/KrtSFbv2KLF BgCtsdpk/P5+QqGNadg2LoJgSwWwgSiL8I+n5d0clOGraOFdNJWMQI3Zk9btzZWUjXxI 0/vPJjt/HQVNr7qFcp6xaV8jqNca618lLjRiYFMWOoe7FumBjHf2kFiQ9dFNZ38M5Iu/ myQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686842240; x=1689434240; 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-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=SXOquuM66tDqWcZqs6boAn8XENqvfdn5AzovLW3egS0=; b=hs6c1N6+wLEja654oInFsnD7FTGz+8mosuhlFjAHhjwaWHY1TphmUcklj+Ds6RGpW7 0wHB2QT5pmRyikDnYkhWsUMBULVDWppxb8ErWQeYUKRbiN9fwzM5sQcDfecTxWaA8ly9 Sg7mekhTVBoFA9gm/YPklL8pb+eqST6Bi+eEEV5F1bt+HHHkCRnLpPMof7ben1FMo90b z76HE7+mbLKbOz5lRs7VEcY4HIhmOQsNsJdsC+Zk1noSdS3PdsdebJWCLKLsm8XVX4IL hqlZqvTSNlg+rWAeMq+RUPNO3CLwfObkRuBbDWbkvAik+iUft6 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDwB5kY4ms4X+k/3u+VwXflLEQ7LPEnBlBsDoll5lCXoMwg51bwR MPZy2fJUhfVYNbP2kuZmjTo= X-Google-Smtp-Source: ACHHUZ57qsUh0OpZfnHL1mY7tQIupE5x6J3dc5071vwSZYPaDJzgDekQgoVH6p8rp7QmQej2rfBYDQ== X-Received: by 2002:a4a:eac3:0:b0:558:b3f1:1081 with SMTP id s3-20020a4aeac3000000b00558b3f11081mr11205942ooh.9.1686842240189; Thu, 15 Jun 2023 08:17:20 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a4a:ded9:0:b0:558:b1ed:9f8f with SMTP id w25-20020a4aded9000000b00558b1ed9f8fls268674oou.1.-pod-prod-00-us; Thu, 15 Jun 2023 08:17:17 -0700 (PDT) X-Received: by 2002:a05:6808:138c:b0:398:1137:15bd with SMTP id c12-20020a056808138c00b00398113715bdmr1782234oiw.1.1686842237265; Thu, 15 Jun 2023 08:17:17 -0700 (PDT) In-Reply-To: X-Original-Sender: stephan2boltzmann-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:32827 Archived-At: ------=_Part_6312_1749575981.1686842236518 Content-Type: multipart/alternative; boundary="----=_Part_6313_958494041.1686842236518" ------=_Part_6313_958494041.1686842236518 Content-Type: text/plain; charset="UTF-8" Thanks a lot for your help, which enabled me to write the following short filter, which puts the name of all authors on the same line in 'docx' output, while preserving the nice default layout in 'latex' output. Debugging filters working on the yaml metadata provided a particular challenge to me: function Meta (m) if FORMAT:match 'docx' then authors = m.author[1] .. {pandoc.Str(', ')} .. m.author[2] m.author = pandoc.MetaInlines(authors) end return m end It only handles two and not more authors, but in my case, that's fine. William Lupton schrieb am Mittwoch, 14. Juni 2023 um 18:55:04 UTC+2: > Your metadata has this structure (hmm... perhaps some of the Inlines are > really MetaInlines, in which case that's a problem with my logging module): > > (#) meta Meta { > author: List[2] { > [1] Inlines[3] { > [1] Str "Author" > [2] Space > [3] Str "A" > } > [2] Inlines[3] { > [1] Str "Author" > [2] Space > [3] Str "B" > } > } > title: Inlines[1] { > [1] Str "Test" > } > } > > ... so I think you want this filter (MetaInlines isn't an attribute name, > and you have to count the space): > > function Meta (m) > print(pandoc.utils.stringify(m.author[1][3])) > end > > On Wed, 14 Jun 2023 at 17:47, Stephan Boltzmann > wrote: > >> Hello everybody out there using Pandoc, >> >> For the following short document, >> --- >> title: Test >> author: >> - Author A >> - Author B >> --- >> # Introduction >> >> I would expect the Lua filter >> >> function Meta (m) >> print(pandoc.utils.stringify(m.author[1].MetaInlines[2])) >> end >> >> to print out "A", but it prints nothing at all. >> >> What is the conceptual misunderstanding I have here? >> >> -- >> 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/pandoc-discuss/19962c60-238b-4ef4-bad6-a8200ca9a3cen%40googlegroups.com >> >> . >> > -- 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/64f0f40b-5c49-47fa-97f5-f824735f6cebn%40googlegroups.com. ------=_Part_6313_958494041.1686842236518 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks a lot for your help, which enabled me to write the following sh= ort filter, which puts the name of all authors on the same line in 'docx' output, while preserving th= e nice default layout in 'latex'<= /span> output.
Debugging filters working on the yaml metadata pro= vided a particular challenge to me:

function Meta (m)
=C2=A0 if FORMAT= :match 'docx' then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 authors =3D m.author[1]= .. {pandoc.Str(', ')} .. m.author[2]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 m.au= thor =3D pandoc.MetaInlines(authors)
=C2=A0 end
=C2=A0 return mend

It only handles two and not more = authors, but in my case, that's fine.
William Lupton schrieb am Mittwoch,= 14. Juni 2023 um 18:55:04 UTC+2:
Your metadata has this structure (hmm= ... perhaps some of the Inlines are really MetaInlines, in which case that&= #39;s a problem with my logging module):

(#) meta Meta {
=C2=A0 author: List[2] {
=C2=A0 =C2=A0 [1] = Inlines[3] {
=C2=A0 =C2=A0 =C2=A0 [1] Str "Author"
=C2=A0 = =C2=A0 =C2=A0 [2] Space
=C2=A0 =C2=A0 =C2=A0 [3] Str "A"
= =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 [2] Inlines[3] {
=C2=A0 =C2=A0 =C2=A0 [= 1] Str "Author"
=C2=A0 =C2=A0 =C2=A0 [2] Space
=C2=A0 =C2= =A0 =C2=A0 [3] Str "B"
=C2=A0 =C2=A0 }
=C2=A0 }
=C2=A0 t= itle: Inlines[1] {
=C2=A0 =C2=A0 [1] Str "Test"
=C2=A0 }}

... so I think you want this filter = (MetaInlines isn't an attribute name, and you have to count the space):=

function Meta (m)
=C2= =A0 =C2=A0 print(pandoc.utils.stringify(m.author[1][3]))
end

On Wed, 14 Jun 2023 at 17:47, Stephan Bol= tzmann <stephan2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org= > wrote:
Hello everybody out there using Pando= c,

For the following short document,
---
title: Test
author:
=C2=A0 - Author A
=C2=A0 -= Author B
---
<= br>
fu= nction Meta (m)
=C2=A0=C2=A0=C2=A0 print(pandoc.utils.stringify(m.author= [1].MetaInlines[2]))
end

to print out &q= uot;A", but it prints nothing at all.

What is= the conceptual misunderstanding I have here?

--
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-discus...@googleg= roups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/19962c60-2= 38b-4ef4-bad6-a8200ca9a3cen%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://groups.google.com/d= /msgid/pandoc-discuss/64f0f40b-5c49-47fa-97f5-f824735f6cebn%40googlegroups.= com.
------=_Part_6313_958494041.1686842236518-- ------=_Part_6312_1749575981.1686842236518--