Closed LibrEars closed 2 years ago
I'm not sure if I should support CiTO because it's an extension. Is the split of the citation key with a colon widely used? Anyway, you could create a file at ~/.config/nvim/after/syntax/markdown
(or .vim/after/syntax/markdown
if using Vim) with the following contents:
syn clear zoteroPCite
syn clear zoteroHidden
syn clear zoteroVisible
syn clear zoteroCiteKey
syn clear zoteroCiteLocator
syn region zoteroPCite matchgroup=Operator start=/\[\ze[^\]]\{-}@/ skip=/\\]/ end=/\]/ keepend transparent contains=zoteroCiteKey,markdownItalic,pandocEmphasis
syn match zoteroCiteKey /@[:#_[:digit:][:lower:][:upper:]\u00FF-\uFFFF]\+/ contains=zoteroHidden,zoteroCito,zoteroCiteLocator
syn match zoteroCito /[a-z_]\{-}:/ contained containedin=zoteroCiteKey contains=@NoSpell
syn match zoteroHidden /[A-Z0-9]\{8}#/ contained containedin=zoteroCiteKey conceal contains=@NoSpell
syn match zoteroCiteLocator /-\ze@/ contained containedin=zoteroCiteKey
syn match zoteroCiteLocator /@/ contained conceal containedin=zoteroCiteKey
hi def link zoteroCito PreCondit
I did some changes to Zotcite's syntax highlighting and now it's enough if you create the file ~/.config/nvim/after/syntax/rmd.vim
or ~/.config/nvim/after/syntax/quarto.vim
(or both) with the following contents:
syn match zoteroCito /[a-z_]\{-}:/ contained containedin=zoteroCiteKey contains=@NoSpell
hi def link zoteroCito PreCondit
Thank you very much! This is awesome!
Could you explain the regular expression? Does it allow everything as long as it is followed by the zoteroCiteKey?
If yes is should be possible to change the CiTO notation from @property:zoteroCiteKey
to @property-zoteroCiteKey
(using a -
instead of :
) from the perspective of zotcite right? This would follow the quarto syntax (@fig-... etc).
Any character can be used to delimit strings in syntax scripts. So, /
is the delimiter.
\{-}
means "as few as possible"
So, the whole code means: match a string with a sequence of either lowercase ASCII letters or underlines ended by a colon and then highlight it as the PreCondit highlight group.
It matches the pattern as long as it is inside a zotcite citation key (zoteroCiteKey) which begins with the @
. The complete definition of the citation key is in the zotcite/after/syntax/markdown.vim
script, but, in summary, a pattern will be a zoteroCiteKey only if it includes 8 uppercase letters followed by a dash. So, @fig- is highlighted as zoteroLabel, not zoteroCiteKey.
Yes, you can replace ':' with '-' if this is how you write your CiTO label.
Hi =)
CiTO allows the author to semantically specify the reason a citation is given: https://github.com/pandoc-ext/cito
I successfully install CiTO as an quarto extension. It is not listed but it worked (other extensions already exist extensions from the pandoc-ext repo):
quarto install extension pandoc-ext/cito
To use it I activated the extension in my project with
cd my_project
andquarto add pandoc-ext/cito
I think I also found out how to run it properly by including it as a filter into the yaml header to run it before zotref.py and before citeproc ("It is mandatory to run citeproc after this filter if CiTO data is embedded in the document; otherwise citeproc will interpret CiTO properties as part of the citation ID."):Now the compilation works but zotref highlighting etc. does not work obviously.
Is there a simple way to tell zotcite how to handle that notation?