Link management using HTML / CSS / Javascript (BibTeX style)

HTML + CSS + Javascript tools offer a great way to create beautiful presentations (like opens.js + MathJax ). However, I usually need to add quotes to my presentations, and I would like to do it systematically (so the bibliography is organized and the links are well formatted). This is something that is easily handled in LaTeX through BibTeX.

The best solution I've found so far comes from a library called bibtex-js . It seems to be doing just fine with the fact that BiBTeX files in HTML are a list of bibliographies, which is partly what I want. However, I need not only to display the lists of bibliographies, but also I need to refer to the entries in this bibliography by some index and get a uniformly formatted reference marker. Take, for example, how LaTeX typically deals with this problem:

%In thebibliography.bib @article{darwin1859origins, title={On the origins of species by means of natural selection}, author={Darwin, Charles}, journal={London: Murray}, year={1859} } %In mydocument.tex As \cite{darwin1859origins} sustains in his ground-breaking book... 

The previous code will appear as something like "As Darwin (1859) supports in his groundbreaking book." Moreover, the formatting in which citation is performed can also be customizable (for example, β€œDarwin, 1859”, β€œ(Darving, 1859)”, β€œ[DWN59]”, β€œ[1]”, etc.).

So the question is, how do you deal with a similar task in an HTML document?

Thank you all in advance!

+6
source share
2 answers

Yes, there is an emacs extension called org-mode, which is text processing with markdown-like syntax. This can be exported to show-js via this: https://github.com/yjwen/org-reveal Or in my case I use the spacemacs extension: https://github.com/syl20bnr/spacemacs/tree/master/layers/ % 2Bemacs / org # revealjs-support

Thus, org mode is an intermediate format that compiles as you wish, i.e. show-js, html or even latex. This includes a link management system: https://github.com/jkitchin/org-ref

I am not happy with this for opens.js, if we use it with show.js, we get the whole link that will be presented as a link (no matter what we print after cite: , and the full citation formats are grouped on any you put them on the slide (so if you have more than 3, you cannot read it correctly, although I think it is in HTML). What I want is either the numbers that I get in latex links or based on footnotes, because in the case of slides, the footnotes work benign.

This, of course, will only work for HTML pages, however you probably want to have presentations like me. I was looking for a solution for this when I came across this unanswered question, so I think here is your answer.

0
source

I made a project, by the way also called bibtex-js . Available for npm .

I did this because most BibTeX parsers have significant parsing reductions. This is closely related to the authoritative document on BibTeX, Tame the BeaST and therefore works pretty well in terms of links and syntactic names of the authors, which seems to be what you are after.

I would say, based on some bibliographic standards, it collapses its own built-in citation function:

 import {parseBibFile, normalizeFieldValue} from "bibtex"; // Parse bib file const bibFile = parseBibFile(bibtexString); // insert the darwin1859origins example as a string // Sanity check: print all ids of entries in the bibfile console.log(Object.keys(bibFile.entries$)); // Get the entry we are after const entry = bibFile.getEntry("darwin1859origins"); // Get the relevant fields // normalizeFieldValue turns a BibTeX string into a Javascript string const year = normalizeFieldValue(entry.getField("year")); // get first author // "author" is a special kind of BibTeX field const author = entry.getField("author").authors$[0]; function inlineCite(author){ return "(" + (author.firstNames .concat(author.vons) .concat(author.lastNames) .concat(author.jrs)).join(" ") + "," + year + ")"; } console.log(inlineCite(author)); // (Charles Darwin, 1859) 

You can do something complicated with et al. if you have multiple authors.

+1
source

Source: https://habr.com/ru/post/955005/


All Articles