Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Citations (bibtex?) support #120

Merged
merged 7 commits into from
Aug 22, 2016
Merged

Citations (bibtex?) support #120

merged 7 commits into from
Aug 22, 2016

Conversation

willdurand
Copy link
Member

@willdurand willdurand commented Aug 19, 2016

Purpose

The idea is to support BibTeX for scientific references.

Features

  • Proof of Concept
  • Write a lib to parse and format bibtex content
  • Write a markdown-it plugin to enhance the fence block parser
  • Write tests for the markdown-it plugin
  • Write tests for the lib
  • Make it pretty in the Preview panel

See below for screenshots.

@willdurand
Copy link
Member Author

I have a working prototype. Let's see what we want to do though because it only supports rendering bibtex entries like this:

@article{author16, ...} 

@jmaupetit
Copy link
Member

As mentioned in #16 (see this comment), I know it won't be easy, but adding citations as footnotes would be nice.

@willdurand
Copy link
Member Author

willdurand commented Aug 19, 2016

Well, supporting bibtex preview would already be nice. My idea is to allow the use of some bibtex references, but I will not rewrite Overleaf :-)

There is no lib for formatting bibtex files correctly in javascript, so I have to write this lib first :-(

Then, I have to test the markdown-it plugin I wrote for rendering bibtex content. I chose this format:

 ```cite
 bibtex content goes here
 ```

Then, I will try to support the [@citation_key] notation to link citation keys in the text with bibtex entries. After that, it should be possible to reuse the principle of footnotes, but as I said, I don't really use them, so I am not sure to spend time on it.

Here are a few screenshots:

screen shot 2016-08-19 at 11 47 17

screen shot 2016-08-19 at 11 46 43

@jmaupetit
Copy link
Member

Then, I will try to support the [@citation_key] notation to link citation keys in the text with bibtex entries.

This is precisely what I am talking about: citation keys (e.g. hunter_ebi_2014) should be clickable; clicking on a key should scroll down to the rendered BibTeX entry (just like footnotes).

@willdurand
Copy link
Member Author

willdurand commented Aug 19, 2016

Not exactly, I should have written "wire" instead of "link". Example: [@hunter_ebi_2014] should render (Hunter et al., 2014) in the preview.

@jmaupetit
Copy link
Member

Ok then. Let's consider this issue as the first step of adding bibliography support in Monod and forget about footnote-like behavior.

@willdurand
Copy link
Member Author

Current status:

screen shot 2016-08-19 at 14 57 17

@willdurand
Copy link
Member Author

willdurand commented Aug 19, 2016

So, it uses regular fence blocks so that rendering in GitHub or whatever GFM-compliant editor should still render something in a decent way:

screen shot 2016-08-19 at 15 21 11

I just added a visual tip for invalid references (i.e. not found in any bibtex entries):

screen shot 2016-08-19 at 15 21 20

@willdurand
Copy link
Member Author

Issue transformed into a PR 🎉

const token = tokens[idx];

if ('cite' === token.info) {
const entries = bibtex.parse(md.utils.escapeHtml(token.content));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for myself: maybe I could avoid to parse the content twice (here and below in the fence block parser)

* new cite plugin (that enhances the fence block parser + add support for [@citation_ref])
* bibtex lib to parse and format references
Don't know if it is a good idea, but at least we can make it testable...
@willdurand willdurand merged commit 40e9a44 into master Aug 22, 2016
@willdurand willdurand deleted the bibtex branch August 22, 2016 14:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants