Coder Social home page Coder Social logo

Citation links about wiki.vim HOT 11 CLOSED

jabirali avatar jabirali commented on September 4, 2024
Citation links

from wiki.vim.

Comments (11)

lervag avatar lervag commented on September 4, 2024 1

This should work now, both wrt. links and completion.

from wiki.vim.

lervag avatar lervag commented on September 4, 2024 1

Thanks; should be fixed now. The allowed characters in the citekey is now alphanumeric and - and _. This seems like a safe and useful set.

I assume you've read the docs on the Zotero scheme in :help wiki-links-urls? I've found that this feature works very well when I ensure authorYear style citekeys for my references. Omni completion also works very well when combined with find and fd (faster).

from wiki.vim.

lervag avatar lervag commented on September 4, 2024

Let me start by trying to explain how the links are implemented in wiki.vim. I've taken to distinguish between a link and a url. A link is the combination of a link text and a link url (which may be of several schemes). This is best explained by examples (see also :help wiki-links):

  • [text](url) (markdown style links)
  • [[url|text]] (wiki style links; the |text part is optional)
  • [target] or [text][target] (reference style links)
    • this is followed by a [target]: url below the text
  • scheme:address (url without link; is also detected as long as the scheme is included)

Note that the scheme part of the url is not necessary in the first three types of links. If it is not there, then the wiki scheme is assumed.


With that; my first thought is that the syntax @citekey could be implemented as a shortcut for an url specification, e.g. @citekey is synonymous to zot:citekey. This should not be too difficult to implement (that is, it should be easy). This would be similar to your proposal, except instead of @citekey implying [citekey](zot:citekey) it would only imply zot:citekey. I would make sure that it would still be detected as a free url, of course.

However, the bracketed form [@citekey] and [@c1; @c2] is worse, because it conflicts with the reference style link defined above. I think you might be right that this could be solved by ensuring that ampersands are not allowed in reference style links.

Thus, I think the following seems a sensible implementation route:

  • Add support for @citekey as a synonym for zot:citekey type urls.
  • Change reference style links so that the single bracket [content] is only valid if there are no ampersands in content.

Comments?

from wiki.vim.

jabirali avatar jabirali commented on September 4, 2024

Thanks for the explanation. I agree, that sounds like a good plan :).

Adding @citekey as a synonym for zot:citekey would already be "good enough" for my use:

  • @citekey is less typing than [@citekey], and I would use the simplest syntax for notes;
  • Via your Zotero handler, we would presumably get omnicompletion and the PDF open function;
  • We can export the wiki file via Pandoc, and the references should be readable and make sense;
  • Changing e.g. \citet to \cite as a postprocessing step after Pandoc LaTeX export is much less work than trying to change unrecognized zot: links to \cite.

Having [@citekey1; @citekey2] available would be a nice bonus feature if it's not too much work :). Implementing this, I think, would also be solved by your proposed solution for #59?

from wiki.vim.

jabirali avatar jabirali commented on September 4, 2024

Works great! Thanks for implementing this :)

from wiki.vim.

lervag avatar lervag commented on September 4, 2024

My pleasure; seems useful to me as well :)

from wiki.vim.

alwc avatar alwc commented on September 4, 2024

@lervag It seems if I use @some-citekey-string instead of zot:some-citekey-string, wiki#url#zot#parse doesn't seem to work properly.

  • For @some-citekey-string, echo self.stripped in wiki#url#zot#parse will return ome (i.e. missing the first character and the text at and after the first -).
  • For zot:some-citekey-string, echo self.stripped in wiki#url#zot#parse will return some-citekey-string

from wiki.vim.

alwc avatar alwc commented on September 4, 2024

That's quick! Thanks @lervag

I've found that this feature works very well when I ensure authorYear style citekeys for my references.

Do you mean having something like [auth:lower][year] as your "Citation key format" under Zotero -> Preferences -> Better BibTeX -> Citation Keys?

from wiki.vim.

lervag avatar lervag commented on September 4, 2024

That's quick! Thanks @lervag

My pleasure :)

Do you mean having something like [auth:lower][year] as your "Citation key format" under Zotero -> Preferences -> Better BibTeX -> Citation Keys?

Yes, precisely! I combine this with the Zotfile extension with filenames formatted as %b - {%T - } {%t}. When it is properly set up, I get nice autocompletion. I also have a simple shell function that uses fzf for quickly opening any pdf:

z() {
  pdf=$(fd -t f -e pdf . ~/.local/zotero | fzf -m -d '/' --with-nth=-1)
  if [ -f "$pdf" ]; then
    echo ${pdf#*zotero/storage/}
    zathura $pdf &
  fi
}

This relies on fd for finding the files and fzf for interactive choosing.

from wiki.vim.

alwc avatar alwc commented on September 4, 2024

That's quick! Thanks @lervag

My pleasure :)

Do you mean having something like [auth:lower][year] as your "Citation key format" under Zotero -> Preferences -> Better BibTeX -> Citation Keys?

Yes, precisely! I combine this with the Zotfile extension with filenames formatted as %b - {%T - } {%t}. When it is properly set up, I get nice autocompletion. I also have a simple shell function that uses fzf for quickly opening any pdf:

z() {
  pdf=$(fd -t f -e pdf . ~/.local/zotero | fzf -m -d '/' --with-nth=-1)
  if [ -f "$pdf" ]; then
    echo ${pdf#*zotero/storage/}
    zathura $pdf &
  fi
}

This relies on fd for finding the files and fzf for interactive choosing.

Nice! I think I'll make some modification of your script and create a new script with rga so that I can search within PDFs too.

from wiki.vim.

lervag avatar lervag commented on September 4, 2024

Nice! I think I'll make some modification of your script and create a new script with rga so that I can search within PDFs too.

I was not aware of rga. It seems interesting. Thanks for making me aware of it!

from wiki.vim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.