bibtex

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2018 License: BSD-3-Clause Imports: 6 Imported by: 6

README

bibtex

A Golang BibTeX package and collection of related command line utilities.

bibtex is a golang package for working with BibTeX files. It includes bibfilter and bibmerge which are a command line utilities for working with BibTeX files (e.g. removing comments before importing into JabRef, merge bib lists). bibtex also can be compiled to JavaScript via GopherJS. A web version of bibfiter and bibmerge commands is available in the webapp directory. The command line utilities and webapp use the same bibtex golang package for implementation.

Compiled versions are provided for Linux (amd64), Mac OS X (amd64), Windows 10 (amd64) and Raspbian (ARM7). See https://github.com/caltechlibrary/bibtex/releases.

bibfilter

Output my.bib file without comment entries

  bibfilter -exclude=comment my.bib

Output only articles from my.bib

    bibfilter -include=article my.bib

Output only articles and conference proceedings from my.bib

    bibfilter -include=article,inproceedings my.bib

bibmerge

Output a new bibtex file based on the contents of two other bibtex files.

Join of two bibtex files

    bibmerge -join mybib1.bib mybib2.bib

Intersection of two bibtex files

    bibmerge -intersect mybib1.bib mybib2.bib

Difference (A - B), includes items in A but not found in B of two bibtex files.

    bibmerge -diff mybib1.bib mybib2.bib

Excluse difference (symmetric difference, inverse of intersection) of two bibtex files

    bibmerge -exclusive mybib1.bib mybib2.bib

Symmetric versus asymmetric differences

  1. (asymmetric) (A - B)
    • Content is in A but NOT in B
    • Content unique to B would not be included
  2. (symmetric) (A - B) Union (B - A)
    • Inverse of the the intersection of A and B
    • Content unique to A and the content unique to B are included

Documentation

Overview

Package bibtex is a quick and dirty BibTeX parser for working with a Bibtex citation

@author R. S. Doiel, <rsdoiel@caltech.edu>

Copyright (c) 2016, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Index

Constants

View Source
const (
	// Version of BibTeX package
	Version = `v0.0.8`

	// LicenseText holds the text for displaying license info
	LicenseText = `` /* 1530-byte string literal not displayed */

	// DefaultInclude list
	DefaultInclude = "" /* 150-byte string literal not displayed */

	// A template for printing an element
	ElementTmplSrc = `` /* 132-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func Bib

func Bib(token *tok.Token, buf []byte) (*tok.Token, []byte)

Bib is a niave BibTeX Tokenizer function Note: there is an English bias in the AlphaNumeric check

func Contains added in v0.0.6

func Contains(elemList []*Element, target *Element) bool

Contains checks an array of Elements for a specific element

func Equal added in v0.0.6

func Equal(elem1, elem2 *Element) bool

Equal compares two Element structures and sees if the contents agree

func NotEqual added in v0.0.6

func NotEqual(elem1, elem2 *Element) bool

NotEqual compares two element structures and see if the contents disagree

Types

type ByKey added in v0.0.6

type ByKey []string

ByKey struct is for sorting Element Keys

func (ByKey) Len added in v0.0.6

func (a ByKey) Len() int

Len of ByKey array

func (ByKey) Less added in v0.0.6

func (a ByKey) Less(i, j int) bool

Less return the lesser of ByKey array elements

func (ByKey) Swap added in v0.0.6

func (a ByKey) Swap(i, j int)

Swap of ByKey array elements

type Element

type Element struct {
	XMLName xml.Name          `json:"-"`
	ID      string            `xml:"id" json:"id"`
	Type    string            `xml:"type" json:"type"`
	Keys    []string          `xml:"keys" json:"keys"`
	Tags    map[string]string `xml:"tags" json:"tags"`
}

Generic Element

func Clone added in v0.0.6

func Clone(elem *Element) *Element

Clone creates a new Element based on an existing element

func Diff added in v0.0.6

func Diff(elemList1, elemList2 []*Element) []*Element

Diff creates a new Element Array of all the elements in elemList1 an not in elemList2

func Exclusive added in v0.0.6

func Exclusive(elemList1, elemList2 []*Element) []*Element

Exclusive create a new Element Array with elements that only exist in elemList1 or elemList2

func Intersect added in v0.0.6

func Intersect(elemList1, elemList2 []*Element) []*Element

Intersect create a new Element Array of elements in both elemList1 and elemList2

func Join added in v0.0.6

func Join(elemList1, elemList2 []*Element) []*Element

Join create a new Element array by combining to Element arrays without creating duplicate entries

func Parse

func Parse(buf []byte) ([]*Element, error)

Parse a BibTeX file into appropriate structures

func (*Element) Set added in v0.0.8

func (element *Element) Set(key, value string) bool

Set adds/updates an attribute (e.g. author, title, year) to an element

func (*Element) String

func (element *Element) String() string

String renders a single BibTeX element

type Elements

type Elements []*Element

type TagTypes

type TagTypes struct {
	Required []string
	Optional []string
}

Directories

Path Synopsis
cmd
bibfilter
bibfilter reads a bibfile and writes it out.
bibfilter reads a bibfile and writes it out.
bibmerge
bibset reads in two bibfiles and writes out new one based on operation selected (e.g.
bibset reads in two bibfiles and writes out new one based on operation selected (e.g.
bibscrape
bibscrape - scrape a plain text file and render a pseudo BibTeX record that will import into JabRef.
bibscrape - scrape a plain text file and render a pseudo BibTeX record that will import into JabRef.
bibtex/scrape.go is a plain text scraping package related to creating BibTeX output @author R. S. Doiel, <rsdoiel@caltech.edu> Copyright (c) 2016, Caltech All rights not granted herein are expressly reserved by Caltech.
bibtex/scrape.go is a plain text scraping package related to creating BibTeX output @author R. S. Doiel, <rsdoiel@caltech.edu> Copyright (c) 2016, Caltech All rights not granted herein are expressly reserved by Caltech.
Package tok is a niave tokenizer @author R. S. Doiel, <rsdoiel@caltech.edu> Copyright (c) 2016, Caltech All rights not granted herein are expressly reserved by Caltech.
Package tok is a niave tokenizer @author R. S. Doiel, <rsdoiel@caltech.edu> Copyright (c) 2016, Caltech All rights not granted herein are expressly reserved by Caltech.
webapp.go a Web Application of bibtex package @author R. S. Doiel, <rsdoiel@caltech.edu> Copyright (c) 2016, Caltech All rights not granted herein are expressly reserved by Caltech.
webapp.go a Web Application of bibtex package @author R. S. Doiel, <rsdoiel@caltech.edu> Copyright (c) 2016, Caltech All rights not granted herein are expressly reserved by Caltech.

Jump to

Keyboard shortcuts

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