From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/24734 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: John MacFarlane Newsgroups: gmane.text.pandoc Subject: Re: generate bibliography from citations keys in docx? Date: Thu, 26 Mar 2020 09:35:43 -0700 Message-ID: References: <4d035407-d692-4ada-ac1a-b2668c8c80bc@googlegroups.com> <30f53079-9e7a-2046-f458-b23f9736ac48@reagle.org> <7e7dfd7e-1bf1-4557-a5f0-e686d48e2438@googlegroups.com> <23e7c785-0f67-4b15-92b6-5c05cf2be2f7@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="19113"; mail-complaints-to="usenet@ciao.gmane.io" To: Andrzej Wodecki , pandoc-discuss Original-X-From: pandoc-discuss+bncBCJZJHG45QDBB3NT6PZQKGQEKMXEPFQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Mar 26 17:36:02 2020 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-qv1-f63.google.com ([209.85.219.63]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jHVUA-0004pD-2E for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 26 Mar 2020 17:36:02 +0100 Original-Received: by mail-qv1-f63.google.com with SMTP id o102sf5195048qvo.14 for ; Thu, 26 Mar 2020 09:36:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1585240561; cv=pass; d=google.com; s=arc-20160816; b=W99uKSU5uR5ymbKAmXhxq1f3qqF7VTGGsfpRRmBRQMM4VmiRTYMcAXYeV21h5BA98D QpIEQEuuX/IvLpJ5kBc8yiyzfnVXQvGqSx5MFguLXjPWNw+BmV2nXUQu3lyBUyeC9pdv hGETjbv5DoBYlU5bzVgpzlvYW7Tb7tet/kGn8x4FSHOtqQhADMafSpNYctfpiQddu3QU PTJj/eVEphTEz/GWAa5FDv+fDNLJvsUz14DH18x3BbnJwxtVim2xfYgBFoLMIV3166Po zUjVX8laIMh3f+zeWM5zfWVxkEoudBTLIxBTv4/yrsuo/vMx+F6mbrY2Wgl4hhMu9bCw 2LYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:content-transfer-encoding :mime-version:message-id:date:references:in-reply-to:subject:to:from :sender:dkim-signature; bh=eqkjmIx0EyBJZFsAKILR13zsqC47hxt3yLVNb0ZLQR0=; b=FAYHVbxtQZ9V0jAZX3vgv5MGGgC5ZZBcStGzDRZbXRIUTjCLOg59o8WbByRqbJlAlI MvP4AxtdDibrhP7SxlQZ5qXXaYo6HlxlERX5p4Pne5v74RHNKlvUwdGoYeoY+c1wzgHC nH2cQ5AuRL95TdQkTy3eQUBt4Ymbixt+nXypHhAa+UX/f9lyXfeNZWdyPzlxkhRK9QbS OYqSHzf8kQTWpL6ZDh6ayfZl0S8lETMIw94RJeKfqVXU2tlh+wIPd2sQvBVFdBRUhS2v 2RJmHr6wiKxxnKULH4CXg/gX7vNmjGRoG1MaSofDx3jy4FeTfB7asZOA+L+K5SKHDrLa VSSQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=TyPsGL4b; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::529 as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=eqkjmIx0EyBJZFsAKILR13zsqC47hxt3yLVNb0ZLQR0=; b=kzSb7hy8NUMigp+CiPvn4my2l03JIQlMf9YuSOoixkns/cYXUKQ2uaGVgdF2JYkrZQ yxnbk8uhyBygzTpNos/Cx76S1X/VR23yJa7Ktb1skO9bp8U5jP0raKowf4NxH+fIDl5a DWqMj112LNDr8on2PaZ887m/DMv8yg6we6UB45zm/gQre7Q940QySyZRBo0n/NSScXCe r1v0P0eW+mXAm0ND8bb0R0vNQLn1jRKGAlTpODZ4/zUjbdjuKrwUKqN+phDLkvOzmw9G LOaXjo6fRM1YHiojGKBkUsMWDvQYr/FlFuFrMe0XM4dZBdos4/rusTtJ3RZrkkPL8sPm lnCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:subject:in-reply-to:references :date:message-id:mime-version:content-transfer-encoding :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=eqkjmIx0EyBJZFsAKILR13zsqC47hxt3yLVNb0ZLQR0=; b=Yq43Vs4fEzhYcUQn3txbytHdScBnLrehXOxCVmJVt0RNWi7Bvh0Gy5H52pb95AXlcT iDH0Y1ECAA2neRY+zJ9vTLulOecOgtDj7DULWFMwPGzNYQBpYSY9GtAQXCYpwyoLse8t iNRssdMBii0g4gRfLCxYgA85FKGy6MMbT1RP53rjmJGec84jw9cN4pVkO64USaxYvAwQ yaXmIm+cYJnRb6cBG9Ptmoy6x0oG8SsBK3ifEoiJvON4EhKgJRuVmyc7iL3k8WvIrEEQ 3DOX1akgCQpwF3yeK0L/8OHzV4XpjScMqarx0CF26+HdS6l4zucFN4qNbVfUFF13WM2f Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ANhLgQ2VPfzurJ2VPFfPhRGv6Bl5Vu5QXDCTigf8svoLJhXZ3QRCcbzP jpVfdG7+NrJ2jRlkP/S+ZOM= X-Google-Smtp-Source: ADFU+vvhNtxHa+9n+hglulVGId1MjEtWxpRCSuWRvl1ZlDcAoYP2J3gzuWGm+33P0393/NbZVapvCw== X-Received: by 2002:ac8:32fc:: with SMTP id a57mr8475811qtb.331.1585240561129; Thu, 26 Mar 2020 09:36:01 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a37:6487:: with SMTP id y129ls2802422qkb.10.gmail; Thu, 26 Mar 2020 09:35:57 -0700 (PDT) X-Received: by 2002:a37:9bcd:: with SMTP id d196mr9119313qke.212.1585240556911; Thu, 26 Mar 2020 09:35:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585240556; cv=none; d=google.com; s=arc-20160816; b=enwMcdv6I7DlDdCobV36ANUGwXklBFqJNdE+q3UMCeC4iLoUs+9E+8w9opdqdFVjhF +kpEZhkCyC0XzxJ4NtZcYEJeVvhJF05pYeI8PsWnsSWfbdYuQc+O3WB2kwAEWOJSfSqZ F32WfVZp6KI3pXqFquDugurS+I3XAQMB0HuE4hL04vyW34zA2zRX2xyOKALxYS7l4PI8 RQLkiJyws8jEDd8a3F09qShDVJxef+D6Lx5bTyj4yoH43NMCJv1wUn9aa1xXe5iLC0lj aznNFpchFN7mcII2R/Gppvo3zgBhsDTP1GhqQKb1X7zHPEXPEM581pMGYiYjH4zcS370 +bjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:to:from:dkim-signature; bh=W6uZAre+7BsjUBS3sQ4t8/wjzSsHDtlXNaObOWzDHFc=; b=oXYjZYpOFXPFr4mB4SvgdDyNIh/53RfMtfZW/13+2tOLAK7nok3Ekjw7fo+K3/jD/1 KJaKBUceItw1LK3pSy0yvYVR9QestqSBj8ZBc8zgsbtm8vH8ug3TK110XJ1sQMj8ehtN kSC0MD04dHTqwIGv0qbdxXR5UlvohssjqSeQ8DX/kj8v3mzwCGFtrZxUzmL0P+04AKIs jKAqNV4nLFNVCflHMtFY/nZmB+7nECPdxUyPuqeKik4zUEgfmWvNrUo0jhtIuoixE2S4 Im+BcukbFHrW35HFnX2hvpRLu07wJbMooctu+jyhRT53QahH+gUw3A+jciBOaW+5l04e 9U8w== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=TyPsGL4b; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::529 as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org Original-Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com. [2607:f8b0:4864:20::529]) by gmr-mx.google.com with ESMTPS id d34si247810qte.4.2020.03.26.09.35.56 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Mar 2020 09:35:56 -0700 (PDT) Received-SPF: pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::529 as permitted sender) client-ip=2607:f8b0:4864:20::529; Original-Received: by mail-pg1-x529.google.com with SMTP id 142so3128259pgf.11 for ; Thu, 26 Mar 2020 09:35:56 -0700 (PDT) X-Received: by 2002:a63:3187:: with SMTP id x129mr9042979pgx.180.1585240555853; Thu, 26 Mar 2020 09:35:55 -0700 (PDT) Original-Received: from johnmacfarlane.net (li55-134.members.linode.com. [74.82.3.134]) by smtp.gmail.com with ESMTPSA id z63sm1985951pgd.12.2020.03.26.09.35.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2020 09:35:54 -0700 (PDT) Original-Received: by johnmacfarlane.net (Postfix, from userid 1000) id C7C99A26A; Thu, 26 Mar 2020 12:35:43 -0400 (EDT) In-Reply-To: <23e7c785-0f67-4b15-92b6-5c05cf2be2f7-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Original-Sender: jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=TyPsGL4b; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::529 as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@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:24734 Archived-At: Whoops, that was a big oversight! Try this one: function Str(el) local citekey =3D el.text:match("[[]@(%w+)[]]") if citekey then local citation =3D pandoc.Citation(citekey, 'NormalCitation') return pandoc.Cite({pandoc.Str(citekey)}, {citation}) end end Andrzej Wodecki writes: > Dear John,=20 > > many many thanks, You helped me a lot. I *almost* there - and as always *= almost=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 Su= rvey.=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 MacF= arlane=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 M= acFarlane=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 her= e:=20 >> >> >=20 >> >>=20 >> https://medium.com/@andrzej.wodecki/scrivener-for-scientific-writing-set= up-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 Jos= eph 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 citatio= n=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 esca= pe=20 >> >> >> citation syntax, allowing you to go to markdown, and then from tha= t=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= email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgi= d/pandoc-discuss/23e7c785-0f67-4b15-92b6-5c05cf2be2f7%40googlegroups.com. --=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/m2imirm5uo.fsf%40johnmacfarlane.net.