Documentation
¶
Overview ¶
Package citation converts MARC 21 records to the RIS and BibTeX citation formats used by reference managers (Zotero, EndNote, Mendeley) and LaTeX.
Citations are a flat, lossy subset of a bibliographic record, so this is a one-way MARC->citation mapping, not a codec. The Writers implement codex.RecordWriter, so they plug into codex.Convert; both formats are self-delimiting (an RIS record ends with ER, a BibTeX entry is a complete @type{...} block), so no Close is needed.
Unlike the single-format exporters (mods, dublincore, schemaorg) that expose one Encode, this package renders two distinct citation formats, so the package-level entry points are named for the format they produce: RIS and BibTeX (with FromRecord as the shared extraction step). Both return ([]byte, error) for signature parity with the other exporters so callers can treat any exporter uniformly; the error is always nil because rendering a citation string cannot fail.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteBibTeXFile ¶
WriteBibTeXFile writes every record to the named file in BibTeX format.
func WriteRISFile ¶
WriteRISFile writes every record to the named file in RIS format.
Types ¶
type Author ¶ added in v0.7.0
Author is a name with intellectual responsibility. Corporate marks a corporate body or conference name (MARC 110/710/111/711) so BibTeX can brace-protect it -- otherwise BibTeX would split "Food and Agriculture Organization" into two authors on the internal "and".
type BibTeXWriter ¶
type BibTeXWriter struct {
// contains filtered or unexported fields
}
BibTeXWriter writes records as a sequence of BibTeX entries.
func NewBibTeXWriter ¶
func NewBibTeXWriter(w io.Writer) *BibTeXWriter
NewBibTeXWriter returns a Writer that writes BibTeX entries to w.
func (*BibTeXWriter) Write ¶
func (wr *BibTeXWriter) Write(r *codex.Record) error
type Entry ¶
type Entry struct {
Title string
Authors []Author
Year string
Date string
Publisher string
Place string
Edition string
ISBN []string
ISSN []string
Keywords []string
Language string
Abstract string
URL []string
// contains filtered or unexported fields
}
Entry is the bibliographic information extracted from a record, shared by the RIS and BibTeX renderers.
func FromRecord ¶
func FromRecord(r *codex.Record) *Entry
FromRecord extracts citation fields from a MARC record in a single pass.
type RISWriter ¶
type RISWriter struct {
// contains filtered or unexported fields
}
RISWriter writes records as a sequence of RIS records.
func NewRISWriter ¶
NewRISWriter returns a Writer that writes RIS records to w.