public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>
To: Carsten Gips <cagixcagix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	pandoc-discuss
	<pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: How to resolve citations inside attributes
Date: Thu, 09 Sep 2021 10:22:04 -0700	[thread overview]
Message-ID: <m21r5x3br7.fsf@MacBook-Pro-2.hsd1.ca.comcast.net> (raw)
In-Reply-To: <782eda7c-31e7-45ac-928d-3fdea56e5412n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>


Citations are only recognized when they're parsed as markdown.
@key in a code block or attribute won't be parsed.

You could use the pandoc Lua 'read' function to parse the
contents of your attribute as Markdown and then do something with that.

Carsten Gips <cagixcagix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> I've tried to resolve this manually by extracting this piece with a Lua 
> filter, converting it into a new document and running Pandoc plus Citeproc 
> on this temporary document with `pandoc.utils.run_json_filter`, retrieving 
> the processed citation and putting it back as codeblock caption in the 
> original document. However, this approach seems not to be working.
>
> To narrow this down further, I wrote a short document (`test.md`, see 
> attachment) and a Lua filter (`codecite.lua`, see attachment). (To make it 
> even shorter, in the Lua filter I simply replace the text block of the 
> document with a similar new block).
>
> But this does not seem to work. The call `pandoc -L codecite.lua test.md -t 
> json` returns only 
>
> ```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":"Space"},{"t":"Str","c":"Ipsum"}]}}}]}},"blocks":[{"t":"Para","c":[{"t":"Str","c":"see 
> [@FOO]"}]}]}
> ```
> i.e. the citation is not resolved.
>
> However, if I run Pandoc directly on this document, i.e `pandoc -t json 
> --citeproc test.md`, the result is as expected:
>
> ```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":"Space"},{"t":"Str","c":"Ipsum"}]}}}]}},"blocks":[{"t":"Para","c":[{"t":"Str","c":"see"},{"t":"Space"},{"t":"Cite","c":[[{"citationId":"FOO","citationPrefix":[],"citationSuffix":[],"citationMode":{"t":"NormalCitation"},"citationNoteNum":1,"citationHash":0}],[{"t":"Str","c":"(Wuppie,"},{"t":"Space"},{"t":"Str","c":"n.d.)"}]]}]},{"t":"Div","c":[["refs",["references","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":"Str","c":"“"},{"t":"Str","c":"Lorem"},{"t":"Space"},{"t":"Str","c":"Ipsum"},{"t":"Str","c":"."},{"t":"Str","c":"”"}]]}]}]]}]]}]}
> ```
>
> Clearly I'm missing something here. But what is it? Can you please advise?
>
>
> PS: `pandoc --version`: pandoc 2.14.2
>
> Carsten Gips schrieb am Donnerstag, 9. September 2021 um 10:27:36 UTC+2:
>
>> Dear all,
>>
>> I'm trying to resolve citations inside attributes, i.e. 
>>
>> ```{.c caption="nice, see [@KEY]"}
>> ...
>> ```
>>
>> Pandoc and Citeproc are currently not handling citations inside am 
>> attribute like in the example. How can I resolve these citations anyway?
>>
>> Thanks,
>> Carsten
>>
>
> -- 
> 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/782eda7c-31e7-45ac-928d-3fdea56e5412n%40googlegroups.com.
> ---
> references:
> - author:
>   - family: Wuppie
>   id: FOO
>   title: Lorem Ipsum
> ---
> see [@FOO]

-- 
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/m21r5x3br7.fsf%40MacBook-Pro-2.hsd1.ca.comcast.net.


  parent reply	other threads:[~2021-09-09 17:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09  8:27 Carsten Gips
     [not found] ` <0bc0abba-e2ba-4473-b768-fe3fbbbcc0ebn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-09-09  8:39   ` Carsten Gips
     [not found]     ` <782eda7c-31e7-45ac-928d-3fdea56e5412n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-09-09 17:22       ` John MacFarlane [this message]
     [not found]         ` <m21r5x3br7.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
2021-09-13  7:54           ` Carsten Gips

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m21r5x3br7.fsf@MacBook-Pro-2.hsd1.ca.comcast.net \
    --to=jgm-tvlzxgkolnx2fbvcvol8/a@public.gmane.org \
    --cc=cagixcagix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).