public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* generate bibliography from citations keys in docx?
@ 2020-03-25 12:01 Andrzej Wodecki
       [not found] ` <4d035407-d692-4ada-ac1a-b2668c8c80bc-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Andrzej Wodecki @ 2020-03-25 12:01 UTC (permalink / raw)
  To: pandoc-discuss


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

Hi, 

I just wrote a book with hundreds of references stored in mylibrary.lib 
file.
Due to my original workflow (Scrivener > Markdown > pandoc-citeproc > MS 
Word)
at the moment I have everything in an MS Word file, where each citation is 
in the form [@citation_key], like below:

From [@andy2020] we can see that...
 
My goal is to generate the bibliography (I use Zotero as a reference 
manager). 

And here comes the problem: I tried many options with pandoc-citeproc and 
nothing worked...

Below is a simplified version of my trials and errors.

The mylibrary.bib file has only one entry looks like this:
*@article{andy2020,*
*  title = {Reinforcement Learning: {{A}} Survey},*
*  volume = {4},*
*  shorttitle = {Reinforcement Learning},*
*  journaltitle = {Journal of artificial intelligence research},*
*  date = {1996},*
*  pages = {237--285},*
*  author = {Kaelbling, Leslie Pack and Littman, Michael L. and Moore, 
Andrew W.}*
*}*


1. First trial

with in.md:

*From [@andy2020]  we can see that...*

command:
pandoc in.md --filter pandoc-citeproc --bibliography mylibrary.bib -o 
out.docx

correctly generates docx:

*From (Kaelbling, Littman, and Moore 1996) we can see that…*
*Kaelbling, Leslie Pack, Michael L. Littman, and Andrew W. Moore. 1996. 
“Reinforcement Learning: A Survey.” Journal of Artificial Intelligence 
Research 4: 237–85.*


2. Second trial
 
with in.docx:

*From [@andy2020] we can see that...*

pandoc in.docx --filter pandoc-citeproc --bibliography mylibrary.bib -o 
out.docx

generates out.docx with:
*From [@andy2020] we can see that...*

*No bibliography generated.*

3. 
with in.docx:
*From [@andy2020] we can see that...*

command:
pandoc in.docx --filter pandoc-citeproc --bibliography mylibrary.bib -o 
out.md

generates out.md with:

*From \[\@andy2020\] we can see that\...*

Note some escape \ characters...

My goal is to successfully generate a bibliography from in.docx to 
out.docx, like in the second trial.

Any ideas? That extremely important to me, I have literally hundreds of 
references...

I would really appreciate Your help, 

Many thanks in advance :)

Andy

-- 
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/4d035407-d692-4ada-ac1a-b2668c8c80bc%40googlegroups.com.

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

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

* Re: generate bibliography from citations keys in docx?
       [not found] ` <4d035407-d692-4ada-ac1a-b2668c8c80bc-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-03-25 13:10   ` Joseph Reagle
       [not found]     ` <30f53079-9e7a-2046-f458-b23f9736ac48-T1oY19WcHSwdnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Joseph Reagle @ 2020-03-25 13:10 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


On 3/25/20 8:01 AM, Andrzej Wodecki wrote:
> Second trial  
> with in.docx: 

Pandoc doesn't expect to find markdown (including pandoc's citation syntax) in a Word file. That only works in markdown files (and perhaps org files). So when it sees a citation in word->markdown, it takes it literally, and escapes the brackets so it remains so in the markdown.

Perhaps someone else can recommend a configuration that won't escape citation syntax, allowing you to go to markdown, and then from that back to Word.

This seems convoluted though. If you're using Zotero, why not use the Word plugin for that? Or, why not stay in markdown as your source document?

-- 
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/30f53079-9e7a-2046-f458-b23f9736ac48%40reagle.org.


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

* Re: generate bibliography from citations keys in docx?
       [not found]     ` <30f53079-9e7a-2046-f458-b23f9736ac48-T1oY19WcHSwdnm+yROfE0A@public.gmane.org>
@ 2020-03-25 16:14       ` Andrzej Wodecki
       [not found]         ` <7e7dfd7e-1bf1-4557-a5f0-e686d48e2438-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Andrzej Wodecki @ 2020-03-25 16:14 UTC (permalink / raw)
  To: pandoc-discuss


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

The reason I have citation keys in MS Word is a consequence of my original 
workflow:
Scrivener > markdown > pandoc-citeproc > MS Word, BTW described here: 
https://medium.com/@andrzej.wodecki/scrivener-for-scientific-writing-setup-af5edf4482b8

But at the final stage of my writings I escaped from Scrivener (export to 
MS Word), with only citation keys left in my doc.
If only I start from scratch in MS Word that wouldn't be a problem, but...

My temporary workaround (very primitive, but works) is:
1. docx > pandoc > markdown
2. markdown: replace all \@ by @
3. markdown > pandoc-citeproc > docx

Anyway, if you have any ideas for anything smarter would be nice to hear :)

Yours, 

Andy


W dniu środa, 25 marca 2020 14:11:06 UTC+1 użytkownik Joseph napisał:
>
>
> On 3/25/20 8:01 AM, Andrzej Wodecki wrote: 
> > Second trial   
> > with in.docx: 
>
> Pandoc doesn't expect to find markdown (including pandoc's citation 
> syntax) in a Word file. That only works in markdown files (and perhaps org 
> files). So when it sees a citation in word->markdown, it takes it 
> literally, and escapes the brackets so it remains so in the markdown. 
>
> Perhaps someone else can recommend a configuration that won't escape 
> citation syntax, allowing you to go to markdown, and then from that back to 
> Word. 
>
> This seems convoluted though. If you're using Zotero, why not use the Word 
> plugin for that? Or, why not stay in markdown as your source document? 
>
>

-- 
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/7e7dfd7e-1bf1-4557-a5f0-e686d48e2438%40googlegroups.com.

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

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

* Re: generate bibliography from citations keys in docx?
       [not found]         ` <7e7dfd7e-1bf1-4557-a5f0-e686d48e2438-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-03-25 16:35           ` John MacFarlane
       [not found]             ` <m28sjotmsv.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: John MacFarlane @ 2020-03-25 16:35 UTC (permalink / raw)
  To: Andrzej Wodecki, pandoc-discuss


You could use a lua filter.

If you do `pandoc your.docx -t native` you'll see how pandoc
parses these faux markdown citations.

If they appear as

Str "[@jones]"

then you could use a filter to replace any Str elements
fitting this pattern with a Cite element.  I can't explain
the whole thing here -- if you want to pursue this, see
the lua filter docs on the website.

Andrzej Wodecki <andrzej.wodecki-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> The reason I have citation keys in MS Word is a consequence of my original 
> workflow:
> Scrivener > markdown > pandoc-citeproc > MS Word, BTW described here: 
> https://medium.com/@andrzej.wodecki/scrivener-for-scientific-writing-setup-af5edf4482b8
>
> But at the final stage of my writings I escaped from Scrivener (export to 
> MS Word), with only citation keys left in my doc.
> If only I start from scratch in MS Word that wouldn't be a problem, but...
>
> My temporary workaround (very primitive, but works) is:
> 1. docx > pandoc > markdown
> 2. markdown: replace all \@ by @
> 3. markdown > pandoc-citeproc > docx
>
> Anyway, if you have any ideas for anything smarter would be nice to hear :)
>
> Yours, 
>
> Andy
>
>
> W dniu środa, 25 marca 2020 14:11:06 UTC+1 użytkownik Joseph napisał:
>>
>>
>> On 3/25/20 8:01 AM, Andrzej Wodecki wrote: 
>> > Second trial   
>> > with in.docx: 
>>
>> Pandoc doesn't expect to find markdown (including pandoc's citation 
>> syntax) in a Word file. That only works in markdown files (and perhaps org 
>> files). So when it sees a citation in word->markdown, it takes it 
>> literally, and escapes the brackets so it remains so in the markdown. 
>>
>> Perhaps someone else can recommend a configuration that won't escape 
>> citation syntax, allowing you to go to markdown, and then from that back to 
>> Word. 
>>
>> This seems convoluted though. If you're using Zotero, why not use the Word 
>> plugin for that? Or, why not stay in markdown as your source document? 
>>
>>
>
> -- 
> 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/7e7dfd7e-1bf1-4557-a5f0-e686d48e2438%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/m28sjotmsv.fsf%40johnmacfarlane.net.


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

* Re: generate bibliography from citations keys in docx?
       [not found]             ` <m28sjotmsv.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2020-03-25 17:09               ` Andrzej Wodecki
       [not found]                 ` <db7c031a-9b53-42e5-b073-f70fa0c16de1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Andrzej Wodecki @ 2020-03-25 17:09 UTC (permalink / raw)
  To: pandoc-discuss


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

DearJohn, 

many thanks. I've tried, and with:

pandoc in.docx --filter pandoc-citeproc --bibliography mylibrary.bib -t 
native

I get

[Para [Str "From",Space,Str "[@andy2020]",Space,Str ...

as you suggested. I've looked at: https://pandoc.org/lua-filters.html
and successfully run the first example "smallcaps.lua". But here I'm stuck: 
I don't know how to write the filter for 
Str "[@ > Cite "[
replacement.

If its not a problem, I would appreciate any tip/help, or just a snippet,

many thanks in advance, 

Andy


W dniu środa, 25 marca 2020 17:36:06 UTC+1 użytkownik John MacFarlane 
napisał:
>
>
> You could use a lua filter. 
>
> If you do `pandoc your.docx -t native` you'll see how pandoc 
> parses these faux markdown citations. 
>
> If they appear as 
>
> Str "[@jones]" 
>
> then you could use a filter to replace any Str elements 
> fitting this pattern with a Cite element.  I can't explain 
> the whole thing here -- if you want to pursue this, see 
> the lua filter docs on the website. 
>
> Andrzej Wodecki <andrzej...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: 
>
> > The reason I have citation keys in MS Word is a consequence of my 
> original 
> > workflow: 
> > Scrivener > markdown > pandoc-citeproc > MS Word, BTW described here: 
> > 
> https://medium.com/@andrzej.wodecki/scrivener-for-scientific-writing-setup-af5edf4482b8 
> > 
> > But at the final stage of my writings I escaped from Scrivener (export 
> to 
> > MS Word), with only citation keys left in my doc. 
> > If only I start from scratch in MS Word that wouldn't be a problem, 
> but... 
> > 
> > My temporary workaround (very primitive, but works) is: 
> > 1. docx > pandoc > markdown 
> > 2. markdown: replace all \@ by @ 
> > 3. markdown > pandoc-citeproc > docx 
> > 
> > Anyway, if you have any ideas for anything smarter would be nice to hear 
> :) 
> > 
> > Yours, 
> > 
> > Andy 
> > 
> > 
> > W dniu środa, 25 marca 2020 14:11:06 UTC+1 użytkownik Joseph napisał: 
> >> 
> >> 
> >> On 3/25/20 8:01 AM, Andrzej Wodecki wrote: 
> >> > Second trial   
> >> > with in.docx: 
> >> 
> >> Pandoc doesn't expect to find markdown (including pandoc's citation 
> >> syntax) in a Word file. That only works in markdown files (and perhaps 
> org 
> >> files). So when it sees a citation in word->markdown, it takes it 
> >> literally, and escapes the brackets so it remains so in the markdown. 
> >> 
> >> Perhaps someone else can recommend a configuration that won't escape 
> >> citation syntax, allowing you to go to markdown, and then from that 
> back to 
> >> Word. 
> >> 
> >> This seems convoluted though. If you're using Zotero, why not use the 
> Word 
> >> plugin for that? Or, why not stay in markdown as your source document? 
> >> 
> >> 
> > 
> > -- 
> > 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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/7e7dfd7e-1bf1-4557-a5f0-e686d48e2438%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/db7c031a-9b53-42e5-b073-f70fa0c16de1%40googlegroups.com.

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

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

* Re: generate bibliography from citations keys in docx?
       [not found]                 ` <db7c031a-9b53-42e5-b073-f70fa0c16de1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-03-25 20:21                   ` John MacFarlane
       [not found]                     ` <m2wo78rxrl.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: John MacFarlane @ 2020-03-25 20:21 UTC (permalink / raw)
  To: Andrzej Wodecki, pandoc-discuss


function Str(el)
  local citekey = el.text:match("[[]@(%w+)[]]")
  local citation = pandoc.Citation(citekey, 'NormalCitation')
  return pandoc.Cite({pandoc.Str(citekey)},
                     {citation})
end

Andrzej Wodecki <andrzej.wodecki-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> DearJohn, 
>
> many thanks. I've tried, and with:
>
> pandoc in.docx --filter pandoc-citeproc --bibliography mylibrary.bib -t 
> native
>
> I get
>
> [Para [Str "From",Space,Str "[@andy2020]",Space,Str ...
>
> as you suggested. I've looked at: https://pandoc.org/lua-filters.html
> and successfully run the first example "smallcaps.lua". But here I'm stuck: 
> I don't know how to write the filter for 
> Str "[@ > Cite "[
> replacement.
>
> If its not a problem, I would appreciate any tip/help, or just a snippet,
>
> many thanks in advance, 
>
> Andy
>
>
> W dniu środa, 25 marca 2020 17:36:06 UTC+1 użytkownik John MacFarlane 
> napisał:
>>
>>
>> You could use a lua filter. 
>>
>> If you do `pandoc your.docx -t native` you'll see how pandoc 
>> parses these faux markdown citations. 
>>
>> If they appear as 
>>
>> Str "[@jones]" 
>>
>> then you could use a filter to replace any Str elements 
>> fitting this pattern with a Cite element.  I can't explain 
>> the whole thing here -- if you want to pursue this, see 
>> the lua filter docs on the website. 
>>
>> Andrzej Wodecki <andrzej...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: 
>>
>> > The reason I have citation keys in MS Word is a consequence of my 
>> original 
>> > workflow: 
>> > Scrivener > markdown > pandoc-citeproc > MS Word, BTW described here: 
>> > 
>> https://medium.com/@andrzej.wodecki/scrivener-for-scientific-writing-setup-af5edf4482b8 
>> > 
>> > But at the final stage of my writings I escaped from Scrivener (export 
>> to 
>> > MS Word), with only citation keys left in my doc. 
>> > If only I start from scratch in MS Word that wouldn't be a problem, 
>> but... 
>> > 
>> > My temporary workaround (very primitive, but works) is: 
>> > 1. docx > pandoc > markdown 
>> > 2. markdown: replace all \@ by @ 
>> > 3. markdown > pandoc-citeproc > docx 
>> > 
>> > Anyway, if you have any ideas for anything smarter would be nice to hear 
>> :) 
>> > 
>> > Yours, 
>> > 
>> > Andy 
>> > 
>> > 
>> > W dniu środa, 25 marca 2020 14:11:06 UTC+1 użytkownik Joseph napisał: 
>> >> 
>> >> 
>> >> On 3/25/20 8:01 AM, Andrzej Wodecki wrote: 
>> >> > Second trial   
>> >> > with in.docx: 
>> >> 
>> >> Pandoc doesn't expect to find markdown (including pandoc's citation 
>> >> syntax) in a Word file. That only works in markdown files (and perhaps 
>> org 
>> >> files). So when it sees a citation in word->markdown, it takes it 
>> >> literally, and escapes the brackets so it remains so in the markdown. 
>> >> 
>> >> Perhaps someone else can recommend a configuration that won't escape 
>> >> citation syntax, allowing you to go to markdown, and then from that 
>> back to 
>> >> Word. 
>> >> 
>> >> This seems convoluted though. If you're using Zotero, why not use the 
>> Word 
>> >> plugin for that? Or, why not stay in markdown as your source document? 
>> >> 
>> >> 
>> > 
>> > -- 
>> > 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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/7e7dfd7e-1bf1-4557-a5f0-e686d48e2438%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/db7c031a-9b53-42e5-b073-f70fa0c16de1%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/m2wo78rxrl.fsf%40johnmacfarlane.net.


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

* Re: generate bibliography from citations keys in docx?
       [not found]                     ` <m2wo78rxrl.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2020-03-26  6:13                       ` Andrzej Wodecki
       [not found]                         ` <23e7c785-0f67-4b15-92b6-5c05cf2be2f7-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Andrzej Wodecki @ 2020-03-26  6:13 UTC (permalink / raw)
  To: pandoc-discuss


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

Dear John, 

many many thanks, You helped me a lot. I *almost* there - and as always *almost 
*makes a difference...

At the moment, having 

*From [@andy2020] we can see that...*

in in.docx, and Your snippet in cite.lua, when I run:
pandoc in.docx --lua-filter=cite.lua --filter pandoc-citeproc 
--bibliography mylibrary.bib -o out.docx

I get out.docx as:

*(Kaelbling, Littman, and Moore 1996) Kaelbling, Leslie Pack, Michael L. 
Littman, and Andrew W. Moore. 1996. “Reinforcement Learning: A Survey.” 
Journal of Artificial Intelligence Research 4: 237–85.*

So, the only thing left is citation [@andy2020], but all other texts are 
gone...

Sorry for bothering You, but *what should I do to just replace [@andy2020] 
with reference and create Bibliography at the end, but having all other 
texts intact?*

Many thanks for the support, 

Andy

PS. I spent some time on pandoc-lua page, but didn't make it...


W dniu środa, 25 marca 2020 21:21:51 UTC+1 użytkownik John MacFarlane 
napisał:
>
>
> function Str(el) 
>   local citekey = el.text:match("[[]@(%w+)[]]") 
>   local citation = pandoc.Citation(citekey, 'NormalCitation') 
>   return pandoc.Cite({pandoc.Str(citekey)}, 
>                      {citation}) 
> end 
>
> Andrzej Wodecki <andrzej...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: 
>
> > DearJohn, 
> > 
> > many thanks. I've tried, and with: 
> > 
> > pandoc in.docx --filter pandoc-citeproc --bibliography mylibrary.bib -t 
> > native 
> > 
> > I get 
> > 
> > [Para [Str "From",Space,Str "[@andy2020]",Space,Str ... 
> > 
> > as you suggested. I've looked at: https://pandoc.org/lua-filters.html 
> > and successfully run the first example "smallcaps.lua". But here I'm 
> stuck: 
> > I don't know how to write the filter for 
> > Str "[@ > Cite "[ 
> > replacement. 
> > 
> > If its not a problem, I would appreciate any tip/help, or just a 
> snippet, 
> > 
> > many thanks in advance, 
> > 
> > Andy 
> > 
> > 
> > W dniu środa, 25 marca 2020 17:36:06 UTC+1 użytkownik John MacFarlane 
> > napisał: 
> >> 
> >> 
> >> You could use a lua filter. 
> >> 
> >> If you do `pandoc your.docx -t native` you'll see how pandoc 
> >> parses these faux markdown citations. 
> >> 
> >> If they appear as 
> >> 
> >> Str "[@jones]" 
> >> 
> >> then you could use a filter to replace any Str elements 
> >> fitting this pattern with a Cite element.  I can't explain 
> >> the whole thing here -- if you want to pursue this, see 
> >> the lua filter docs on the website. 
> >> 
> >> Andrzej Wodecki <andrzej...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: 
> >> 
> >> > The reason I have citation keys in MS Word is a consequence of my 
> >> original 
> >> > workflow: 
> >> > Scrivener > markdown > pandoc-citeproc > MS Word, BTW described here: 
> >> > 
> >> 
> https://medium.com/@andrzej.wodecki/scrivener-for-scientific-writing-setup-af5edf4482b8 
> >> > 
> >> > But at the final stage of my writings I escaped from Scrivener 
> (export 
> >> to 
> >> > MS Word), with only citation keys left in my doc. 
> >> > If only I start from scratch in MS Word that wouldn't be a problem, 
> >> but... 
> >> > 
> >> > My temporary workaround (very primitive, but works) is: 
> >> > 1. docx > pandoc > markdown 
> >> > 2. markdown: replace all \@ by @ 
> >> > 3. markdown > pandoc-citeproc > docx 
> >> > 
> >> > Anyway, if you have any ideas for anything smarter would be nice to 
> hear 
> >> :) 
> >> > 
> >> > Yours, 
> >> > 
> >> > Andy 
> >> > 
> >> > 
> >> > W dniu środa, 25 marca 2020 14:11:06 UTC+1 użytkownik Joseph napisał: 
> >> >> 
> >> >> 
> >> >> On 3/25/20 8:01 AM, Andrzej Wodecki wrote: 
> >> >> > Second trial   
> >> >> > with in.docx: 
> >> >> 
> >> >> Pandoc doesn't expect to find markdown (including pandoc's citation 
> >> >> syntax) in a Word file. That only works in markdown files (and 
> perhaps 
> >> org 
> >> >> files). So when it sees a citation in word->markdown, it takes it 
> >> >> literally, and escapes the brackets so it remains so in the 
> markdown. 
> >> >> 
> >> >> Perhaps someone else can recommend a configuration that won't escape 
> >> >> citation syntax, allowing you to go to markdown, and then from that 
> >> back to 
> >> >> Word. 
> >> >> 
> >> >> This seems convoluted though. If you're using Zotero, why not use 
> the 
> >> Word 
> >> >> plugin for that? Or, why not stay in markdown as your source 
> document? 
> >> >> 
> >> >> 
> >> > 
> >> > -- 
> >> > 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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
> >> > To view this discussion on the web visit 
> >> 
> https://groups.google.com/d/msgid/pandoc-discuss/7e7dfd7e-1bf1-4557-a5f0-e686d48e2438%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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/db7c031a-9b53-42e5-b073-f70fa0c16de1%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/23e7c785-0f67-4b15-92b6-5c05cf2be2f7%40googlegroups.com.

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

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

* Re: generate bibliography from citations keys in docx?
       [not found]                         ` <23e7c785-0f67-4b15-92b6-5c05cf2be2f7-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-03-26 16:35                           ` John MacFarlane
       [not found]                             ` <m2imirm5uo.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: John MacFarlane @ 2020-03-26 16:35 UTC (permalink / raw)
  To: Andrzej Wodecki, pandoc-discuss


Whoops, that was a big oversight!  Try this one:

function Str(el)
  local citekey = el.text:match("[[]@(%w+)[]]")
  if citekey then
    local citation = pandoc.Citation(citekey, 'NormalCitation')
    return pandoc.Cite({pandoc.Str(citekey)},
                       {citation})
  end
end



Andrzej Wodecki <andrzej.wodecki-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Dear John, 
>
> many many thanks, You helped me a lot. I *almost* there - and as always *almost 
> *makes a difference...
>
> At the moment, having 
>
> *From [@andy2020] we can see that...*
>
> in in.docx, and Your snippet in cite.lua, when I run:
> pandoc in.docx --lua-filter=cite.lua --filter pandoc-citeproc 
> --bibliography mylibrary.bib -o out.docx
>
> I get out.docx as:
>
> *(Kaelbling, Littman, and Moore 1996) Kaelbling, Leslie Pack, Michael L. 
> Littman, and Andrew W. Moore. 1996. “Reinforcement Learning: A Survey.” 
> Journal of Artificial Intelligence Research 4: 237–85.*
>
> So, the only thing left is citation [@andy2020], but all other texts are 
> gone...
>
> Sorry for bothering You, but *what should I do to just replace [@andy2020] 
> with reference and create Bibliography at the end, but having all other 
> texts intact?*
>
> Many thanks for the support, 
>
> Andy
>
> PS. I spent some time on pandoc-lua page, but didn't make it...
>
>
> W dniu środa, 25 marca 2020 21:21:51 UTC+1 użytkownik John MacFarlane 
> napisał:
>>
>>
>> function Str(el) 
>>   local citekey = el.text:match("[[]@(%w+)[]]") 
>>   local citation = pandoc.Citation(citekey, 'NormalCitation') 
>>   return pandoc.Cite({pandoc.Str(citekey)}, 
>>                      {citation}) 
>> end 
>>
>> Andrzej Wodecki <andrzej...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: 
>>
>> > DearJohn, 
>> > 
>> > many thanks. I've tried, and with: 
>> > 
>> > pandoc in.docx --filter pandoc-citeproc --bibliography mylibrary.bib -t 
>> > native 
>> > 
>> > I get 
>> > 
>> > [Para [Str "From",Space,Str "[@andy2020]",Space,Str ... 
>> > 
>> > as you suggested. I've looked at: https://pandoc.org/lua-filters.html 
>> > and successfully run the first example "smallcaps.lua". But here I'm 
>> stuck: 
>> > I don't know how to write the filter for 
>> > Str "[@ > Cite "[ 
>> > replacement. 
>> > 
>> > If its not a problem, I would appreciate any tip/help, or just a 
>> snippet, 
>> > 
>> > many thanks in advance, 
>> > 
>> > Andy 
>> > 
>> > 
>> > W dniu środa, 25 marca 2020 17:36:06 UTC+1 użytkownik John MacFarlane 
>> > napisał: 
>> >> 
>> >> 
>> >> You could use a lua filter. 
>> >> 
>> >> If you do `pandoc your.docx -t native` you'll see how pandoc 
>> >> parses these faux markdown citations. 
>> >> 
>> >> If they appear as 
>> >> 
>> >> Str "[@jones]" 
>> >> 
>> >> then you could use a filter to replace any Str elements 
>> >> fitting this pattern with a Cite element.  I can't explain 
>> >> the whole thing here -- if you want to pursue this, see 
>> >> the lua filter docs on the website. 
>> >> 
>> >> Andrzej Wodecki <andrzej...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: 
>> >> 
>> >> > The reason I have citation keys in MS Word is a consequence of my 
>> >> original 
>> >> > workflow: 
>> >> > Scrivener > markdown > pandoc-citeproc > MS Word, BTW described here: 
>> >> > 
>> >> 
>> https://medium.com/@andrzej.wodecki/scrivener-for-scientific-writing-setup-af5edf4482b8 
>> >> > 
>> >> > But at the final stage of my writings I escaped from Scrivener 
>> (export 
>> >> to 
>> >> > MS Word), with only citation keys left in my doc. 
>> >> > If only I start from scratch in MS Word that wouldn't be a problem, 
>> >> but... 
>> >> > 
>> >> > My temporary workaround (very primitive, but works) is: 
>> >> > 1. docx > pandoc > markdown 
>> >> > 2. markdown: replace all \@ by @ 
>> >> > 3. markdown > pandoc-citeproc > docx 
>> >> > 
>> >> > Anyway, if you have any ideas for anything smarter would be nice to 
>> hear 
>> >> :) 
>> >> > 
>> >> > Yours, 
>> >> > 
>> >> > Andy 
>> >> > 
>> >> > 
>> >> > W dniu środa, 25 marca 2020 14:11:06 UTC+1 użytkownik Joseph napisał: 
>> >> >> 
>> >> >> 
>> >> >> On 3/25/20 8:01 AM, Andrzej Wodecki wrote: 
>> >> >> > Second trial   
>> >> >> > with in.docx: 
>> >> >> 
>> >> >> Pandoc doesn't expect to find markdown (including pandoc's citation 
>> >> >> syntax) in a Word file. That only works in markdown files (and 
>> perhaps 
>> >> org 
>> >> >> files). So when it sees a citation in word->markdown, it takes it 
>> >> >> literally, and escapes the brackets so it remains so in the 
>> markdown. 
>> >> >> 
>> >> >> Perhaps someone else can recommend a configuration that won't escape 
>> >> >> citation syntax, allowing you to go to markdown, and then from that 
>> >> back to 
>> >> >> Word. 
>> >> >> 
>> >> >> This seems convoluted though. If you're using Zotero, why not use 
>> the 
>> >> Word 
>> >> >> plugin for that? Or, why not stay in markdown as your source 
>> document? 
>> >> >> 
>> >> >> 
>> >> > 
>> >> > -- 
>> >> > 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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
>> >> > To view this discussion on the web visit 
>> >> 
>> https://groups.google.com/d/msgid/pandoc-discuss/7e7dfd7e-1bf1-4557-a5f0-e686d48e2438%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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/db7c031a-9b53-42e5-b073-f70fa0c16de1%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/23e7c785-0f67-4b15-92b6-5c05cf2be2f7%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/m2imirm5uo.fsf%40johnmacfarlane.net.


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

* Re: generate bibliography from citations keys in docx?
       [not found]                             ` <m2imirm5uo.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2020-03-27  5:34                               ` Andrzej Wodecki
       [not found]                                 ` <371930ea-0898-4ab1-a3dc-ad0af946fd30-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Andrzej Wodecki @ 2020-03-27  5:34 UTC (permalink / raw)
  To: pandoc-discuss


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

Many thanks, works perfectly :)

You saved me hours of work...

Have a nice day!

Andy

W dniu czwartek, 26 marca 2020 17:36:03 UTC+1 użytkownik John MacFarlane 
napisał:
>
>
> Whoops, that was a big oversight!  Try this one: 
>
> function Str(el) 
>   local citekey = el.text:match("[[]@(%w+)[]]") 
>   if citekey then 
>     local citation = pandoc.Citation(citekey, 'NormalCitation') 
>     return pandoc.Cite({pandoc.Str(citekey)}, 
>                        {citation}) 
>   end 
> end 
>
>
>
> Andrzej Wodecki <andrzej...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: 
>
> > Dear John, 
> > 
> > many many thanks, You helped me a lot. I *almost* there - and as always 
> *almost 
> > *makes a difference... 
> > 
> > At the moment, having 
> > 
> > *From [@andy2020] we can see that...* 
> > 
> > in in.docx, and Your snippet in cite.lua, when I run: 
> > pandoc in.docx --lua-filter=cite.lua --filter pandoc-citeproc 
> > --bibliography mylibrary.bib -o out.docx 
> > 
> > I get out.docx as: 
> > 
> > *(Kaelbling, Littman, and Moore 1996) Kaelbling, Leslie Pack, Michael L. 
> > Littman, and Andrew W. Moore. 1996. “Reinforcement Learning: A Survey.” 
> > Journal of Artificial Intelligence Research 4: 237–85.* 
> > 
> > So, the only thing left is citation [@andy2020], but all other texts are 
> > gone... 
> > 
> > Sorry for bothering You, but *what should I do to just replace 
> [@andy2020] 
> > with reference and create Bibliography at the end, but having all other 
> > texts intact?* 
> > 
> > Many thanks for the support, 
> > 
> > Andy 
> > 
> > PS. I spent some time on pandoc-lua page, but didn't make it... 
> > 
> > 
> > W dniu środa, 25 marca 2020 21:21:51 UTC+1 użytkownik John MacFarlane 
> > napisał: 
> >> 
> >> 
> >> function Str(el) 
> >>   local citekey = el.text:match("[[]@(%w+)[]]") 
> >>   local citation = pandoc.Citation(citekey, 'NormalCitation') 
> >>   return pandoc.Cite({pandoc.Str(citekey)}, 
> >>                      {citation}) 
> >> end 
> >> 
> >> Andrzej Wodecki <andrzej...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: 
> >> 
> >> > DearJohn, 
> >> > 
> >> > many thanks. I've tried, and with: 
> >> > 
> >> > pandoc in.docx --filter pandoc-citeproc --bibliography mylibrary.bib 
> -t 
> >> > native 
> >> > 
> >> > I get 
> >> > 
> >> > [Para [Str "From",Space,Str "[@andy2020]",Space,Str ... 
> >> > 
> >> > as you suggested. I've looked at: https://pandoc.org/lua-filters.html 
> >> > and successfully run the first example "smallcaps.lua". But here I'm 
> >> stuck: 
> >> > I don't know how to write the filter for 
> >> > Str "[@ > Cite "[ 
> >> > replacement. 
> >> > 
> >> > If its not a problem, I would appreciate any tip/help, or just a 
> >> snippet, 
> >> > 
> >> > many thanks in advance, 
> >> > 
> >> > Andy 
> >> > 
> >> > 
> >> > W dniu środa, 25 marca 2020 17:36:06 UTC+1 użytkownik John MacFarlane 
> >> > napisał: 
> >> >> 
> >> >> 
> >> >> You could use a lua filter. 
> >> >> 
> >> >> If you do `pandoc your.docx -t native` you'll see how pandoc 
> >> >> parses these faux markdown citations. 
> >> >> 
> >> >> If they appear as 
> >> >> 
> >> >> Str "[@jones]" 
> >> >> 
> >> >> then you could use a filter to replace any Str elements 
> >> >> fitting this pattern with a Cite element.  I can't explain 
> >> >> the whole thing here -- if you want to pursue this, see 
> >> >> the lua filter docs on the website. 
> >> >> 
> >> >> Andrzej Wodecki <andrzej...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: 
> >> >> 
> >> >> > The reason I have citation keys in MS Word is a consequence of my 
> >> >> original 
> >> >> > workflow: 
> >> >> > Scrivener > markdown > pandoc-citeproc > MS Word, BTW described 
> here: 
> >> >> > 
> >> >> 
> >> 
> https://medium.com/@andrzej.wodecki/scrivener-for-scientific-writing-setup-af5edf4482b8 
> >> >> > 
> >> >> > But at the final stage of my writings I escaped from Scrivener 
> >> (export 
> >> >> to 
> >> >> > MS Word), with only citation keys left in my doc. 
> >> >> > If only I start from scratch in MS Word that wouldn't be a 
> problem, 
> >> >> but... 
> >> >> > 
> >> >> > My temporary workaround (very primitive, but works) is: 
> >> >> > 1. docx > pandoc > markdown 
> >> >> > 2. markdown: replace all \@ by @ 
> >> >> > 3. markdown > pandoc-citeproc > docx 
> >> >> > 
> >> >> > Anyway, if you have any ideas for anything smarter would be nice 
> to 
> >> hear 
> >> >> :) 
> >> >> > 
> >> >> > Yours, 
> >> >> > 
> >> >> > Andy 
> >> >> > 
> >> >> > 
> >> >> > W dniu środa, 25 marca 2020 14:11:06 UTC+1 użytkownik Joseph 
> napisał: 
> >> >> >> 
> >> >> >> 
> >> >> >> On 3/25/20 8:01 AM, Andrzej Wodecki wrote: 
> >> >> >> > Second trial   
> >> >> >> > with in.docx: 
> >> >> >> 
> >> >> >> Pandoc doesn't expect to find markdown (including pandoc's 
> citation 
> >> >> >> syntax) in a Word file. That only works in markdown files (and 
> >> perhaps 
> >> >> org 
> >> >> >> files). So when it sees a citation in word->markdown, it takes it 
> >> >> >> literally, and escapes the brackets so it remains so in the 
> >> markdown. 
> >> >> >> 
> >> >> >> Perhaps someone else can recommend a configuration that won't 
> escape 
> >> >> >> citation syntax, allowing you to go to markdown, and then from 
> that 
> >> >> back to 
> >> >> >> Word. 
> >> >> >> 
> >> >> >> This seems convoluted though. If you're using Zotero, why not use 
> >> the 
> >> >> Word 
> >> >> >> plugin for that? Or, why not stay in markdown as your source 
> >> document? 
> >> >> >> 
> >> >> >> 
> >> >> > 
> >> >> > -- 
> >> >> > 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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
> >> >> > To view this discussion on the web visit 
> >> >> 
> >> 
> https://groups.google.com/d/msgid/pandoc-discuss/7e7dfd7e-1bf1-4557-a5f0-e686d48e2438%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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
> >> > To view this discussion on the web visit 
> >> 
> https://groups.google.com/d/msgid/pandoc-discuss/db7c031a-9b53-42e5-b073-f70fa0c16de1%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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/23e7c785-0f67-4b15-92b6-5c05cf2be2f7%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/371930ea-0898-4ab1-a3dc-ad0af946fd30%40googlegroups.com.

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

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

* Re: generate bibliography from citations keys in docx?
       [not found]                                 ` <371930ea-0898-4ab1-a3dc-ad0af946fd30-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-05-24  3:02                                   ` Ioan Muntean
  0 siblings, 0 replies; 10+ messages in thread
From: Ioan Muntean @ 2021-05-24  3:02 UTC (permalink / raw)
  To: pandoc-discuss


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

John and Andrzej
Thanks for your solution. I managed  to replicate it and it works! John, I 
have exactly the same idea as Andrzej, but in my word document generated by 
Better Bibtex citekeys I have multiple citation in one reference:
[@abi2021measurementpositivemuon; 
@lhcbcollaboration2021testleptonuniversality]
 I would like to do the same as above, but generate a \cite field in Latex 
like:
\cite {abi2021measurementpositivemuon, 
lhcbcollaboration2021testleptonuniversality}. Of course, when there is a 
page reference the lua filter needs to do some extra work. I may need to do 
a loop inside the field and search /skip the ";" sign
Thanks guys for your amazing ideas!
Ioan Muntean

On Friday, March 27, 2020 at 1:34:11 AM UTC-4 Andrzej Wodecki wrote:

> Many thanks, works perfectly :)
>
> You saved me hours of work...
>
> Have a nice day!
>
> Andy
>
>
> W dniu czwartek, 26 marca 2020 17:36:03 UTC+1 użytkownik John MacFarlane 
> napisał:
>
>>
>> Whoops, that was a big oversight!  Try this one: 
>>
>> function Str(el) 
>>   local citekey = el.text:match("[[]@(%w+)[]]") 
>>   if citekey then 
>>     local citation = pandoc.Citation(citekey, 'NormalCitation') 
>>     return pandoc.Cite({pandoc.Str(citekey)}, 
>>                        {citation}) 
>>   end 
>> end 
>>
>>
>>
>> Andrzej Wodecki <andrzej...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: 
>>
>> > Dear John, 
>> > 
>> > many many thanks, You helped me a lot. I *almost* there - and as always 
>> *almost 
>> > *makes a difference... 
>> > 
>> > At the moment, having 
>> > 
>> > *From [@andy2020] we can see that...* 
>> > 
>> > in in.docx, and Your snippet in cite.lua, when I run: 
>> > pandoc in.docx --lua-filter=cite.lua --filter pandoc-citeproc 
>> > --bibliography mylibrary.bib -o out.docx 
>> > 
>> > I get out.docx as: 
>> > 
>> > *(Kaelbling, Littman, and Moore 1996) Kaelbling, Leslie Pack, Michael 
>> L. 
>> > Littman, and Andrew W. Moore. 1996. “Reinforcement Learning: A Survey.” 
>> > Journal of Artificial Intelligence Research 4: 237–85.* 
>> > 
>> > So, the only thing left is citation [@andy2020], but all other texts 
>> are 
>> > gone... 
>> > 
>> > Sorry for bothering You, but *what should I do to just replace 
>> [@andy2020] 
>> > with reference and create Bibliography at the end, but having all other 
>> > texts intact?* 
>> > 
>> > Many thanks for the support, 
>> > 
>> > Andy 
>> > 
>> > PS. I spent some time on pandoc-lua page, but didn't make it... 
>> > 
>> > 
>> > W dniu środa, 25 marca 2020 21:21:51 UTC+1 użytkownik John MacFarlane 
>> > napisał: 
>> >> 
>> >> 
>> >> function Str(el) 
>> >>   local citekey = el.text:match("[[]@(%w+)[]]") 
>> >>   local citation = pandoc.Citation(citekey, 'NormalCitation') 
>> >>   return pandoc.Cite({pandoc.Str(citekey)}, 
>> >>                      {citation}) 
>> >> end 
>> >> 
>> >> Andrzej Wodecki <andrzej...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: 
>> >> 
>> >> > DearJohn, 
>> >> > 
>> >> > many thanks. I've tried, and with: 
>> >> > 
>> >> > pandoc in.docx --filter pandoc-citeproc --bibliography mylibrary.bib 
>> -t 
>> >> > native 
>> >> > 
>> >> > I get 
>> >> > 
>> >> > [Para [Str "From",Space,Str "[@andy2020]",Space,Str ... 
>> >> > 
>> >> > as you suggested. I've looked at: 
>> https://pandoc.org/lua-filters.html 
>> >> > and successfully run the first example "smallcaps.lua". But here I'm 
>> >> stuck: 
>> >> > I don't know how to write the filter for 
>> >> > Str "[@ > Cite "[ 
>> >> > replacement. 
>> >> > 
>> >> > If its not a problem, I would appreciate any tip/help, or just a 
>> >> snippet, 
>> >> > 
>> >> > many thanks in advance, 
>> >> > 
>> >> > Andy 
>> >> > 
>> >> > 
>> >> > W dniu środa, 25 marca 2020 17:36:06 UTC+1 użytkownik John 
>> MacFarlane 
>> >> > napisał: 
>> >> >> 
>> >> >> 
>> >> >> You could use a lua filter. 
>> >> >> 
>> >> >> If you do `pandoc your.docx -t native` you'll see how pandoc 
>> >> >> parses these faux markdown citations. 
>> >> >> 
>> >> >> If they appear as 
>> >> >> 
>> >> >> Str "[@jones]" 
>> >> >> 
>> >> >> then you could use a filter to replace any Str elements 
>> >> >> fitting this pattern with a Cite element.  I can't explain 
>> >> >> the whole thing here -- if you want to pursue this, see 
>> >> >> the lua filter docs on the website. 
>> >> >> 
>> >> >> Andrzej Wodecki <andrzej...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: 
>> >> >> 
>> >> >> > The reason I have citation keys in MS Word is a consequence of my 
>> >> >> original 
>> >> >> > workflow: 
>> >> >> > Scrivener > markdown > pandoc-citeproc > MS Word, BTW described 
>> here: 
>> >> >> > 
>> >> >> 
>> >> 
>> https://medium.com/@andrzej.wodecki/scrivener-for-scientific-writing-setup-af5edf4482b8 
>> >> >> > 
>> >> >> > But at the final stage of my writings I escaped from Scrivener 
>> >> (export 
>> >> >> to 
>> >> >> > MS Word), with only citation keys left in my doc. 
>> >> >> > If only I start from scratch in MS Word that wouldn't be a 
>> problem, 
>> >> >> but... 
>> >> >> > 
>> >> >> > My temporary workaround (very primitive, but works) is: 
>> >> >> > 1. docx > pandoc > markdown 
>> >> >> > 2. markdown: replace all \@ by @ 
>> >> >> > 3. markdown > pandoc-citeproc > docx 
>> >> >> > 
>> >> >> > Anyway, if you have any ideas for anything smarter would be nice 
>> to 
>> >> hear 
>> >> >> :) 
>> >> >> > 
>> >> >> > Yours, 
>> >> >> > 
>> >> >> > Andy 
>> >> >> > 
>> >> >> > 
>> >> >> > W dniu środa, 25 marca 2020 14:11:06 UTC+1 użytkownik Joseph 
>> napisał: 
>> >> >> >> 
>> >> >> >> 
>> >> >> >> On 3/25/20 8:01 AM, Andrzej Wodecki wrote: 
>> >> >> >> > Second trial   
>> >> >> >> > with in.docx: 
>> >> >> >> 
>> >> >> >> Pandoc doesn't expect to find markdown (including pandoc's 
>> citation 
>> >> >> >> syntax) in a Word file. That only works in markdown files (and 
>> >> perhaps 
>> >> >> org 
>> >> >> >> files). So when it sees a citation in word->markdown, it takes 
>> it 
>> >> >> >> literally, and escapes the brackets so it remains so in the 
>> >> markdown. 
>> >> >> >> 
>> >> >> >> Perhaps someone else can recommend a configuration that won't 
>> escape 
>> >> >> >> citation syntax, allowing you to go to markdown, and then from 
>> that 
>> >> >> back to 
>> >> >> >> Word. 
>> >> >> >> 
>> >> >> >> This seems convoluted though. If you're using Zotero, why not 
>> use 
>> >> the 
>> >> >> Word 
>> >> >> >> plugin for that? Or, why not stay in markdown as your source 
>> >> document? 
>> >> >> >> 
>> >> >> >> 
>> >> >> > 
>> >> >> > -- 
>> >> >> > 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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
>> >> >> > To view this discussion on the web visit 
>> >> >> 
>> >> 
>> https://groups.google.com/d/msgid/pandoc-discuss/7e7dfd7e-1bf1-4557-a5f0-e686d48e2438%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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
>> >> > To view this discussion on the web visit 
>> >> 
>> https://groups.google.com/d/msgid/pandoc-discuss/db7c031a-9b53-42e5-b073-f70fa0c16de1%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-...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>>
> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/23e7c785-0f67-4b15-92b6-5c05cf2be2f7%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/bc948bae-0b65-4b2e-8cac-bea115c19134n%40googlegroups.com.

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

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

end of thread, other threads:[~2021-05-24  3:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25 12:01 generate bibliography from citations keys in docx? Andrzej Wodecki
     [not found] ` <4d035407-d692-4ada-ac1a-b2668c8c80bc-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-03-25 13:10   ` Joseph Reagle
     [not found]     ` <30f53079-9e7a-2046-f458-b23f9736ac48-T1oY19WcHSwdnm+yROfE0A@public.gmane.org>
2020-03-25 16:14       ` Andrzej Wodecki
     [not found]         ` <7e7dfd7e-1bf1-4557-a5f0-e686d48e2438-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-03-25 16:35           ` John MacFarlane
     [not found]             ` <m28sjotmsv.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2020-03-25 17:09               ` Andrzej Wodecki
     [not found]                 ` <db7c031a-9b53-42e5-b073-f70fa0c16de1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-03-25 20:21                   ` John MacFarlane
     [not found]                     ` <m2wo78rxrl.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2020-03-26  6:13                       ` Andrzej Wodecki
     [not found]                         ` <23e7c785-0f67-4b15-92b6-5c05cf2be2f7-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-03-26 16:35                           ` John MacFarlane
     [not found]                             ` <m2imirm5uo.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2020-03-27  5:34                               ` Andrzej Wodecki
     [not found]                                 ` <371930ea-0898-4ab1-a3dc-ad0af946fd30-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-05-24  3:02                                   ` Ioan Muntean

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