Documentation ¶
Index ¶
Constants ¶
const ( // ErrTypeNotFound represents an entry type not found error. ErrTypeNotFound errorType // ErrFieldNotFound represents a field not found error. ErrFieldNotFound )
Variables ¶
var EntryTypes map[string]*EntryType
EntryTypes holds the list of all entry types loaded.
var TypeNotFoundError *tnfError
TypeNotFoundError is deprecated.
Functions ¶
func FTypesInfo ¶
FTypesInfo writes the information of each entry type to the io.Writer w. The level indicates how much information to show (0 = only labels, 1 = labels and required fields, 2 = labels, required fields, and optional fields.)
Types ¶
type Entry ¶
type Entry struct { Type string `yaml:"type"` Key string `yaml:"key"` Required map[string]string `yaml:"req"` Optional map[string]string `yaml:"opt"` File string `yaml:"file"` Info os.FileInfo `yaml:"-"` }
Entry is the basic object of scholar.
func Convert ¶
Convert changes the type of an entry, parsing all the fields from one type to the other.
If the entry type does not exits, it returns with an ErrTypeNotFound error. If a required field from the output entry type cannot be found on the original entry, the Required field is replaced by an empty string and Convert keeps parsing the entry. An ErrFieldNotFound error is raised as a result, but it is safe to ignore ErrFieldNotFound.
Any field that was Required in the original entry, but it is not on the output entry type, is converted to an Optional field. This ensures back and forth conversion of the same entry without losing information.
func NewEntry ¶
NewEntry returns an empty copy of an entry according to the types of entries loaded.
func (*Entry) Export ¶
Export returns a string with all the information of the entry in the given format.
func (*Entry) FirstAuthorLast ¶
FirstAuthorLast return the lastname of the first author of the entry.
type EntryType ¶
type EntryType struct { Type string Description string `yaml:"desc"` Required map[string]string `yaml:"req"` Optional map[string]string `yaml:"opt"` }
EntryType defines how each entry will be formatted. Each entry has a TYPE of entry, a short DESCRIPTION, REQUIRED fields, and OPTIONAL fields according to BibLaTex documentation.