From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29219 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Carsten Gips Newsgroups: gmane.text.pandoc Subject: Resolving citations inside attributes Date: Thu, 9 Sep 2021 01:14:12 -0700 (PDT) Message-ID: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_328_895990243.1631175252551" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35198"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDPI3JF23IIBB6V252EQMGQESSWM3SQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Sep 10 20:01:34 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f61.google.com ([209.85.161.61]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mOkqD-0008xH-5C for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 10 Sep 2021 20:01:33 +0200 Original-Received: by mail-oo1-f61.google.com with SMTP id s20-20020a4aead40000b029028b41986b27sf1504683ooh.14 for ; Fri, 10 Sep 2021 11:01:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:date:from:to:message-id:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=L5cUc08mLskmXKPxqarVvA5VkQYVvro2lsJKd0jv4vU=; b=pGYVUh8lMJxMV3GhBIRGAmPYFynRoy5LBf/VraEarnBoMpHFef+2CpaqSH+iymcuqz yTI5FlHEqiuJK7tAK5MC8eBZyQ2CT5+T3euW7h/E7aUz5y/LTDZSjiqxW3qdZb+JUUZA igJsYTgR7svrlumTNGEuLuIkAjtnVSLX0HbEbmUexbqgr1uq549RAktHEzlKobtKBepd zGNQ6prmHrLUQtWxNdutBKK0/4pzdd2UHUKhf+kVZPGvp6Z/X003zPkcsw8uHnckiFDk N3lO0l1u3kT/k1B2AcmBKJ2ulcm4QzKG/5zglFotnh0L4MexGZWXrNldw004hZ3t1GYC RV4g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:message-id:subject:mime-version:x-original-sender :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=L5cUc08mLskmXKPxqarVvA5VkQYVvro2lsJKd0jv4vU=; b=ZNXTzlbBStNxcwdeUGnt4WwdTFJZzT+KGkza1V/Op/Mv5/9wDjIJcUIzOp5eXWZAYI fTlR8iSrwI+4dCacg7CCdBfV03Wntpvp+AVJahtjsDL1szBOfy18kaGPeXMhKGw1qCBW NA1fIZrOYQOJgv4yMdhStBCbSyhLxTjCT3BT3/WN/JbTV3IJ38Wv3MfPZ+SO3yKTjcJB EZ9jummBOtOLlS2ReljX544sRyZJ/QdlsfMe2wZ5QIGZWqEgZsvsqsWq0i4bYEXmG0o9 CAyYmmDTgVcaW2LXhBkG4KptNkjPlizur2iYb4xVerJPN7UwBdYzyBPt083Xh0QPKyXd 1PeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:date:from:to:message-id:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=L5cUc08mLskmXKPxqarVvA5VkQYVvro2lsJKd0jv4vU=; b=jRT0QKSDnzrcb01UY6Fl9HD0VURAl3sWGogsu7TweCZQoG6KFRYEgif6GgxS9XN6SN zQ6hvAKf7FULdBdOvpRFuQcS5ITT3uwescpEWWi8aH9zkGA+RDXd0ITAhCCuQJr4Cq8D zfnj/lWPc68DdwBCx0OucFEa4w+QxcgKhoSq3SvYXLEnYxf+sdQl6kXxOr8qPF7yrl27 F4R7F8k/wx5Vhk7P8oosUGVjAuPgyZ9HeK/EKZHGH0Il05R/C88cOHqyxn6zBz0tq+4e AGmyyAcztazfGXtavFO/j1nWxLQtNJ3cSIFgp4YpAorPh2Nw6PDFR057GeCZnw2wkqNG xCcw== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM532dKXoEIMK1el5AgmW5tHyXjxab+3GEiHrcBD7io8A8wmj9DIZk UIZVzv8qvQwU07lkvTMQxq8= X-Google-Smtp-Source: ABdhPJyGhmiSEsiKWkMi9VXoRoIF8WRBdLDuNiQSXBNu21f6XMj3ddNFpTnvW+EqGqtkYk9Zh8OH6A== X-Received: by 2002:aca:aa47:: with SMTP id t68mr5171298oie.25.1631296891553; Fri, 10 Sep 2021 11:01:31 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6830:2442:: with SMTP id x2ls1815864otr.3.gmail; Fri, 10 Sep 2021 11:01:30 -0700 (PDT) X-Received: by 2002:a05:6830:1105:: with SMTP id w5mr5582381otq.85.1631296890277; Fri, 10 Sep 2021 11:01:30 -0700 (PDT) Original-Received: by 2002:aca:6288:0:b0:267:76:fb3b with SMTP id 5614622812f47-26dbc2d3a50msb6e; Thu, 9 Sep 2021 01:14:15 -0700 (PDT) X-Received: by 2002:a05:6830:2470:: with SMTP id x48mr1329133otr.103.1631175253181; Thu, 09 Sep 2021 01:14:13 -0700 (PDT) X-Original-Sender: cagixcagix-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:29219 Archived-At: ------=_Part_328_895990243.1631175252551 Content-Type: multipart/alternative; boundary="----=_Part_329_1526382415.1631175252551" ------=_Part_329_1526382415.1631175252551 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, I'm trying to resolve citations inside attributes, i.e. something like ```{.c caption=3D"nice piece, cf. [@FOO]"} int main() { return 42; } ``` Since Pandoc/Citeproc currently do not handle citations of this kind, I'm= =20 trying to resolve this manually with a Lua filter: Put this piece into a=20 new temporary document, run Pandoc+Citeproc on this document using=20 `pandoc.utils.run_json_filter`, retrieve the processed string and put back= =20 it in the original place, i.e. the caption. However, this approach seems to be not working? As a MWE I've tried this document `test.md`: ```markdown --- references: - author: - family: Wuppie id: FOO title: Lorem Ipsum --- see [@FOO] ``` Running `pandoc -t json --citeproc test.md` the result is=20 ```json {"pandoc-api-version":[1,22],"meta":{"references":{"t":"MetaList","c":[{"t"= :"MetaMap","c":{"author":{"t":"MetaList","c":[{"t":"MetaMap","c":{"family":= {"t":"MetaInlines","c":[{"t":"Str","c":"Wuppie"}]}}}]},"id":{"t":"MetaInlin= es","c":[{"t":"Str","c":"FOO"}]},"title":{"t":"MetaInlines","c":[{"t":"Str"= ,"c":"Lorem"},{"t":"Space"},{"t":"Str","c":"Ipsum"}]}}}]}},"blocks":[{"t":"= Para","c":[{"t":"Str","c":"see"},{"t":"Space"},{"t":"Cite","c":[[{"citation= Id":"FOO","citationPrefix":[],"citationSuffix":[],"citationMode":{"t":"Norm= alCitation"},"citationNoteNum":1,"citationHash":0}],[{"t":"Str","c":"(Wuppi= e,"},{"t":"Space"},{"t":"Str","c":"n.d.)"}]]}]},{"t":"Div","c":[["refs",["r= eferences","csl-bib-body","hanging-indent"],[]],[{"t":"Div","c":[["ref-FOO"= ,["csl-entry"],[]],[{"t":"Para","c":[{"t":"Str","c":"Wuppie."},{"t":"Space"= },{"t":"Str","c":"n.d."},{"t":"Space"},{"t":"Span","c":[["",[],[]],[{"t":"S= tr","c":"=E2=80=9C"},{"t":"Str","c":"Lorem"},{"t":"Space"},{"t":"Str","c":"= Ipsum"},{"t":"Str","c":"."},{"t":"Str","c":"=E2=80=9D"}]]}]}]]}]]}]} ``` , i.e. the citation is properly resolved (as expected). However, using the Lua filter `codecite.lua` (for the sake of simplicity,= =20 I'll just replace the old block directly with a citation): ```lua local meta function render_blocks(b) local blocks =3D {pandoc.Para{pandoc.Str("see [@FOO]")}} local tmp =3D pandoc.utils.run_json_filter( pandoc.Pandoc(blocks, meta), 'pandoc', {'--from=3Djson', '--to=3Djson', '--citeproc'} ) return tmp.blocks end return { { Meta =3D function (m) meta =3D m end }, { Block =3D render_blocks } } ``` and running `pandoc -L codecite.lua test.md -t json` the result is just=20 ```json {"pandoc-api-version":[1,22],"meta":{"references":{"t":"MetaList","c":[{"t"= :"MetaMap","c":{"author":{"t":"MetaList","c":[{"t":"MetaMap","c":{"family":= {"t":"MetaInlines","c":[{"t":"Str","c":"Wuppie"}]}}}]},"id":{"t":"MetaInlin= es","c":[{"t":"Str","c":"FOO"}]},"title":{"t":"MetaInlines","c":[{"t":"Str"= ,"c":"Lorem"},{"t":"Space"},{"t":"Str","c":"Ipsum"}]}}}]}},"blocks":[{"t":"= Para","c":[{"t":"Str","c":"see=20 [@FOO]"}]}]} ``` , which is unexpected (citation is not resolved). Clearly I'm missing something here. But what is it? Can you please advise? `pandoc --version`: pandoc 2.14.2 Thanks!=20 Carsten --=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/bcb42d1a-cd9f-45f1-a1f4-5f21cb9ae46an%40googlegroups.com. ------=_Part_329_1526382415.1631175252551 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, I'm trying to resolve citations inside attributes, i.e. something like<= div>
```{.c caption=3D"nice piece, cf. [@FOO]"}
int= main() {
    return 42;
}
```

Since Pandoc/Citeproc currently do not handle citation= s of this kind, I'm trying to resolve this manually with a Lua filter: Put = this piece into a new temporary document, run Pandoc+Citeproc on this docum= ent using `pandoc.utils.run_json_filter`, retrieve the processed string and= put back it in the original place, i.e. the caption.

<= div>However, this approach seems to be not working?

As a MWE I've tried this document `test.md`:

```= markdown
---
references:
- author:<= /div>
- family: Wuppie
id: FOO
title: Lorem I= psum
---
see [@FOO]
```

Running `pandoc -t json -= -citeproc test.md` the result is 
```json
{"pandoc= -api-version":[1,22],"meta":{"references":{"t":"MetaList","c":[{"t":"MetaMa= p","c":{"author":{"t":"MetaList","c":[{"t":"MetaMap","c":{"family":{"t":"Me= taInlines","c":[{"t":"Str","c":"Wuppie"}]}}}]},"id":{"t":"MetaInlines","c":= [{"t":"Str","c":"FOO"}]},"title":{"t":"MetaInlines","c":[{"t":"Str","c":"Lo= rem"},{"t":"Space"},{"t":"Str","c":"Ipsum"}]}}}]}},"blocks":[{"t":"Para","c= ":[{"t":"Str","c":"see"},{"t":"Space"},{"t":"Cite","c":[[{"citationId":"FOO= ","citationPrefix":[],"citationSuffix":[],"citationMode":{"t":"NormalCitati= on"},"citationNoteNum":1,"citationHash":0}],[{"t":"Str","c":"(Wuppie,"},{"t= ":"Space"},{"t":"Str","c":"n.d.)"}]]}]},{"t":"Div","c":[["refs",["reference= s","csl-bib-body","hanging-indent"],[]],[{"t":"Div","c":[["ref-FOO",["csl-e= ntry"],[]],[{"t":"Para","c":[{"t":"Str","c":"Wuppie."},{"t":"Space"},{"t":"= Str","c":"n.d."},{"t":"Space"},{"t":"Span","c":[["",[],[]],[{"t":"Str","c":= "=E2=80=9C"},{"t":"Str","c":"Lorem"},{"t":"Space"},{"t":"Str","c":"Ipsum"},= {"t":"Str","c":"."},{"t":"Str","c":"=E2=80=9D"}]]}]}]]}]]}]}
```<= /div>
, i.e. the citation is properly resolved (as expected).

However, using the Lua filter `codecite.lua` (for the sake = of simplicity, I'll just replace the old block directly with a citation):

```lua
local meta

function render_blocks(b)
    local blocks =3D {pa= ndoc.Para{pandoc.Str("see [@FOO]")}}

    local = tmp =3D pandoc.utils.run_json_filter(
       = pandoc.Pandoc(blocks, meta),
       = 'pandoc',
        {'--from=3Djson', '--to=3D= json', '--citeproc'}
    )
    = return tmp.blocks
end

return {
  &nb= sp; { Meta =3D function (m) meta =3D m end },
    { Blo= ck =3D render_blocks }
}
```

and running `pandoc -L codecite.lua test.md -t json` the result is ju= st 

```json
{"pandoc-api-version":[= 1,22],"meta":{"references":{"t":"MetaList","c":[{"t":"MetaMap","c":{"author= ":{"t":"MetaList","c":[{"t":"MetaMap","c":{"family":{"t":"MetaInlines","c":= [{"t":"Str","c":"Wuppie"}]}}}]},"id":{"t":"MetaInlines","c":[{"t":"Str","c"= :"FOO"}]},"title":{"t":"MetaInlines","c":[{"t":"Str","c":"Lorem"},{"t":"Spa= ce"},{"t":"Str","c":"Ipsum"}]}}}]}},"blocks":[{"t":"Para","c":[{"t":"Str","= c":"see [@FOO]"}]}]}
```
, which is unexpected (citatio= n is not resolved).

Clearly I'm missing something = here. But what is it? Can you please advise?

`pand= oc --version`: pandoc 2.14.2

Thanks! 
Carsten

--
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/bcb42d1a-cd9f-45f1-a1f4-5f21cb9ae46an%40googlegroups.= com.
------=_Part_329_1526382415.1631175252551-- ------=_Part_328_895990243.1631175252551--