From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/24733 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Andrzej Wodecki Newsgroups: gmane.text.pandoc Subject: Re: generate bibliography from citations keys in docx? Date: Wed, 25 Mar 2020 23:13:20 -0700 (PDT) Message-ID: <23e7c785-0f67-4b15-92b6-5c05cf2be2f7@googlegroups.com> References: <4d035407-d692-4ada-ac1a-b2668c8c80bc@googlegroups.com> <30f53079-9e7a-2046-f458-b23f9736ac48@reagle.org> <7e7dfd7e-1bf1-4557-a5f0-e686d48e2438@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_3053_382289255.1585203200366" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="38050"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCAJTAHOV4CRBAMQ6HZQKGQEB4BZNBI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Mar 26 07:13:26 2020 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ot1-f61.google.com ([209.85.210.61]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jHLld-0009ml-5n for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 26 Mar 2020 07:13:25 +0100 Original-Received: by mail-ot1-f61.google.com with SMTP id r23sf3715058otp.4 for ; Wed, 25 Mar 2020 23:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=B05sfoYVVUgLUcHlp8jTMHUBJ65HOHYxz174ALk3haQ=; b=TLGrDqzRaA1zSDRAiq7bnmedhDrWIfgjA4c3f9y3rGf1LaioCV8Uqjq9ZiFOYmbj+L zjy4wYeehV8wfSyA9r5157bCKZo95jyIFN44CYSRB6a0GEva/EYLQhVnoyo3OCgYHDdj vGic7/qvj0i6w7ZZ0FYs0BbDoiknur6ksxe/+b4YQ/TVGILi6vbr6lvdwfQNDFpJbrXt BTiMWiaDGQWp6tmH9s8v7UtO6te//J6V3dPi7+cnUA+A2pc+N+x4qvqCuBC7t/Cncfpx K7a3+il19lV4u1zwJEcQMuq4P/j6/swWYQNqh7MGB6lb4G698BOR7Pn/7SqF3pP31bGf wElQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=B05sfoYVVUgLUcHlp8jTMHUBJ65HOHYxz174ALk3haQ=; b=ERCUXadu5f7si+i3UCztijZFHYBAL6R7o6B18LmYcjFvdiQNwv3OjRkMHUR3tC7Rvt meqIgamcivvm1PxGc0/luHOe+TSTcTAiOrPEl7gpyOd87Q1paJ6+ZVluvdtivEOAa0Tk OLt+aLB9P3DjKVxlXJcItFlmsuSUjFA/jPcwyyD9i8trvwbCWsdDfe+RvcowAH064eLq E82fRPioXveaA4uh6Ut+JTwLgrpn3czlDvwxEal6fGBRsqlNqCpqsgdjNuxzYymc+P8k gub17bYWnkYrwvugQ1CKcWFeOG9eyC3id6jh03h7q/y6D+eQ8kwgxBLJ9ExM73ib+mRs n0EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=B05sfoYVVUgLUcHlp8jTMHUBJ65HOHYxz174ALk3haQ=; b=GD0vAcgauUPJKuUuCI7yemdDP1ySqzkRwLsK4uC2BClIrcGtep/xW3KoHKSUM2+NX0 iKOri2lqM6HSJ+vh74ejJnKUvsUyZZcl4CwqzgoEGSovB2b43Lm5OMy2ivu6sNIm5cod Twd4Muq6jSRj28eNUX8q2JBPoXyAZrOjy17ZiCw0DloweTq6TSwime2XlLuZQYRs3jXf or9m70gQbSNqNDS3HMM3as93MSU+bOd8Q3qpBVN1Ez1z8uvnACVUpxQRdwMXImGn+7aC wiDXQjL2MfvdZTxjcS260Nj2ZoqThOh+9smO72BiUuHCvWc5Dl8nW+52V/NK8wVVqYnq 1Seg== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ANhLgQ2kob+HLBY8N8wmfhbD5ZgmHw7OEVzVjrbbvEDgKV0ld3vPPXJr 9NYCVBpV1MdfFoWOiwMcri8= X-Google-Smtp-Source: ADFU+vvkWN6lzMXIuXUFksWVLgxIbYtfOa596aCbV6PrQ1O3QGKrXDOXm3q20rv7s2HjZhuQ5H01IA== X-Received: by 2002:a9d:6a05:: with SMTP id g5mr5182363otn.116.1585203204187; Wed, 25 Mar 2020 23:13:24 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a9d:3b23:: with SMTP id z32ls1720798otb.1.gmail; Wed, 25 Mar 2020 23:13:21 -0700 (PDT) X-Received: by 2002:a9d:5a9:: with SMTP id 38mr4768483otd.331.1585203200971; Wed, 25 Mar 2020 23:13:20 -0700 (PDT) In-Reply-To: X-Original-Sender: andrzej.wodecki-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:24733 Archived-At: ------=_Part_3053_382289255.1585203200366 Content-Type: multipart/alternative; boundary="----=_Part_3054_1707654397.1585203200367" ------=_Part_3054_1707654397.1585203200367 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Dear John,=20 many many thanks, You helped me a lot. I *almost* there - and as always *al= most=20 *makes a difference... At the moment, having=20 *From [@andy2020] we can see that...* in in.docx, and Your snippet in cite.lua, when I run: pandoc in.docx --lua-filter=3Dcite.lua --filter pandoc-citeproc=20 --bibliography mylibrary.bib -o out.docx I get out.docx as: *(Kaelbling, Littman, and Moore 1996) Kaelbling, Leslie Pack, Michael L.=20 Littman, and Andrew W. Moore. 1996. =E2=80=9CReinforcement Learning: A Surv= ey.=E2=80=9D=20 Journal of Artificial Intelligence Research 4: 237=E2=80=9385.* So, the only thing left is citation [@andy2020], but all other texts are=20 gone... Sorry for bothering You, but *what should I do to just replace [@andy2020]= =20 with reference and create Bibliography at the end, but having all other=20 texts intact?* Many thanks for the support,=20 Andy PS. I spent some time on pandoc-lua page, but didn't make it... W dniu =C5=9Broda, 25 marca 2020 21:21:51 UTC+1 u=C5=BCytkownik John MacFar= lane=20 napisa=C5=82: > > > function Str(el)=20 > local citekey =3D el.text:match("[[]@(%w+)[]]")=20 > local citation =3D pandoc.Citation(citekey, 'NormalCitation')=20 > return pandoc.Cite({pandoc.Str(citekey)},=20 > {citation})=20 > end=20 > > Andrzej Wodecki > writes:=20 > > > DearJohn,=20 > >=20 > > many thanks. I've tried, and with:=20 > >=20 > > pandoc in.docx --filter pandoc-citeproc --bibliography mylibrary.bib -t= =20 > > native=20 > >=20 > > I get=20 > >=20 > > [Para [Str "From",Space,Str "[@andy2020]",Space,Str ...=20 > >=20 > > as you suggested. I've looked at: https://pandoc.org/lua-filters.html= =20 > > and successfully run the first example "smallcaps.lua". But here I'm=20 > stuck:=20 > > I don't know how to write the filter for=20 > > Str "[@ > Cite "[=20 > > replacement.=20 > >=20 > > If its not a problem, I would appreciate any tip/help, or just a=20 > snippet,=20 > >=20 > > many thanks in advance,=20 > >=20 > > Andy=20 > >=20 > >=20 > > W dniu =C5=9Broda, 25 marca 2020 17:36:06 UTC+1 u=C5=BCytkownik John Ma= cFarlane=20 > > napisa=C5=82:=20 > >>=20 > >>=20 > >> You could use a lua filter.=20 > >>=20 > >> If you do `pandoc your.docx -t native` you'll see how pandoc=20 > >> parses these faux markdown citations.=20 > >>=20 > >> If they appear as=20 > >>=20 > >> Str "[@jones]"=20 > >>=20 > >> then you could use a filter to replace any Str elements=20 > >> fitting this pattern with a Cite element. I can't explain=20 > >> the whole thing here -- if you want to pursue this, see=20 > >> the lua filter docs on the website.=20 > >>=20 > >> Andrzej Wodecki > writes:=20 > >>=20 > >> > The reason I have citation keys in MS Word is a consequence of my=20 > >> original=20 > >> > workflow:=20 > >> > Scrivener > markdown > pandoc-citeproc > MS Word, BTW described here= :=20 > >> >=20 > >>=20 > https://medium.com/@andrzej.wodecki/scrivener-for-scientific-writing-setu= p-af5edf4482b8=20 > >> >=20 > >> > But at the final stage of my writings I escaped from Scrivener=20 > (export=20 > >> to=20 > >> > MS Word), with only citation keys left in my doc.=20 > >> > If only I start from scratch in MS Word that wouldn't be a problem,= =20 > >> but...=20 > >> >=20 > >> > My temporary workaround (very primitive, but works) is:=20 > >> > 1. docx > pandoc > markdown=20 > >> > 2. markdown: replace all \@ by @=20 > >> > 3. markdown > pandoc-citeproc > docx=20 > >> >=20 > >> > Anyway, if you have any ideas for anything smarter would be nice to= =20 > hear=20 > >> :)=20 > >> >=20 > >> > Yours,=20 > >> >=20 > >> > Andy=20 > >> >=20 > >> >=20 > >> > W dniu =C5=9Broda, 25 marca 2020 14:11:06 UTC+1 u=C5=BCytkownik Jose= ph napisa=C5=82:=20 > >> >>=20 > >> >>=20 > >> >> On 3/25/20 8:01 AM, Andrzej Wodecki wrote:=20 > >> >> > Second trial =20 > >> >> > with in.docx:=20 > >> >>=20 > >> >> Pandoc doesn't expect to find markdown (including pandoc's citation= =20 > >> >> syntax) in a Word file. That only works in markdown files (and=20 > perhaps=20 > >> org=20 > >> >> files). So when it sees a citation in word->markdown, it takes it= =20 > >> >> literally, and escapes the brackets so it remains so in the=20 > markdown.=20 > >> >>=20 > >> >> Perhaps someone else can recommend a configuration that won't escap= e=20 > >> >> citation syntax, allowing you to go to markdown, and then from that= =20 > >> back to=20 > >> >> Word.=20 > >> >>=20 > >> >> This seems convoluted though. If you're using Zotero, why not use= =20 > the=20 > >> Word=20 > >> >> plugin for that? Or, why not stay in markdown as your source=20 > document?=20 > >> >>=20 > >> >>=20 > >> >=20 > >> > --=20 > >> > You received this message because you are subscribed to the Google= =20 > >> Groups "pandoc-discuss" group.=20 > >> > To unsubscribe from this group and stop receiving emails from it,=20 > send=20 > >> an email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org .=20 > >> > To view this discussion on the web visit=20 > >>=20 > https://groups.google.com/d/msgid/pandoc-discuss/7e7dfd7e-1bf1-4557-a5f0-= e686d48e2438%40googlegroups.com.=20 > > >>=20 > >>=20 > >=20 > > --=20 > > You received this message because you are subscribed to the Google=20 > Groups "pandoc-discuss" group.=20 > > To unsubscribe from this group and stop receiving emails from it, send= =20 > an email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org .=20 > > To view this discussion on the web visit=20 > https://groups.google.com/d/msgid/pandoc-discuss/db7c031a-9b53-42e5-b073-= f70fa0c16de1%40googlegroups.com.=20 > > --=20 You received this message because you are subscribed to the Google Groups "= pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/23e7c785-0f67-4b15-92b6-5c05cf2be2f7%40googlegroups.com. ------=_Part_3054_1707654397.1585203200367 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Dear John,=C2=A0

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

At the moment, having=C2=A0
<= div>
From [@andy2020] we can see that...
=
in in.docx, and Your snippet in cite.lua, when I run:pandoc in.docx --lua-filter=3Dcite.lua --filter pandoc-citeproc --bibliog= raphy mylibrary.bib -o out.docx

I get out.docx as:<= /div>(Kaelbling, Littman, and Moore 1996)
Kaelbling, Leslie Pack, Mi= chael L. Littman, and Andrew W. Moore. 1996. =E2=80=9CReinforcement Learnin= g: A Survey.=E2=80=9D Journal of Artificial Intelligence Research 4: 237=E2= =80=9385.

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

Sorry for b= othering You, but what should I do to just replace [@andy2020] with refe= rence and create Bibliography at the end, but having all other texts intact= ?

Many thanks for the support,=C2=A0

Andy

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


=
W dniu =C5=9Broda, 25 marca 2020 21:21:51 UTC+1 u=C5=BCytkownik = John MacFarlane napisa=C5=82:

function Str(el)
=C2=A0 local citekey =3D el.text:match("[[]@(%w+)[]]")
=C2=A0 local citation =3D pandoc.Citation(citekey, 'NormalCitation&= #39;)
=C2=A0 return pandoc.Cite({pandoc.Str(citekey)},
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0{citation})
end

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

> DearJohn,=20
>
> many thanks. I've tried, and with:
>
> pandoc in.docx --filter pandoc-citeproc --bibliography mylibrary.b= ib -t=20
> native
>
> I get
>
> [Para [Str "From",Space,Str "[@andy2020]",Spac= e,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:=20
> I don't know how to write the filter for=20
> Str "[@ > Cite "[
> replacement.
>
> If its not a problem, I would appreciate any tip/help, or just a s= nippet,
>
> many thanks in advance,=20
>
> Andy
>
>
> W dniu =C5=9Broda, 25 marca 2020 17:36:06 UTC+1 u=C5=BCytkownik Jo= hn MacFarlane=20
> napisa=C5=82:
>>
>>
>> You could use a lua filter.=20
>>
>> If you do `pandoc your.docx -t native` you'll see how pand= oc=20
>> parses these faux markdown citations.=20
>>
>> If they appear as=20
>>
>> Str "[@jones]"=20
>>
>> then you could use a filter to replace any Str elements=20
>> fitting this pattern with a Cite element. =C2=A0I can't ex= plain=20
>> the whole thing here -- if you want to pursue this, see=20
>> the lua filter docs on the website.=20
>>
>> Andrzej Wodecki <andrzej...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript= :>> writes:=20
>>
>> > The reason I have citation keys in MS Word is a consequen= ce of my=20
>> original=20
>> > workflow:=20
>> > Scrivener > markdown > pandoc-citeproc > MS Word= , BTW described here:=20
>> >=20
>> https://medium.com/@andrzej= .wodecki/scrivener-for-scientific-writing-setup-af5edf4482b8= =20
>> >=20
>> > But at the final stage of my writings I escaped from Scri= vener (export=20
>> to=20
>> > MS Word), with only citation keys left in my doc.=20
>> > If only I start from scratch in MS Word that wouldn't= be a problem,=20
>> but...=20
>> >=20
>> > My temporary workaround (very primitive, but works) is:= =20
>> > 1. docx > pandoc > markdown=20
>> > 2. markdown: replace all \@ by @=20
>> > 3. markdown > pandoc-citeproc > docx=20
>> >=20
>> > Anyway, if you have any ideas for anything smarter would = be nice to hear=20
>> :)=20
>> >=20
>> > Yours,=20
>> >=20
>> > Andy=20
>> >=20
>> >=20
>> > W dniu =C5=9Broda, 25 marca 2020 14:11:06 UTC+1 u=C5=BCyt= kownik Joseph napisa=C5=82:=20
>> >>=20
>> >>=20
>> >> On 3/25/20 8:01 AM, Andrzej Wodecki wrote:=20
>> >> > Second trial =C2=A0=20
>> >> > with in.docx:=20
>> >>=20
>> >> Pandoc doesn't expect to find markdown (including= pandoc's citation=20
>> >> syntax) in a Word file. That only works in markdown f= iles (and perhaps=20
>> org=20
>> >> files). So when it sees a citation in word->markdo= wn, it takes it=20
>> >> literally, and escapes the brackets so it remains so = in the markdown.=20
>> >>=20
>> >> Perhaps someone else can recommend a configuration th= at won't escape=20
>> >> citation syntax, allowing you to go to markdown, and = then from that=20
>> back to=20
>> >> Word.=20
>> >>=20
>> >> This seems convoluted though. If you're using Zot= ero, why not use the=20
>> Word=20
>> >> plugin for that? Or, why not stay in markdown as your= source document?=20
>> >>=20
>> >>=20
>> >=20
>> > --=20
>> > You received this message because you are subscribed to t= he Google=20
>> Groups "pandoc-discuss" group.=20
>> > To unsubscribe from this group and stop receiving emails = from it, send=20
>> an email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:= >.=20
>> > To view this discussion on the web visit=20
>> https://groups.google.com/d/msgid/pandoc-discus= s/7e7dfd7e-1bf1-4557-a5f0-e686d48e2438%40googlegroups.com.=20
>>
>>
>
> --=20
> You received this message because you are subscribed to the Google= Groups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, = send an email to pandoc-...@googlegroups.com.
> To view this discussion on the web visit https://groups.= google.com/d/msgid/pandoc-discuss/db7c031a-9b53-42e5-b073-f70fa0c= 16de1%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/= msgid/pandoc-discuss/23e7c785-0f67-4b15-92b6-5c05cf2be2f7%40googlegroups.co= m.
------=_Part_3054_1707654397.1585203200367-- ------=_Part_3053_382289255.1585203200366--