public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Carsten Gips <cagixcagix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: How to resolve citations inside attributes
Date: Mon, 13 Sep 2021 00:54:40 -0700 (PDT)	[thread overview]
Message-ID: <9c08fc54-f3bf-451a-92fe-14d9c978711dn@googlegroups.com> (raw)
In-Reply-To: <m21r5x3br7.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 4563 bytes --]


Thanks, 'read' was the hint I was looking for! It's working now :)
John MacFarlane schrieb am Donnerstag, 9. September 2021 um 19:22:19 UTC+2:

>
> 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 <cagix...-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-discus...-/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/9c08fc54-f3bf-451a-92fe-14d9c978711dn%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 7716 bytes --]

      parent reply	other threads:[~2021-09-13  7:54 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
     [not found]         ` <m21r5x3br7.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
2021-09-13  7:54           ` Carsten Gips [this message]

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=9c08fc54-f3bf-451a-92fe-14d9c978711dn@googlegroups.com \
    --to=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).