Documentation ¶
Index ¶
- Constants
- Variables
- func FullPath(fname string) (string, error)
- type BibComposite
- type BibConst
- type BibEntry
- type BibString
- type BibTex
- func (bib *BibTex) AddEntry(entry *BibEntry)
- func (bib *BibTex) AddPreamble(p BibString)
- func (bib *BibTex) AddStringVar(key string, val BibString)
- func (bib *BibTex) GetStringVar(key string) *BibVar
- func (bib *BibTex) Lookup(cite string) (*BibEntry, bool)
- func (bib *BibTex) MakeKeyMap()
- func (bib *BibTex) PrettyString() string
- func (bib *BibTex) RawString() string
- func (bib *BibTex) String() string
- type BibVar
- type ErrParse
- type File
- type Files
- type Lexer
- type Scanner
- type Token
- type TokenPos
Constants ¶
const ATSIGN = 57349
const BAREIDENT = 57359
const COLON = 57350
const COMMA = 57352
const COMMENT = 57346
const DQUOTE = 57356
const EQUAL = 57351
const IDENT = 57360
const LBRACE = 57354
const LPAREN = 57357
const POUND = 57353
const PREAMBLE = 57348
const RBRACE = 57355
const RPAREN = 57358
const STRING = 57347
Variables ¶
var ( // ErrUnexpectedAtsign is an error for unexpected @ in {}. ErrUnexpectedAtsign = errors.New("Unexpected @ sign") // ErrUnknownStringVar is an error for looking up undefined string var. ErrUnknownStringVar = errors.New("Unknown string variable") )
Functions ¶
Types ¶
type BibComposite ¶
type BibComposite []BibString
BibComposite is a composite string, may contain both variable and string.
func NewBibComposite ¶
func NewBibComposite(s BibString) *BibComposite
NewBibComposite creates a new composite with one element.
func (*BibComposite) Append ¶
func (c *BibComposite) Append(s BibString) *BibComposite
Append adds a BibString to the composite
func (*BibComposite) RawString ¶
func (c *BibComposite) RawString() string
RawString returns a raw (bibtex) representation of the composite string.
func (*BibComposite) String ¶
func (c *BibComposite) String() string
type BibConst ¶
type BibConst string
BibConst is a string constant.
func NewBibConst ¶
NewBibConst converts a constant string to BibConst.
type BibEntry ¶
BibEntry is a record of BibTeX record.
func NewBibEntry ¶
NewBibEntry creates a new BibTeX entry.
type BibString ¶
type BibString interface { RawString() string // Internal representation. String() string // Displayed string. }
BibString is a segment of a bib string.
type BibTex ¶
type BibTex struct { Preambles []BibString // List of Preambles Entries []*BibEntry // Items in a bibliography. KeyMap map[string]*BibEntry // fast key lookup map -- made on demand in Lookup StringVar map[string]*BibVar // Map from string variable to string. }
BibTex is a list of BibTeX entries.
func (*BibTex) AddPreamble ¶
AddPreamble adds a preamble to a bibtex.
func (*BibTex) AddStringVar ¶
AddStringVar adds a new string var (if does not exist).
func (*BibTex) GetStringVar ¶
GetStringVar looks up a string by its key.
func (*BibTex) Lookup ¶ added in v1.0.0
Lookup finds CiteName in entries, using fast KeyMap (made on demand) returns nil, false if not found
func (*BibTex) MakeKeyMap ¶ added in v1.0.0
func (bib *BibTex) MakeKeyMap()
MakeKeyMap creates the KeyMap from CiteName to entry
func (*BibTex) PrettyString ¶
PrettyString pretty prints a BibTex.
type BibVar ¶
BibVar is a string variable.
type File ¶ added in v1.0.0
type File struct { File string `desc:"file name -- full path"` BibTex *BibTex `desc:"bibtex data loaded from file"` Mod time.Time `desc:"mod time for loaded bibfile -- to detect updates"` }
File maintains a record for an bibtex file
func (*File) Open ¶ added in v1.0.0
Open [re]opens the given filename, looking on standard BIBINPUTS or TEXINPUTS env var paths if not found locally. If Mod >= mod timestamp on the file, and BibTex is already loaded, then nothing happens (already have it), but otherwise it parses the file and puts contents in BibTex field.
type Files ¶ added in v1.0.0
Files is a map of bibtex files
func (*Files) Open ¶ added in v1.0.0
Open [re]opens the given filename, looking on standard BIBINPUTS or TEXINPUTS env var paths if not found locally. If Mod >= mod timestamp on the file, and BibTex is already loaded, then nothing happens (already have it), but otherwise it parses the file and puts contents in BibTex field.
type Lexer ¶
type Lexer struct { Errors chan error // contains filtered or unexported fields }
Lexer for bibtex.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner is a lexical scanner
func NewScanner ¶
NewScanner returns a new instance of Scanner.