csl

package
v0.35.2 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package csl converts citation-style language (CSL) metadata to/from the commonmeta metadata format.

Index

Constants

This section is empty.

Variables

View Source
var CMToCSLMappings = map[string]string{
	"Article":               "article",
	"JournalArticle":        "article-journal",
	"BlogPost":              "post-weblog",
	"Book":                  "book",
	"BookChapter":           "chapter",
	"Collection":            "collection",
	"Dataset":               "dataset",
	"Document":              "document",
	"Entry":                 "entry",
	"Event":                 "event",
	"Figure":                "figure",
	"Image":                 "graphic",
	"LegalDocument":         "legal_case",
	"Manuscript":            "manuscript",
	"Map":                   "map",
	"Audiovisual":           "motion_picture",
	"Patent":                "patent",
	"Performance":           "performance",
	"Journal":               "periodical",
	"PersonalCommunication": "personal_communication",
	"Report":                "report",
	"Review":                "review",
	"Software":              "software",
	"Presentation":          "speech",
	"Standard":              "standard",
	"Dissertation":          "thesis",
	"WebPage":               "webpage",
}
View Source
var CSLToCMMappings = map[string]string{
	"article":                "Article",
	"article-journal":        "JournalArticle",
	"article-magazine":       "Article",
	"article-newspaper":      "Article",
	"bill":                   "LegalDocument",
	"book":                   "Book",
	"broadcast":              "Audiovisual",
	"chapter":                "BookChapter",
	"classic":                "Book",
	"collection":             "Collection",
	"dataset":                "Dataset",
	"document":               "Document",
	"entry":                  "Entry",
	"entry-dictionary":       "Entry",
	"entry-encyclopedia":     "Entry",
	"event":                  "Event",
	"figure":                 "Figure",
	"graphic":                "Image",
	"hearing":                "LegalDocument",
	"interview":              "Document",
	"legal_case":             "LegalDocument",
	"legislation":            "LegalDocument",
	"manuscript":             "Manuscript",
	"map":                    "Map",
	"motion_picture":         "Audiovisual",
	"musical_score":          "Document",
	"pamphlet":               "Document",
	"paper-conference":       "ProceedingsArticle",
	"patent":                 "Patent",
	"performance":            "Performance",
	"periodical":             "Journal",
	"personal_communication": "PersonalCommunication",
	"post":                   "Post",
	"post-weblog":            "BlogPost",
	"regulation":             "LegalDocument",
	"report":                 "Report",
	"review":                 "Review",
	"review-book":            "Review",
	"software":               "Software",
	"song":                   "Audiovisual",
	"speech":                 "Presentation",
	"standard":               "Standard",
	"thesis":                 "Dissertation",
	"treaty":                 "LegalDocument",
	"webpage":                "WebPage",
}

source: https://docs.citationstyles.org/en/stable/specification.html?highlight=book#appendix-iii-types

Functions

func Load added in v0.6.6

func Load(filename string) (commonmeta.Data, error)

Load loads the metadata for a single work from a CSL file

func LoadAll added in v0.6.6

func LoadAll(filename string) ([]commonmeta.Data, error)

LoadAll loads the metadata for a list of works from a CSL file and converts it to the Commonmeta format

func Read added in v0.2.1

func Read(content Content) (commonmeta.Data, error)

Read reads CSL metadata and converts it into Commonmeta metadata.

func ReadAll added in v0.6.6

func ReadAll(content []Content) ([]commonmeta.Data, error)

ReadAll reads a list of CSL metadata and returns a list of works in Commonmeta format

func Write added in v0.2.4

func Write(data commonmeta.Data) ([]byte, error)

Write writes CSL metadata.

func WriteAll added in v0.2.13

func WriteAll(list []commonmeta.Data) ([]byte, error)

WriteAll writes a list of CSL metadata.

Types

type Author added in v0.2.4

type Author struct {
	Family              string `json:"family,omitempty"`
	Given               string `json:"given,omitempty"`
	NonDroppingParticle string `json:"non-dropping-particle,omitempty"`
	Literal             string `json:"literal,omitempty"`
}

Authors represents the author in the CSL item.

type CSL added in v0.2.4

type CSL struct {
	ID       string `json:"id"`
	Type     string `json:"type"`
	Abstract string `json:"abstract,omitempty"`
	Accessed struct {
		DateAsParts []dateutils.DateSlice `json:"date-parts"`
		DateTime    string                `json:"date-time"`
	} `json:"accessed"`
	Author              []Author `json:"author,omitempty"`
	Categories          []string `json:"categories,omitempty"`
	ContainerTitle      string   `json:"container-title,omitempty"`
	ContainerTitleShort string   `json:"container-title-short,omitempty"`
	DOI                 string   `json:"DOI,omitempty"`
	Editor              []Author `json:"editor,omitempty"`
	ISSN                string   `json:"ISSN,omitempty"`
	Issue               string   `json:"issue,omitempty"`
	Issued              struct {
		DateAsParts []dateutils.DateSlice `json:"date-parts"`
		DateTime    string                `json:"date-time"`
	} `json:"issued"`
	Keyword   string `json:"keyword,omitempty"`
	Language  string `json:"language,omitempty"`
	License   string `json:"license,omitempty"`
	Note      string `json:"note,omitempty"`
	Page      string `json:"page,omitempty"`
	PMID      string `json:"PMID,omitempty"`
	Publisher string `json:"publisher,omitempty"`
	Source    string `json:"source,omitempty"`
	Submitted struct {
		DateAsParts []dateutils.DateSlice `json:"date-parts"`
		DateTime    string                `json:"date-time"`
	} `json:"submitted"`
	Title   string `json:"title,omitempty"`
	URL     string `json:"URL,omitempty"`
	Version string `json:"version,omitempty"`
	Volume  string `json:"volume,omitempty"`
}

CSL represents the CSL metadata.

func Convert added in v0.2.4

func Convert(data commonmeta.Data) (CSL, error)

Convert converts commonmeta metadata to CSL JSON.

type Content

type Content struct {
	*CSL
	Publisher json.RawMessage `json:"publisher"`
}

type Publisher added in v0.6.6

type Publisher struct {
	Name string `json:"name,omitempty"`
}

Jump to

Keyboard shortcuts

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