Closed kjambunathan closed 4 years ago
KMFGJF27-apse
I have checked out your repo, and looked at the pandoc
files in there.
In the Makefile
, I see invocation for pandoc-zotero-live-citemarkers.lua
(and NOT zotero.lua
). I am wondering if you are working on improvements to zotero.lua
. This paper
document doesn't produce a scannable-cite
version.
In the transcript of the bug, I have used one of the keys from biblio.bib
in your report, and manually imported it in to zotero client.
paper:
@rm -f *.docx *.odt *.json
@pandoc -s --lua-filter=pandoc-zotero-live-citemarkers.lua -o paper$(TIMESTAMP).docx main.md
@pandoc -s --lua-filter=pandoc-zotero-live-citemarkers.lua -o paper$(TIMESTAMP).odt main.md
@pandoc -s --metadata=zotero_scannable_cite:true --lua-filter=pandoc-zotero-live-citemarkers.lua -o paper$(TIMESTAMP)-scannable-cite.odt main.md
When I tried to programmatically import the biblio.bib
to Zotero, I realized that your repo needs python 3
. I am little bit hesitant to move to python3.
start:
ZOTERO_IMPORT=$(PWD)/biblio.bib npm start
Scannable cite was indeed broken; try the version at https://raw.githubusercontent.com/retorquere/zotero-better-bibtex/gh-1581/site/content/exporting/zotero.lua
In the Makefile, I see invocation for pandoc-zotero-live-citemarkers.lua (and NOT zotero.lua). I am wondering if you are working on improvements to zotero.lua. This paper document doesn't produce a scannable-cite version.
zotero.lua
is a bundled version that includes the json encoder/decoder, utils.lua
and zotero.lua
to get to a standalone filter, so you don't have to install the dependencies. pandoc-zotero-live-citemarkers.lua
is the "main" code that loads and calls the other parts.
In the Zotero UI, a quick copy of the entry using scannable cite format produces this
The lua filter won't produce exactly that; the human-readable part ("Wrigstad, & Castegren, 2017") will just be the citekey. Scannable cite doesn't need that part, it's just a user convenience.
When I tried to programmatically import the biblio.bib to Zotero, I realized that your repo needs python 3. I am little bit hesitant to move to python3.
That's not changing. My test framework has a lot of assumptions expecting Python 3.8. You might want to try pyenv or conda if you really want to use the test runner.
You don't really need all that to test the pandoc stuff though. Just create a new profile (using zotero -datadir profile -P
), install BBT in that profile, and import the bib file. After that, whenever you start Zotero with that profile (with -datadir profile
), everything you need for the pandoc tests is present. The automated import is mainly because I do all my testing in a dedicated testing profile, and that gets erased very often.
If you don't include -datadir profile
on each start of Zotero for these tests, Zotero will point to your main datadir, and the import will land in your regular Zotero library. I'm presuming you don't want that. The test runner automates that, but it's a very heavyweight process; it also rebuilds & installs BBT in the testing profile it creates.
Can you download this, place it on the pandoc
directory of the clone you have (replacing the existing Makefile
), and run make 1581
(assuming you have imported biblio.bib)? The pandoc call should only output the following:
@sec:theory: not found
@sec:achievement-driven: not found
@sec:the-game: not found
@fig:matrix: not found
@sec:implementation: not found
This downloads the bundled lua filter so that we'll be sure that we're using the same filter, and applies it to the etst file. This reliably gets me a scannable cite odt.
~Wait, let me retool that to use your citekey so you don't have to import biblio.bib~ never mind, you were already using a key from biblio.bib. Yeah, so test that Makefile please.
No luck even after installing 5.2.45.6838.xpi
.
This is what I did.
make 1581
.I have updated the Makefile to only build your minimal ww.md
. I still reliably get scannable cite. What version of pandoc are you using?
I appreciate you are trying to include as much relevant info as possible, but your posts are very overwhelming to read for me. Could you use bold instead of ##
headings, and maybe a little more selective output? And no all-caps please. I'm an oldschool internet habitant from the usenet days, and allcaps sounds like shouting in my mind, I can't help it.
No need to install 6838, sorry about that post, that was automated. Nothing has changed in BBT, so the normal release will suffice.
I skipped the lua
script, and hit the URL directly
I see
TypeError: citationKeys is undefined[1]
The above error is with /zotero-better-bibtex-5.2.45.6838.xpi
~/src/zotero-better-bibtex/pandoc$ curl -s http://127.0.0.1:23119/better-bibtex/export/item?pandocFilterData=true&translator=jzon&citationKeys=wrigstad2017mastery
[1] 16130
[2] 16131
TypeError: citationKeys is undefined[1]- Done curl -s http://127.0.0.1:23119/better-bibtex/export/item?pandocFilterData=true
[2]+ Done translator=jzon
~/src/zotero-better-bibtex/pandoc$ pandoc -s --lua-filter=pandoc-zotxt.lua -F pandoc-citeproc ww.md -t plain
(Wrigstad and Castegren 2017)
Wrigstad, Tobias, and Elias Castegren. 2017. “Mastery Learning-Like
Teaching with Achievements.” In SPLASH-E.
Quick upate. Scannable cite does NOT work with test build 5.2.45.6841 as well.
Sorry about those test builds. You can ignore them; nothing has changed in BBT for this. I'm just checking in changes to the Makefile.
TypeError: citationKeys is undefined[1]
You have to quote the URL. The &
in the URL means "execute in background" to the shell when not quoted.
~/src/zotero-better-bibtex$ dpkg -l | grep pandoc
ii libghc-pandoc-citeproc-data 0.16.4.1-1 all Pandoc support for Citation Style Language - data files
ii pandoc 2.9.1.1-2 amd64 general markup converter
ii pandoc-citeproc 0.16.4.1-1+b1 amd64 Pandoc support for Citation Style Language - tools
ii pandoc-data 2.9.1.1-2 all general markup converter - data files
TypeError: citationKeys is undefined[1]
You have to quote the URL. The
&
in the URL means "execute in background" to the shell when not quoted.
This is the working version.
curl -s 'http://127.0.0.1:23119/better-bibtex/export/item?pandocFilterData=true&translator=jzon&citationKeys=wrigstad2017mastery'
make 1581
with ww.md
still doesn't produce scannable cite documents.
That's the pandoc version I have. I don't know what to tell you. make 1581
fetches the same filter for you and me, and it gets me a scannable cite on both Mac and Ubuntu.
Can you try with this as the filter? It will log its workings to stdout.
Can you try with this as the filter? It will log its workings to stdout.
~/src/zotero-better-bibtex/pandoc$ make 1581
curl -L https://gist.githubusercontent.com/retorquere/7c41cea2bd44544571fd5f28ff74eefc/raw/01418802313c481545219b93354cea3aef2e25c4/zotero.lua -o zotero-bundled.lua
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 48584 100 48584 0 0 7595 0 0:00:06 0:00:06 --:--:-- 11545
echo "[@wrigstad2017mastery]" > ww.md
pandoc -s --metadata=zotero_scannable_cite:true --lua-filter=./zotero-bundled.lua -o paper2020-07-23T14:27:11-scannable-cite.odt ww.md
{"client":"zotero","author_in_text":false,"scannable_cite":true,"format":"scannable-cite"}
http://127.0.0.1:23119/better-bibtex/export/item?pandocFilterData=true&translator=jzon&citationKeys=
unzip paper2020-07-23T14:27:11-scannable-cite.odt content.xml
Archive: paper2020-07-23T14:27:11-scannable-cite.odt
inflating: content.xml
grep @wrigstad2017mastery content.xml
<text:p text:style-name="Text_20_body">[@wrigstad2017mastery]</text:p>
1581:
@rm -f *.docx *.odt *.json content.xml
curl -L https://gist.githubusercontent.com/retorquere/7c41cea2bd44544571fd5f28ff74eefc/raw/01418802313c481545219b93354cea3aef2e25c4/zotero.lua -o zotero-bundled.lua
echo "[@wrigstad2017mastery]" > ww.md
pandoc -s --metadata=zotero_scannable_cite:true --lua-filter=./zotero-bundled.lua -o paper$(TIMESTAMP)-scannable-cite.odt ww.md
unzip paper$(TIMESTAMP)-scannable-cite.odt content.xml
grep @wrigstad2017mastery content.xml
Can you try with this as the filter? It will log its workings to stdout.
I have a hunch on where the problem could be. May be the Scannable Cite.js
is in a location different from what the lua script expects.
Remember cayw
url works. But zotero.lua
doesn't work. May if you could track down the changes in these code paths, then the fix will be obvious.
The lua script doesn't expect Scannable Cite.js
to be anywhere -- the lua script makes the scannable cite marker by itself.
Surely, cayw
is doing the right thing for me.
That's because that actually does use the output of Scannable Cite.js
. The two don't have anything to do with each other.
That's because that actually does use the output of
Scannable Cite.js
. The two don't have anything to do with each other.
That explains why I don't see scannable cite
in BibTex's translator list. (See screenshot). Are BibTex and Zotero's translators compatible .... May be I can teach Better BibTex about 'Scannable Cite` as a translator ...
Can you try again with https://gist.githubusercontent.com/retorquere/dbfcc3e51f2aaf82333bddb38cf5e4de/raw/zotero.lua ?
That explains why I don't see scannable cite in BibTex's translator list. (See screenshot). Are BibTex and Zotero's translators compatible .... May be I can teach Better BibTex about 'Scannable Cite` as a translator ...
You don't need it there. If you want drag and drop scannable cites, just set Scannable Cite
to be the default format for Default Format
under Export
in the Zotero preferences. The menu you screencapped above is just to change the behavior of the Better BibTeX Citation Key Quick Copy
export translator. They're not translators themselves.
Can we please not do many questions at once? The pandoc scannable cite is entirely separate from the bits you're looking at now.
Is @
part of a citekey. zotero.lua thinks @
is not part of citekey. Does pandoc thnk otherwise.
Is there a way to examine pandoc's AST on my side?
~/src/zotero-better-bibtex/pandoc$ curl -s 'http://127.0.0.1:23119/better-bibtex/export/item?pandocFilterData=true&translator=jzon&citationKeys=wrigstad2017mastery'
{"items":{"wrigstad2017mastery":{"attachments":[],"citationKey":"wrigstad2017mastery","citekey":"wrigstad2017mastery","creators":[{"creatorType":"author","firstName":"Tobias","lastName":"Wrigstad"},{"creatorType":"author","firstName":"Elias","lastName":"Castegren"}],"date":"2017","dateAdded":"2020-07-22T06:12:32Z","dateModified":"2020-07-22T06:12:32Z","extra":"Citation Key: wrigstad2017mastery","itemID":110,"itemType":"conferencePaper","key":"TH5CXWRG","libraryID":1,"notes":[],"publicationTitle":"SPLASH-E","relations":[],"select":"zotero://select/library/items/TH5CXWRG","tags":[],"title":"Mastery learning-like teaching with achievements","uri":"http://zotero.org/users/local/debm4usg/items/TH5CXWRG","version":0}},"zotero":{"wrigstad2017mastery":{"itemID":110,"uri":"http://zotero.org/users/local/debm4usg/items/TH5CXWRG"}},"errors":{}}
The filter at that gist should output:
Inlines_replace_cites: format=scannable-cite
Inlines_replace_cites: format=scannable-cite
Inlines_replace_cites: format=scannable-cite
Inlines_replace_cites: format=scannable-cite
Inlines_replace_cites: citekeys={"wrigstad2017mastery":true}
scannable-cite: { | [@wrigstad2017mastery] | | | zu:0:PQUXDB37 }
The @
is not part of the citekey. You can sort of get the AST by doing pandoc ww.md -o ww.json
but the field names are not always the same (the json has citationId
for example where the AST has id
).
The output of the filter from the gist will tell me more. Maybe it's just not fetching the citekeys properly on your system, that would explain the behavior.
It is not really seeing any keys at all. Here is the output.
~/src/zotero-better-bibtex/pandoc$ make 1581
curl -L https://gist.githubusercontent.com/retorquere/dbfcc3e51f2aaf82333bddb38cf5e4de/raw/zotero.lua -o zotero-bundled.lua
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 48739 100 48739 0 0 32086 0 0:00:01 0:00:01 --:--:-- 32086
echo "[@wrigstad2017mastery]" > ww.md
pandoc -s --metadata=zotero_scannable_cite:true --lua-filter=./zotero-bundled.lua -o paper2020-07-23T15:23:57-scannable-cite.odt ww.md
unzip paper2020-07-23T15:23:57-scannable-cite.odt content.xml
Archive: paper2020-07-23T15:23:57-scannable-cite.odt
inflating: content.xml
grep @wrigstad2017mastery content.xml
<text:p text:style-name="Text_20_body">[@wrigstad2017mastery]</text:p>
~/src/zotero-better-bibtex/pandoc$
It's not running the filter at all it seems. The Inlines_replace_cites
should be present even if it's just a simple text file without citekeys.
Are you getting it from the right gist? I'm using https://gist.github.com/retorquere/dbfcc3e51f2aaf82333bddb38cf5e4de now
Are you getting it from the right gist? I'm using https://gist.github.com/retorquere/dbfcc3e51f2aaf82333bddb38cf5e4de now
See the make 1581
output
That's the point. If that doesn't give Inlines_replace_cites
output, the filter isn't running at all. Can you check whether the line
print('Inlines_replace_cites: format=' .. config.format)
is present in your filter?
That's the point. If that doesn't give
Inlines_replace_cites
output, the filter isn't running at all. Can you check whether the lineprint('Inlines_replace_cites: format=' .. config.format)
is present in your filter?
Of course. (I am a developer)
You can skip the unzip and the grep for now. If those lines don't appear with the filter at the gist, the filter is not being ran.
Can you grab the filter at https://gist.github.com/fe514aa0344c65d28445d8dceb899de1 and see what this outputs:
pandoc -s --lua-filter=./mwe.lua -o ww.docx ww.md
My guess is that pandoc
tries to load the module. But module load fails, and pandoc is skipping ahead silently.
Does LUA_PATH
look good to you?
~/src/zotero-better-bibtex/pandoc$ luarocks path
export LUA_PATH='/home/kjambunathan/.luarocks/share/lua/5.1/?.lua;/home/kjambunathan/.luarocks/share/lua/5.1/?/init.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;./?.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua'
export LUA_CPATH='/home/kjambunathan/.luarocks/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/?.so;./?.so;/usr/lib/x86_64-linux-gnu/lua/5.1/?.so;/usr/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so'
~/src/zotero-better-bibtex/pandoc$ echo $LUA_PATH
/home/kjambunathan/.luarocks/share/lua/5.1/?.lua;/home/kjambunathan/.luarocks/share/lua/5.1/?/init.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;./?.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua
I have no idea, but the filter doesn't use anything from the path. Everything it needs is bundled into the filter.
~/src/zotero-better-bibtex/pandoc$ cat ww.md
[@wrigstad2017mastery]
~/src/zotero-better-bibtex/pandoc$ cat test.lua
function Inlines_holler(inlines)
print('inlines')
return inlines
end
return {
{ Inlines = Inlines_holler },
}
~/src/zotero-better-bibtex/pandoc$ pandoc -s --lua-filter=./test.lua -o ww.odt ww.md
If that doesn't output anything, pandoc is not running lua filters at all, full stop. There's nothing I can do about that -- for me it does run this filter, and outputs inlines
four times. You'll have to get help from the pandoc people to see why this filter is not running.
If that doesn't output anything, pandoc is not running lua filters at all, full stop.
It does run lua filters. My guess is that it is not hitting the inlines
callback.
~/src/zotero-better-bibtex/pandoc$ pandoc -s --lua-filter=pandoc-zotxt.lua -F pandoc-citeproc ww.md -t plain
(Wrigstad and Castegren 2017)
Wrigstad, Tobias, and Elias Castegren. 2017. “Mastery Learning-Like
Teaching with Achievements.” In SPLASH-E.
https://pandoc.org/lua-filters.html:
There are two special function names, which can be used to define filters on lists of blocks or lists of inlines.
Inlines (inlines) If present in a filter, this function will be called on all lists of inline elements, like the content of a Para (paragraph) block, or the description of an Image. The inlines argument passed to the function will be a List of Inlines for each call.
Does the AST look good to you. I don't see anything tagged as inlines
.
~/src/zotero-better-bibtex/pandoc$ cat ww.md
[@wrigstad2017mastery]
(reverse-i-search)`json': cat ww.^Con
~/src/zotero-better-bibtex/pandoc$ pandoc ww.md -o ww.json
~/src/zotero-better-bibtex/pandoc$ cat ww.json
{"blocks":[{"t":"Para","c":[{"t":"Cite","c":[[{"citationSuffix":[],"citationNoteNum":0,"citationMode":{"t":"NormalCitation"},"citationPrefix":[],"citationId":"wrigstad2017mastery","citationHash":0}],[{"t":"Str","c":"[@wrigstad2017mastery]"}]]}]}],"pandoc-api-version":[1,20],"meta":{}}
If that doesn't output anything, pandoc is not running lua filters at all, full stop. There's nothing I can do about that -- for me it does run this filter, and outputs inlines four times. You'll have to get help from the pandoc people to see why this filter is not running.
Thanks for your time. I will narrow it down further. I have gathered some additional information to proceed ahead.
(Below remark is for benefit of search engines)
Lua filter is not of much importance to me. I will not be using pandoc at all. Instead, I will be using Emacs's Orgmode filters. So, JSON-RPC would be what I need. See https://github.com/retorquere/zotero-better-bibtex/issues/1582.
Yeah, that AST looks good -- Inlines
and Blocks
aren't present in the AST, they're called when pandoc sees a certain formation of AST elements.
This is another way to look at the AST.
$ echo 'See [@wrigstad2017mastery].' | pandoc -f markdown -t native
[Para [Str "See",Space,Cite [Citation {citationId = "wrigstad2017mastery", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[@wrigstad2017mastery]"],Str "."]]
Yeah I know but you get the same identifiers, and inside the Lua filters they look differently -- citation nodes in the AST as a Lue filter sees it have an id
, not an citationId
, and these nodes have a .t
property that you find their type name on, and that's not present in the json/native AST dump.
This is a pandoc issue.
zotero.lua doesn't work with this version of pandoc-2.9.1.1, specifically the version that comes with Debian sid
~$ pandoc --version
pandoc 2.9.1.1
Compiled with pandoc-types 1.20, texmath 0.12.0.2, skylighting 0.8.4
Default user data directory: /home/kjambunathan/.local/share/pandoc or /home/kjambunathan/.pandoc
Copyright (C) 2006-2019 John MacFarlane
Web: https://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
~$ dpkg -l | grep pandoc
ii libghc-pandoc-citeproc-data 0.16.4.1-1 all Pandoc support for Citation Style Language - data files
ii pandoc 2.9.1.1-2 amd64 general markup converter
ii pandoc-citeproc 0.16.4.1-1+b1 amd64 Pandoc support for Citation Style Language - tools
ii pandoc-data 2.9.1.1-2 all general markup converter - data files
zotero.lua
works with pandoc 2.10, specifically latest binary release from https://github.com/jgm/pandoc/releases/tag/2.10
~$ dpkg -l | grep pandoc
ii libghc-pandoc-citeproc-data 0.16.4.1-1 all Pandoc support for Citation Style Language - data files
ii pandoc 2.10-1 amd64 general markup converter
ii pandoc-citeproc 0.16.4.1-1+b1 amd64 Pandoc support for Citation Style Language - tools
ii pandoc-data 2.9.1.1-2 all general markup converter - data files
~$ pandoc --version
pandoc 2.10
Compiled with pandoc-types 1.21, texmath 0.12.0.2, skylighting 0.8.5
Default user data directory: /home/kjambunathan/.local/share/pandoc or /home/kjambunathan/.pandoc
Copyright (C) 2006-2020 John MacFarlane
Web: https://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
@retorquere As part of the resolution, you may want to check for pandoc version in zotero.lua
. Thanks for your support and patience.
I will leave one more comment, for the benefit of people who could be hitting this bug through search engines.
This comment captures the results of a successful run.
~/src/zotero-better-bibtex/pandoc$ make 1581
curl -L https://raw.githubusercontent.com/retorquere/zotero-better-bibtex/master/site/content/exporting/zotero.lua -o zotero-bundled.lua
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 48420 100 48420 0 0 12785 0 0:00:03 0:00:03 --:--:-- 12785
echo "[@wrigstad2017mastery]" > ww.md
pandoc -s --metadata=zotero_scannable_cite:true --lua-filter=./zotero-bundled.lua -o paper2020-07-23T18:38:31-scannable-cite.odt ww.md
unzip paper2020-07-23T18:38:31-scannable-cite.odt content.xml
Archive: paper2020-07-23T18:38:31-scannable-cite.odt
inflating: content.xml
grep @wrigstad2017mastery content.xml
<text:p text:style-name="Text_20_body">{ <text:s text:c="1" />| [@wrigstad2017mastery] | <text:s text:c="1" />| <text:s text:c="1" />| zu:0:TH5CXWRG }</text:p>
These are screenshots taken on LibreOffice
Output as produced by zotero.lua
Output after running it through Tools->ODF Scan
Output after after changing Document Preferences
to use Chicago Author Date
Output after after inserting Bibliography
filter broken
**pandocc is installed** ``` ~$ pandoc --version pandoc 2.9.1.1 Compiled with pandoc-types 1.20, texmath 0.12.0.2, skylighting 0.8.4 Default user data directory: /home/kjambunathan/.local/share/pandoc or /home/kjambunathan/.pandoc Copyright (C) 2006-2019 John MacFarlane Web: https://pandoc.org This is free software; see the source for copying conditions. There is no warranty, not even for merchantability or fitness for a particular purpose. ``` **pandoc datadir has `pandoc-zotxt.lua` and `zotero.lua` filters** ``` ~$ ls /home/kjambunathan/.local/share/pandoc/filters pandoc-zotxt.lua pandoc-zotxt.lua-0.3.17 zotero.lua ``` **A very simple `md` file** ``` ~$ cat ww.md @wrigstad2017mastery ``` **Conversion to using `pandoc-zotxt` works fine => citekey is present in Zotero** ``` ~$ pandoc -s --lua-filter=pandoc-zotxt.lua -F pandoc-citeproc ww.md -t plain Wrigstad and Castegren (2017) Wrigstad, Tobias, and Elias Castegren. 2017. “Mastery Learning-Like Teaching with Achievements.” In SPLASH-E. ``` **Try using [`zotero.lua`](https://retorque.re/zotero-better-bibtex/exporting/zotero.lua) to produce 'scannable-cite` ODT file** (cf. https://retorque.re/zotero-better-bibtex/exporting/pandoc/) ``` ~$ pandoc -s --metadata=zotero_scannable_cite:true --lua-filter=zotero.lua -o ww.odt ww.md ~$ rm *.xml mimetype ``` **`content.xml` is not OK. I see no scannable cite. The citekey is literally carried over with no translations whatsoever.** ``` ~$ unzip ww.odt Archive: ww.odt extracting: mimetype inflating: meta.xml inflating: META-INF/manifest.xml inflating: content.xml inflating: manifest.rdf inflating: styles.xml inflating: settings.xml extracting: Configurations2/accelerator/current.xml inflating: Thumbnails/thumbnail.png ~$ cat content.xml | tail