citation

package
v0.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 6 Imported by: 0

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 BibTeX

func BibTeX(r *codex.Record) ([]byte, error)

BibTeX converts a record to a BibTeX entry.

func RIS

func RIS(r *codex.Record) ([]byte, error)

RIS converts a record to an RIS record.

func WriteBibTeXFile

func WriteBibTeXFile(path string, records []*codex.Record) error

WriteBibTeXFile writes every record to the named file in BibTeX format.

func WriteRISFile

func WriteRISFile(path string, records []*codex.Record) error

WriteRISFile writes every record to the named file in RIS format.

Types

type Author added in v0.7.0

type Author struct {
	Name      string
	Corporate bool
}

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.

func (*Entry) BibTeX

func (e *Entry) BibTeX() []byte

BibTeX renders the entry as a BibTeX entry.

func (*Entry) RIS

func (e *Entry) RIS() []byte

RIS renders the entry as an RIS record.

type RISWriter

type RISWriter struct {
	// contains filtered or unexported fields
}

RISWriter writes records as a sequence of RIS records.

func NewRISWriter

func NewRISWriter(w io.Writer) *RISWriter

NewRISWriter returns a Writer that writes RIS records to w.

func (*RISWriter) Write

func (wr *RISWriter) Write(r *codex.Record) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL