Documentation
¶
Overview ¶
Package refs reads a source's reference list into records a citation can point at, and the citation markers in a quote into the records they name.
Every field is read from the entry's own text by a fixed rule, never by a model, and every field is a stretch of that text: a DOI, an arXiv id, a year, a title and a first author are found in Raw or not at all. That is the quote gate's principle applied to references. Whether a reference exists is a separate question, answered by a resolver (refs/resolve).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthorYear ¶
AuthorYear is one author-year citation: "Lu et al., 2024" is {Lu, 2024}.
type Marker ¶
type Marker struct {
Text string
Labels []string
Keys []string
Cites []AuthorYear
}
Marker is one in-text citation: the text that makes it and the entries it names, as labels, keys or author-year pairs.
type Reference ¶
type Reference struct {
// ID is "r" and the first ten hex digits of the SHA-256 of the
// normalised entry, so the same entry is named the same way in every
// run and anyone holding the entry can recompute it.
ID string `json:"id"`
// Raw is the entry as the list gives it, line breaks folded to spaces.
Raw string `json:"raw"`
// Source names the file the list came from.
Source string `json:"source"`
// Label is the entry's marker without its brackets: "12" for "[12]"
// or "12.", "AJMV98" for "[AJMV98]", "" in an author-year list.
Label string `json:"label,omitempty"`
// Key is the BibTeX or \bibitem key, when the list comes from LaTeX.
Key string `json:"key,omitempty"`
// FirstAuthor is the first author's surname, or the first words of a
// corporate author.
FirstAuthor string `json:"first_author,omitempty"`
Title string `json:"title,omitempty"`
// Year is the year of publication, 0 when none is found.
Year int `json:"year,omitempty"`
DOI string `json:"doi,omitempty"`
ArXiv string `json:"arxiv,omitempty"`
URL string `json:"url,omitempty"`
}
Reference is one entry of a source's reference list.
func FromBibTeX ¶
FromBibTeX reads BibTeX entries as references. Raw is the entry written out as a plain citation ("Author. Title. Venue, Year."), so it names the entry the way a reference list would and its ID is stable however the file is formatted.
func Parse ¶
Parse reads a reference list into references, in list order. It reads numbered lists ("[12]", "12."), labelled lists ("[AJMV98]"), author-year lists, Markdown bullet lists and \bibitem lists. An entry that carries no year and no identifier is still returned: a resolver may find it by its title, and leaving it out would hide it from the run summary.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bibtex reads BibTeX files: the entries, their keys and their fields, as written.
|
Package bibtex reads BibTeX files: the entries, their keys and their fields, as written. |
|
Package resolve finds out whether a reference names a real work, and which.
|
Package resolve finds out whether a reference names a real work, and which. |