public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* recursive citeproc?
@ 2021-01-25 14:00 Julien Dutant
       [not found] ` <22fc94e0-d1e7-44b9-a683-a387f3c24e58n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Julien Dutant @ 2021-01-25 14:00 UTC (permalink / raw)
  To: pandoc-discuss


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

Dear all, 

I have to work with self-citing .bib files. They contain \citet commands in 
the title and note fields, e.g.:

```
@Article{lewis_dk:1981b,
  author  = {Lewis, David},
  journal = {Theoria},
  title   = {Are We Free to Break the Laws?},
  year    = {1981},
  note    = {reprinted in \citet[291--298]{lewis_dk:1986a}},
  number  = {3},
  pages   = {113--121},
  volume  = {47},
  doi     = {10.1093/0195036468.003.0010},
}
@article{aaron_ri-etal:1961,
author = {Aaron, Richard Ithamar and Rotenstreich, Nathan and Passmore, 
John A. and Mercier, Andr{\'e} and Russell, Leonard and Moreau, Joseph },
year = { 1961 },
title = { Discussion sur \citet{hersch_j:1961} et \citet{marias:1961} },
journal = { dialectica },
volume = { 15 },
number = { 57--58 },
pages = { 253--257 },
}
```

In LaTeX these would be processed by compiling the document 3 times. But 
(a) I intend to work with citeproc + CSL, and (b) I can't manually replace 
all the \citet commands in the .bib file (thousands of entries). Right now 
my best solution would be to write a python script using bibparse and 
citeproc-py (https://pypi.org/project/bibparse/ and 
https://github.com/brechtm/citeproc-py) to process those \citet commands. 
But I'm curious to hear if you have a better idea - or if John would 
consider making citeproc recursive. 

In general, Citeproc processes LaTeX commands in .bib fields, but not \cite 
commands. They are passed as such in TeX output:

```
\leavevmode\hypertarget{ref-aaron_ri-etal:1961}{}%
Aaron, Richard Ithamar, Nathan Rotenstreich, John A. Passmore, André
Mercier, Leonard Russell, and Joseph Moreau. 1961. {``Discussion Sur
\cite{hersch_j:1961} Et {marias:1961}.''} \emph{Dialectica} 15 (57--58):
253--57.
```

Yet citeproc does recognize them because in HTML it prints the keys in a 
special 'citation-data' span:

```
<div id="ref-aaron_ri-etal:1961" class="csl-entry" role="doc-biblioentry">
Aaron, Richard Ithamar, Nathan Rotenstreich, John A. Passmore, André 
Mercier, Leonard Russell, and Joseph Moreau. 1961. <span>“Discussion Sur 
<span class="citation" data-cites="hersch_j:1961"></span> Et <span 
class="citation" data-cites="marias:1961"><span 
class="nocase">marias:1961</span></span>.”</span> <em>Dialectica</em> 15 
(57–58): 253–57.
```

When trying to produce a PDF we actually get an error, because natbib isn't 
loaded (citeproc has processed the references already) so the \citet 
command is unknown. 

As I said, a python script with bibparse and citeproc-py seems to me the 
best option at the moment. There's probably a Haskell option too 
(BibTex https://wiki.haskell.org/BibTeX and citeproc). Any suggestion 
welcome. 

All best,

Julien


-- 
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/22fc94e0-d1e7-44b9-a683-a387f3c24e58n%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: recursive citeproc?
       [not found] ` <22fc94e0-d1e7-44b9-a683-a387f3c24e58n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-01-25 16:42   ` John MacFarlane
       [not found]     ` <m2a6sxezok.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: John MacFarlane @ 2021-01-25 16:42 UTC (permalink / raw)
  To: Julien Dutant, pandoc-discuss


One approach that might work is to first convert to markdown
using --citeproc, and then to process this markdown document,
again using --citeproc, to your target format. That would be
like what you do in LaTeX, running it multiple times.

Julien Dutant <julien.dutant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Dear all, 
>
> I have to work with self-citing .bib files. They contain \citet commands in 
> the title and note fields, e.g.:
>
> ```
> @Article{lewis_dk:1981b,
>   author  = {Lewis, David},
>   journal = {Theoria},
>   title   = {Are We Free to Break the Laws?},
>   year    = {1981},
>   note    = {reprinted in \citet[291--298]{lewis_dk:1986a}},
>   number  = {3},
>   pages   = {113--121},
>   volume  = {47},
>   doi     = {10.1093/0195036468.003.0010},
> }
> @article{aaron_ri-etal:1961,
> author = {Aaron, Richard Ithamar and Rotenstreich, Nathan and Passmore, 
> John A. and Mercier, Andr{\'e} and Russell, Leonard and Moreau, Joseph },
> year = { 1961 },
> title = { Discussion sur \citet{hersch_j:1961} et \citet{marias:1961} },
> journal = { dialectica },
> volume = { 15 },
> number = { 57--58 },
> pages = { 253--257 },
> }
> ```
>
> In LaTeX these would be processed by compiling the document 3 times. But 
> (a) I intend to work with citeproc + CSL, and (b) I can't manually replace 
> all the \citet commands in the .bib file (thousands of entries). Right now 
> my best solution would be to write a python script using bibparse and 
> citeproc-py (https://pypi.org/project/bibparse/ and 
> https://github.com/brechtm/citeproc-py) to process those \citet commands. 
> But I'm curious to hear if you have a better idea - or if John would 
> consider making citeproc recursive. 
>
> In general, Citeproc processes LaTeX commands in .bib fields, but not \cite 
> commands. They are passed as such in TeX output:
>
> ```
> \leavevmode\hypertarget{ref-aaron_ri-etal:1961}{}%
> Aaron, Richard Ithamar, Nathan Rotenstreich, John A. Passmore, André
> Mercier, Leonard Russell, and Joseph Moreau. 1961. {``Discussion Sur
> \cite{hersch_j:1961} Et {marias:1961}.''} \emph{Dialectica} 15 (57--58):
> 253--57.
> ```
>
> Yet citeproc does recognize them because in HTML it prints the keys in a 
> special 'citation-data' span:
>
> ```
> <div id="ref-aaron_ri-etal:1961" class="csl-entry" role="doc-biblioentry">
> Aaron, Richard Ithamar, Nathan Rotenstreich, John A. Passmore, André 
> Mercier, Leonard Russell, and Joseph Moreau. 1961. <span>“Discussion Sur 
> <span class="citation" data-cites="hersch_j:1961"></span> Et <span 
> class="citation" data-cites="marias:1961"><span 
> class="nocase">marias:1961</span></span>.”</span> <em>Dialectica</em> 15 
> (57–58): 253–57.
> ```
>
> When trying to produce a PDF we actually get an error, because natbib isn't 
> loaded (citeproc has processed the references already) so the \citet 
> command is unknown. 
>
> As I said, a python script with bibparse and citeproc-py seems to me the 
> best option at the moment. There's probably a Haskell option too 
> (BibTex https://wiki.haskell.org/BibTeX and citeproc). Any suggestion 
> welcome. 
>
> All best,
>
> Julien
>
>
> -- 
> 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/22fc94e0-d1e7-44b9-a683-a387f3c24e58n%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/m2a6sxezok.fsf%40MacBook-Pro.hsd1.ca.comcast.net.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: recursive citeproc?
       [not found]     ` <m2a6sxezok.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
@ 2021-01-25 16:48       ` John MacFarlane
       [not found]         ` <m27do1ezdw.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: John MacFarlane @ 2021-01-25 16:48 UTC (permalink / raw)
  To: Julien Dutant, pandoc-discuss

John MacFarlane <fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> One approach that might work is to first convert to markdown
> using --citeproc, and then to process this markdown document,
> again using --citeproc, to your target format. That would be
> like what you do in LaTeX, running it multiple times.

To make this work, you'd need the first conversion to be

    -t markdown-citations

This will give you the md citations in the body text,
where they can be interpreted on the next pass with --citeproc.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: recursive citeproc?
       [not found]         ` <m27do1ezdw.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
@ 2021-01-25 17:58           ` Julien Dutant
       [not found]             ` <73b2c062-8ea8-4142-b9e3-9ad852c5dfeen-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Julien Dutant @ 2021-01-25 17:58 UTC (permalink / raw)
  To: pandoc-discuss


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

Thanks John. Just to clarify: my sources are already in pandoc's markdown. 
So I have a markdown file with, say, "@aaron_ri-etal:1961" and an 
associated .bib file that cites some of its own keys. 

If I understand well, the idea is to run these:
pandoc -s test.md --citeproc -t markdown-citations -o intermediate.md
pandoc -s intermediate.md -o intermediate.pdf/html

With the test.md file's metadata referencing the self-citing .bib file. (I 
didn't know the markdown-citations flag btw!)

In my test there's a problem: the self-cites are either left as LaTeX or 
printed as link with the bibtex key for text. Here's the test.bib file:

```
@article{aaron_ri-etal:1961,
author = { Aaron, Richard Ithamar and Rotenstreich, Nathan and Passmore, 
John A. and Mercier, Andr{\'e} and Russell, Leonard and Moreau, Joseph },
year = { 1961 },
title = { Discussion sur \citet{hersch_j:1961} et \citet{marias:1961} },
journal = { dialectica },
volume = { 15 },
number = { 57--58 },
pages = { 253--257 },
}

@article{hersch_j:1961,
author = { Hersch, J. },
year = { 1961 },
title = { Some paper },
journal = { dialectica },
volume = { 15 },
number = { 57--58 },
pages = { 253--257 },
}

@article{marias:1961,
author = { Marias, T. },
year = { 1961 },
title = { Some paper },
journal = { dialectica },
volume = { 15 },
number = { 57--58 },
pages = { 253--257 },
}
```

The test.md source:

```
---
author: John Dodd
title: My Paper
bibliography: test.bib
link-citations: true
---

I'm citing @aaron_ri-etal:1961 [165].
```

And the result of pandoc -s test.md -t markdown-citations --citeproc (note 
the \citet and the "marias:1961" link; no idea why one is treated one way 
and the other another way):

```
---
author: John Dodd
bibliography: test.bib
link-citations: true
title: My Paper
---

I'm citing [Aaron et al.](#ref-aaron_ri-etal:1961) ([1961,
165](#ref-aaron_ri-etal:1961)).

::: {#refs .references .csl-bib-body .hanging-indent}
::: {#ref-aaron_ri-etal:1961 .csl-entry}
Aaron, Richard Ithamar, Nathan Rotenstreich, John A. Passmore, André
Mercier, Leonard Russell, and Joseph Moreau. 1961. "Discussion Sur
`\citet{hersch_j:1961}`{=latex} Et [marias:1961]{.nocase}." *Dialectica*
15 (57--58): 253--57.
:::
:::
```

Or did I misunderstand the idea?

On Monday, January 25, 2021 at 4:48:43 PM UTC John MacFarlane wrote:

> John MacFarlane <fiddlo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
> > One approach that might work is to first convert to markdown
> > using --citeproc, and then to process this markdown document,
> > again using --citeproc, to your target format. That would be
> > like what you do in LaTeX, running it multiple times.
>
> To make this work, you'd need the first conversion to be
>
> -t markdown-citations
>
> This will give you the md citations in the body text,
> where they can be interpreted on the next pass with --citeproc.
>
>

-- 
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/73b2c062-8ea8-4142-b9e3-9ad852c5dfeen%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: recursive citeproc?
       [not found]             ` <73b2c062-8ea8-4142-b9e3-9ad852c5dfeen-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-01-25 18:01               ` Julien Dutant
       [not found]                 ` <93a071c5-3ec5-4bad-b3ef-74aa1c123780n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2021-01-25 19:00               ` John MacFarlane
  1 sibling, 1 reply; 9+ messages in thread
From: Julien Dutant @ 2021-01-25 18:01 UTC (permalink / raw)
  To: pandoc-discuss


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

PS, of course I meant to add citeproc in the second processing step. So I 
thought the idea was to run:
```
pandoc -s --citeproc test.md -t markdown-citations -o intermediate.md
pandoc -s --citeproc intermediate.md -o intermediate.pdf/html
```
Anyway the problem was with the first command. 

All best,

Julien
On Monday, January 25, 2021 at 5:58:53 PM UTC Julien Dutant wrote:

> Thanks John. Just to clarify: my sources are already in pandoc's markdown. 
> So I have a markdown file with, say, "@aaron_ri-etal:1961" and an 
> associated .bib file that cites some of its own keys. 
>
> If I understand well, the idea is to run these:
> pandoc -s test.md --citeproc -t markdown-citations -o intermediate.md
> pandoc -s intermediate.md -o intermediate.pdf/html
>
> With the test.md file's metadata referencing the self-citing .bib file. (I 
> didn't know the markdown-citations flag btw!)
>
> In my test there's a problem: the self-cites are either left as LaTeX or 
> printed as link with the bibtex key for text. Here's the test.bib file:
>
> ```
> @article{aaron_ri-etal:1961,
> author = { Aaron, Richard Ithamar and Rotenstreich, Nathan and Passmore, 
> John A. and Mercier, Andr{\'e} and Russell, Leonard and Moreau, Joseph },
> year = { 1961 },
> title = { Discussion sur \citet{hersch_j:1961} et \citet{marias:1961} },
> journal = { dialectica },
> volume = { 15 },
> number = { 57--58 },
> pages = { 253--257 },
> }
>
> @article{hersch_j:1961,
> author = { Hersch, J. },
> year = { 1961 },
> title = { Some paper },
> journal = { dialectica },
> volume = { 15 },
> number = { 57--58 },
> pages = { 253--257 },
> }
>
> @article{marias:1961,
> author = { Marias, T. },
> year = { 1961 },
> title = { Some paper },
> journal = { dialectica },
> volume = { 15 },
> number = { 57--58 },
> pages = { 253--257 },
> }
> ```
>
> The test.md source:
>
> ```
> ---
> author: John Dodd
> title: My Paper
> bibliography: test.bib
> link-citations: true
> ---
>
> I'm citing @aaron_ri-etal:1961 [165].
> ```
>
> And the result of pandoc -s test.md -t markdown-citations --citeproc (note 
> the \citet and the "marias:1961" link; no idea why one is treated one way 
> and the other another way):
>
> ```
> ---
> author: John Dodd
> bibliography: test.bib
> link-citations: true
> title: My Paper
> ---
>
> I'm citing [Aaron et al.](#ref-aaron_ri-etal:1961) ([1961,
> 165](#ref-aaron_ri-etal:1961)).
>
> ::: {#refs .references .csl-bib-body .hanging-indent}
> ::: {#ref-aaron_ri-etal:1961 .csl-entry}
> Aaron, Richard Ithamar, Nathan Rotenstreich, John A. Passmore, André
> Mercier, Leonard Russell, and Joseph Moreau. 1961. "Discussion Sur
> `\citet{hersch_j:1961}`{=latex} Et [marias:1961]{.nocase}." *Dialectica*
> 15 (57--58): 253--57.
> :::
> :::
> ```
>
> Or did I misunderstand the idea?
>
> On Monday, January 25, 2021 at 4:48:43 PM UTC John MacFarlane wrote:
>
>> John MacFarlane <fiddlo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: 
>>
>> > One approach that might work is to first convert to markdown 
>> > using --citeproc, and then to process this markdown document, 
>> > again using --citeproc, to your target format. That would be 
>> > like what you do in LaTeX, running it multiple times. 
>>
>> To make this work, you'd need the first conversion to be 
>>
>> -t markdown-citations 
>>
>> This will give you the md citations in the body text, 
>> where they can be interpreted on the next pass with --citeproc. 
>>
>>

-- 
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/93a071c5-3ec5-4bad-b3ef-74aa1c123780n%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: recursive citeproc?
       [not found]                 ` <93a071c5-3ec5-4bad-b3ef-74aa1c123780n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-01-25 18:06                   ` Julien Dutant
  0 siblings, 0 replies; 9+ messages in thread
From: Julien Dutant @ 2021-01-25 18:06 UTC (permalink / raw)
  To: pandoc-discuss


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

Oh, actually another problem with processing the markdown file (pandoc -s 
--citeproc test.md -t markdown-citations -o intermediate.md) is that it 
drops the self-cited references. 

Perhaps you meant to process the bib file. I tried:
pandoc --citeproc test.bib -t markdown-citations

But I have the same problem with the rendering of self-cites (LaTeX and or 
link with the key text, see below). In addition, I don't know how to use 
the resulting file as bibliography: if I put "bibliography : bibliotest.md" 
in my source file I get an error "Could not determine bibliography format". 

Result of pandoc --citeproc test.bib -t markdown-citations:
```
::: {#refs .references .csl-bib-body .hanging-indent}
::: {#ref-aaron_ri-etal:1961 .csl-entry}
Aaron, Richard Ithamar, Nathan Rotenstreich, John A. Passmore, André
Mercier, Leonard Russell, and Joseph Moreau. 1961. "Discussion Sur
`\citet{hersch_j:1961}`{=latex} Et [marias:1961]{.nocase}." *Dialectica*
15 (57--58): 253--57.
:::

::: {#ref-hersch_j:1961 .csl-entry}
Hersch, J. 1961. "Some Paper." *Dialectica* 15 (57--58): 253--57.
:::

::: {#ref-marias:1961 .csl-entry}
Marias, T. 1961. "Some Paper." *Dialectica* 15 (57--58): 253--57.
:::
:::
```



On Monday, January 25, 2021 at 6:01:05 PM UTC Julien Dutant wrote:

> PS, of course I meant to add citeproc in the second processing step. So I 
> thought the idea was to run:
> ```
> pandoc -s --citeproc test.md -t markdown-citations -o intermediate.md
> pandoc -s --citeproc intermediate.md -o intermediate.pdf/html
> ```
> Anyway the problem was with the first command. 
>
> All best,
>
> Julien
> On Monday, January 25, 2021 at 5:58:53 PM UTC Julien Dutant wrote:
>
>> Thanks John. Just to clarify: my sources are already in pandoc's 
>> markdown. So I have a markdown file with, say, "@aaron_ri-etal:1961" and an 
>> associated .bib file that cites some of its own keys. 
>>
>> If I understand well, the idea is to run these:
>> pandoc -s test.md --citeproc -t markdown-citations -o intermediate.md
>> pandoc -s intermediate.md -o intermediate.pdf/html
>>
>> With the test.md file's metadata referencing the self-citing .bib file. 
>> (I didn't know the markdown-citations flag btw!)
>>
>> In my test there's a problem: the self-cites are either left as LaTeX or 
>> printed as link with the bibtex key for text. Here's the test.bib file:
>>
>> ```
>> @article{aaron_ri-etal:1961,
>> author = { Aaron, Richard Ithamar and Rotenstreich, Nathan and Passmore, 
>> John A. and Mercier, Andr{\'e} and Russell, Leonard and Moreau, Joseph },
>> year = { 1961 },
>> title = { Discussion sur \citet{hersch_j:1961} et \citet{marias:1961} },
>> journal = { dialectica },
>> volume = { 15 },
>> number = { 57--58 },
>> pages = { 253--257 },
>> }
>>
>> @article{hersch_j:1961,
>> author = { Hersch, J. },
>> year = { 1961 },
>> title = { Some paper },
>> journal = { dialectica },
>> volume = { 15 },
>> number = { 57--58 },
>> pages = { 253--257 },
>> }
>>
>> @article{marias:1961,
>> author = { Marias, T. },
>> year = { 1961 },
>> title = { Some paper },
>> journal = { dialectica },
>> volume = { 15 },
>> number = { 57--58 },
>> pages = { 253--257 },
>> }
>> ```
>>
>> The test.md source:
>>
>> ```
>> ---
>> author: John Dodd
>> title: My Paper
>> bibliography: test.bib
>> link-citations: true
>> ---
>>
>> I'm citing @aaron_ri-etal:1961 [165].
>> ```
>>
>> And the result of pandoc -s test.md -t markdown-citations --citeproc 
>> (note the \citet and the "marias:1961" link; no idea why one is treated one 
>> way and the other another way):
>>
>> ```
>> ---
>> author: John Dodd
>> bibliography: test.bib
>> link-citations: true
>> title: My Paper
>> ---
>>
>> I'm citing [Aaron et al.](#ref-aaron_ri-etal:1961) ([1961,
>> 165](#ref-aaron_ri-etal:1961)).
>>
>> ::: {#refs .references .csl-bib-body .hanging-indent}
>> ::: {#ref-aaron_ri-etal:1961 .csl-entry}
>> Aaron, Richard Ithamar, Nathan Rotenstreich, John A. Passmore, André
>> Mercier, Leonard Russell, and Joseph Moreau. 1961. "Discussion Sur
>> `\citet{hersch_j:1961}`{=latex} Et [marias:1961]{.nocase}." *Dialectica*
>> 15 (57--58): 253--57.
>> :::
>> :::
>> ```
>>
>> Or did I misunderstand the idea?
>>
>> On Monday, January 25, 2021 at 4:48:43 PM UTC John MacFarlane wrote:
>>
>>> John MacFarlane <fiddlo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: 
>>>
>>> > One approach that might work is to first convert to markdown 
>>> > using --citeproc, and then to process this markdown document, 
>>> > again using --citeproc, to your target format. That would be 
>>> > like what you do in LaTeX, running it multiple times. 
>>>
>>> To make this work, you'd need the first conversion to be 
>>>
>>> -t markdown-citations 
>>>
>>> This will give you the md citations in the body text, 
>>> where they can be interpreted on the next pass with --citeproc. 
>>>
>>>

-- 
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/9fec3891-1a82-4309-ad5e-0e6ed672d98en%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: recursive citeproc?
       [not found]             ` <73b2c062-8ea8-4142-b9e3-9ad852c5dfeen-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2021-01-25 18:01               ` Julien Dutant
@ 2021-01-25 19:00               ` John MacFarlane
       [not found]                 ` <m2h7n4etad.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
  1 sibling, 1 reply; 9+ messages in thread
From: John MacFarlane @ 2021-01-25 19:00 UTC (permalink / raw)
  To: Julien Dutant, pandoc-discuss


OK, never mind, you're right -- we'd need the citations extension
to be both enabled (to get the bibliography written out) and
disabled (to get a citation in it and not the raw latex or key).

Here's something that MAY work:

pandoc input.md --bibliography bib.bib --citeproc -t json -s -o tmp.json
pandoc tmp.json --bibliography bib.bib --citeproc -s -o output.html -Msuppress-bibliography

This seemed to work for me.

Julien Dutant <julien.dutant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Thanks John. Just to clarify: my sources are already in pandoc's markdown. 
> So I have a markdown file with, say, "@aaron_ri-etal:1961" and an 
> associated .bib file that cites some of its own keys. 
>
> If I understand well, the idea is to run these:
> pandoc -s test.md --citeproc -t markdown-citations -o intermediate.md
> pandoc -s intermediate.md -o intermediate.pdf/html
>
> With the test.md file's metadata referencing the self-citing .bib file. (I 
> didn't know the markdown-citations flag btw!)
>
> In my test there's a problem: the self-cites are either left as LaTeX or 
> printed as link with the bibtex key for text. Here's the test.bib file:
>
> ```
> @article{aaron_ri-etal:1961,
> author = { Aaron, Richard Ithamar and Rotenstreich, Nathan and Passmore, 
> John A. and Mercier, Andr{\'e} and Russell, Leonard and Moreau, Joseph },
> year = { 1961 },
> title = { Discussion sur \citet{hersch_j:1961} et \citet{marias:1961} },
> journal = { dialectica },
> volume = { 15 },
> number = { 57--58 },
> pages = { 253--257 },
> }
>
> @article{hersch_j:1961,
> author = { Hersch, J. },
> year = { 1961 },
> title = { Some paper },
> journal = { dialectica },
> volume = { 15 },
> number = { 57--58 },
> pages = { 253--257 },
> }
>
> @article{marias:1961,
> author = { Marias, T. },
> year = { 1961 },
> title = { Some paper },
> journal = { dialectica },
> volume = { 15 },
> number = { 57--58 },
> pages = { 253--257 },
> }
> ```
>
> The test.md source:
>
> ```
> ---
> author: John Dodd
> title: My Paper
> bibliography: test.bib
> link-citations: true
> ---
>
> I'm citing @aaron_ri-etal:1961 [165].
> ```
>
> And the result of pandoc -s test.md -t markdown-citations --citeproc (note 
> the \citet and the "marias:1961" link; no idea why one is treated one way 
> and the other another way):
>
> ```
> ---
> author: John Dodd
> bibliography: test.bib
> link-citations: true
> title: My Paper
> ---
>
> I'm citing [Aaron et al.](#ref-aaron_ri-etal:1961) ([1961,
> 165](#ref-aaron_ri-etal:1961)).
>
> ::: {#refs .references .csl-bib-body .hanging-indent}
> ::: {#ref-aaron_ri-etal:1961 .csl-entry}
> Aaron, Richard Ithamar, Nathan Rotenstreich, John A. Passmore, André
> Mercier, Leonard Russell, and Joseph Moreau. 1961. "Discussion Sur
> `\citet{hersch_j:1961}`{=latex} Et [marias:1961]{.nocase}." *Dialectica*
> 15 (57--58): 253--57.
> :::
> :::
> ```
>
> Or did I misunderstand the idea?
>
> On Monday, January 25, 2021 at 4:48:43 PM UTC John MacFarlane wrote:
>
>> John MacFarlane <fiddlo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>>
>> > One approach that might work is to first convert to markdown
>> > using --citeproc, and then to process this markdown document,
>> > again using --citeproc, to your target format. That would be
>> > like what you do in LaTeX, running it multiple times.
>>
>> To make this work, you'd need the first conversion to be
>>
>> -t markdown-citations
>>
>> This will give you the md citations in the body text,
>> where they can be interpreted on the next pass with --citeproc.
>>
>>
>
> -- 
> 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/73b2c062-8ea8-4142-b9e3-9ad852c5dfeen%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/m2h7n4etad.fsf%40MacBook-Pro.hsd1.ca.comcast.net.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: recursive citeproc?
       [not found]                 ` <m2h7n4etad.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
@ 2021-01-26  1:21                   ` Julien Dutant
       [not found]                     ` <ba140ff7-43ea-4547-8dc5-c08e6eb6e906n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Julien Dutant @ 2021-01-26  1:21 UTC (permalink / raw)
  To: pandoc-discuss


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

Smart, it does work! The only thing needed is to add the self-cited keys as 
`nocite` to ensure they appear in the biblio too. So with input.md:

```
---
author: John Dodd
title: My Paper
nocite: |
    @hersch_j:1961, @marias:1961
---
I'm citing @aaron_ri-etal:1961 [165].
```

And the test.bib above, using the first run from .md to .json and the 
second run to the output with --M supress-bibliography produces the desired 
output:

```
...
<div id="refs" class="references csl-bib-body hanging-indent" 
role="doc-bibliography">
<div id="ref-aaron_ri-etal:1961" class="csl-entry" role="doc-biblioentry">
Aaron, Richard Ithamar, Nathan Rotenstreich, John A. Passmore, André 
Mercier, Leonard Russell, and Joseph Moreau. 1961. <span>“Discussion Sur 
<span class="citation" data-cites="hersch_j:1961">Hersch (1961)</span> Et 
<span class="citation" data-cites="marias:1961">Marias 
(1961)</span>.”</span> <em>Dialectica</em> 15 (57–58): 253–57.
</div>
<div id="ref-hersch_j:1961" class="csl-entry" role="doc-biblioentry">
Hersch, J. 1961. <span>“Some Paper.”</span> <em>Dialectica</em> 15 (57–58): 
253–57.
</div>
<div id="ref-marias:1961" class="csl-entry" role="doc-biblioentry">
Marias, T. 1961. <span>“Some Paper.”</span> <em>Dialectica</em> 15 (57–58): 
253–57.
</div>
</div>
```

Strangely, I notice in the json that the citations are converted one in 
latex raw citation and one in markdown - perhaps because the former 
contains an underscore? But that doesn't prevent citeproc from processing 
both on the second run. 

```
{"t":"Cite","c":[[{"citationId":"hersch_j:1961","citationPrefix":[],"citationSuffix":[],"citationMode":{"t":"AuthorInText"},"citationNoteNum":0,"citationHash":0}],[{"t":"RawInline","c":["latex","\\citet{hersch_j:1961}"]}]]},{"t":"Space"},{"t":"Str","c":"Et"},{"t":"Space"},{"t":"Cite","c":[[{"citationId":"marias:1961","citationPrefix":[],"citationSuffix":[],"citationMode":{"t":"AuthorInText"},"citationNoteNum":0,"citationHash":0}],[{"t":"Span","c":[["",["nocase"],[]],[{"t":"Str","c":"marias:1961"}]]}]]}
```

In case anyone else is reading: as I understand it, the first run (from 
input to json) formats and prints out a bibliography and the end of the 
document, but still with self-citations commands (as in the json excerpt 
above). It's necessary to go to json because other formats would either not 
contain the bibliography (markdown output) or not have their included 
citations commands processed in the second run (html, say). In the second 
run, citeproc replaces these leftover citations commands with their 
formatted output, e.g. "Marias (1961)". Without the variable 
"suppress-bibliography" the second run would produce a second bibliography 
below the first, but with it that is avoided and we get the desired output.

This is brilliant, thanks. It'll spare me quite a bit of work.

Julien
On Monday, January 25, 2021 at 7:00:26 PM UTC John MacFarlane wrote:

>
> OK, never mind, you're right -- we'd need the citations extension
> to be both enabled (to get the bibliography written out) and
> disabled (to get a citation in it and not the raw latex or key).
>
> Here's something that MAY work:
>
> pandoc input.md --bibliography bib.bib --citeproc -t json -s -o tmp.json
> pandoc tmp.json --bibliography bib.bib --citeproc -s -o output.html 
> -Msuppress-bibliography
>
> This seemed to work for me.
>
> Julien Dutant <julien...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
> > Thanks John. Just to clarify: my sources are already in pandoc's 
> markdown. 
> > So I have a markdown file with, say, "@aaron_ri-etal:1961" and an 
> > associated .bib file that cites some of its own keys. 
> >
> > If I understand well, the idea is to run these:
> > pandoc -s test.md --citeproc -t markdown-citations -o intermediate.md
> > pandoc -s intermediate.md -o intermediate.pdf/html
> >
> > With the test.md file's metadata referencing the self-citing .bib file. 
> (I 
> > didn't know the markdown-citations flag btw!)
> >
> > In my test there's a problem: the self-cites are either left as LaTeX or 
> > printed as link with the bibtex key for text. Here's the test.bib file:
> >
> > ```
> > @article{aaron_ri-etal:1961,
> > author = { Aaron, Richard Ithamar and Rotenstreich, Nathan and Passmore, 
> > John A. and Mercier, Andr{\'e} and Russell, Leonard and Moreau, Joseph },
> > year = { 1961 },
> > title = { Discussion sur \citet{hersch_j:1961} et \citet{marias:1961} },
> > journal = { dialectica },
> > volume = { 15 },
> > number = { 57--58 },
> > pages = { 253--257 },
> > }
> >
> > @article{hersch_j:1961,
> > author = { Hersch, J. },
> > year = { 1961 },
> > title = { Some paper },
> > journal = { dialectica },
> > volume = { 15 },
> > number = { 57--58 },
> > pages = { 253--257 },
> > }
> >
> > @article{marias:1961,
> > author = { Marias, T. },
> > year = { 1961 },
> > title = { Some paper },
> > journal = { dialectica },
> > volume = { 15 },
> > number = { 57--58 },
> > pages = { 253--257 },
> > }
> > ```
> >
> > The test.md source:
> >
> > ```
> > ---
> > author: John Dodd
> > title: My Paper
> > bibliography: test.bib
> > link-citations: true
> > ---
> >
> > I'm citing @aaron_ri-etal:1961 [165].
> > ```
> >
> > And the result of pandoc -s test.md -t markdown-citations --citeproc 
> (note 
> > the \citet and the "marias:1961" link; no idea why one is treated one 
> way 
> > and the other another way):
> >
> > ```
> > ---
> > author: John Dodd
> > bibliography: test.bib
> > link-citations: true
> > title: My Paper
> > ---
> >
> > I'm citing [Aaron et al.](#ref-aaron_ri-etal:1961) ([1961,
> > 165](#ref-aaron_ri-etal:1961)).
> >
> > ::: {#refs .references .csl-bib-body .hanging-indent}
> > ::: {#ref-aaron_ri-etal:1961 .csl-entry}
> > Aaron, Richard Ithamar, Nathan Rotenstreich, John A. Passmore, André
> > Mercier, Leonard Russell, and Joseph Moreau. 1961. "Discussion Sur
> > `\citet{hersch_j:1961}`{=latex} Et [marias:1961]{.nocase}." *Dialectica*
> > 15 (57--58): 253--57.
> > :::
> > :::
> > ```
> >
> > Or did I misunderstand the idea?
> >
> > On Monday, January 25, 2021 at 4:48:43 PM UTC John MacFarlane wrote:
> >
> >> John MacFarlane <fiddlo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
> >>
> >> > One approach that might work is to first convert to markdown
> >> > using --citeproc, and then to process this markdown document,
> >> > again using --citeproc, to your target format. That would be
> >> > like what you do in LaTeX, running it multiple times.
> >>
> >> To make this work, you'd need the first conversion to be
> >>
> >> -t markdown-citations
> >>
> >> This will give you the md citations in the body text,
> >> where they can be interpreted on the next pass with --citeproc.
> >>
> >>
> >
> > -- 
> > 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/73b2c062-8ea8-4142-b9e3-9ad852c5dfeen%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/ba140ff7-43ea-4547-8dc5-c08e6eb6e906n%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: recursive citeproc?
       [not found]                     ` <ba140ff7-43ea-4547-8dc5-c08e6eb6e906n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-01-26  2:30                       ` John MacFarlane
  0 siblings, 0 replies; 9+ messages in thread
From: John MacFarlane @ 2021-01-26  2:30 UTC (permalink / raw)
  To: Julien Dutant, pandoc-discuss

Julien Dutant <julien.dutant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Strangely, I notice in the json that the citations are converted one in 
> latex raw citation and one in markdown - perhaps because the former 
> contains an underscore?

No, that isn't why.  I think this is a bug but I don't really
understand it.

I'll put up an issue to think about it more.


https://github.com/jgm/pandoc/issues/7049


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-01-26  2:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25 14:00 recursive citeproc? Julien Dutant
     [not found] ` <22fc94e0-d1e7-44b9-a683-a387f3c24e58n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-01-25 16:42   ` John MacFarlane
     [not found]     ` <m2a6sxezok.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2021-01-25 16:48       ` John MacFarlane
     [not found]         ` <m27do1ezdw.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2021-01-25 17:58           ` Julien Dutant
     [not found]             ` <73b2c062-8ea8-4142-b9e3-9ad852c5dfeen-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-01-25 18:01               ` Julien Dutant
     [not found]                 ` <93a071c5-3ec5-4bad-b3ef-74aa1c123780n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-01-25 18:06                   ` Julien Dutant
2021-01-25 19:00               ` John MacFarlane
     [not found]                 ` <m2h7n4etad.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2021-01-26  1:21                   ` Julien Dutant
     [not found]                     ` <ba140ff7-43ea-4547-8dc5-c08e6eb6e906n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-01-26  2:30                       ` John MacFarlane

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).