Documentation
¶
Index ¶
- Constants
- func FmtHelp(src string, appName string, version string, releaseDate string, ...) string
- func GetObject(identifier string, u string, validate ValidatorFunc) (interface{}, bool)
- func GetObjectDOI(doi string) (interface{}, bool)
- func GetObjectISBN(isbn string) (interface{}, bool)
- func NormalizeArXivID(arxivID string) string
- func NormalizeDOI(doi string) string
- func NormalizeDOIShort(doi string) string
- func NormalizeEAN(ean string) string
- func NormalizeEMAIL(email string) string
- func NormalizeFundRefID(id string) string
- func NormalizeISBN(isbn string) string
- func NormalizeISNI(isni string) string
- func NormalizeISSN(issn string) string
- func NormalizeLCNAF(id string) string
- func NormalizeORCID(orcid string) string
- func NormalizePMCID(pmcid string) string
- func NormalizePMID(pubMedID string) string
- func NormalizeRAiD(raid string) string
- func NormalizeRAiDShort(raid string) string
- func NormalizeROR(ror string) string
- func NormalizeSNAC(id string) string
- func NormalizeTEL(tel string) string
- func NormalizeUUID(uuid string) string
- func NormalizeVIAF(id string) string
- func ValidateArXivID(arxivID string) bool
- func ValidateDOI(doi string) bool
- func ValidateDOIShort(doi string) bool
- func ValidateEAN(ean string) bool
- func ValidateEMAIL(email string) bool
- func ValidateFundRefID(id string) bool
- func ValidateISBN(isbn string) bool
- func ValidateISNI(isni string) bool
- func ValidateISSN(issn string) bool
- func ValidateLCNAF(id string) bool
- func ValidateORCID(orcid string) bool
- func ValidatePMCID(pmcid string) bool
- func ValidatePMID(pubMedID string) bool
- func ValidateRAiD(raid string) bool
- func ValidateRAiDShort(raid string) bool
- func ValidateROR(ror string) bool
- func ValidateSNAC(id string) bool
- func ValidateTEL(tel string) bool
- func ValidateUUID(uuid string) bool
- func ValidateVIAF(id string) bool
- func VerifyArXivID(arxiv string) bool
- func VerifyDOI(doi string) bool
- func VerifyFundRefID(id string) bool
- func VerifyISBN(isbn string) bool
- func VerifyISNI(isni string) bool
- func VerifyISSN(issn string) bool
- func VerifyIdentifier(identifier string, u string, validate ValidatorFunc) bool
- func VerifyLCNAF(id string) bool
- func VerifyORCID(orcid string) bool
- func VerifyPMCID(pmcid string) bool
- func VerifyPMID(pmid string) bool
- func VerifyROR(ror string) bool
- func VerifySNAC(id string) bool
- func VerifyVIAF(id string) bool
- type NormalizorFunc
- type ValidatorFunc
- type VerifyFunc
Constants ¶
const ( // Version number of release Version = "0.1.1" // ReleaseDate, the date version.go was generated ReleaseDate = "2026-06-11" // ReleaseHash, the Git hash when version.go was generated ReleaseHash = "5bbf50d" LicenseText = `` /* 1525-byte string literal not displayed */ )
const ARXIVPattern = `^arxiv:(\d{4}\.\d{4,5}(v\d+)?|[a-z\-]+/\d{7}(v\d+)?)$`
ARXIVPattern matches a normalized arXiv identifier in either the new (YYMM.NNNNN) or old (archive/YYMMNNN) form, with an optional version suffix.
const DOIPattern = `^https://doi\.org/10\.\d{4,9}/[^\s]+$`
DOIPattern is the regular expression pattern matching a normalized (extended/full URL) DOI.
const DOIPrefix = "https://doi.org/"
DOIPrefix is the canonical resolver URL prefix for a DOI.
const DOIShortPattern = `^10\.\d{4,9}/[^\s]+$`
DOIShortPattern is the regular expression pattern matching a normalized short-form (bare) DOI.
const EMAILPattern = `^(?:"?([^"]*)"?\s)?(?:<?(.+@[^>]+)>?)$`
EMAILPattern is the regular expression pattern matching a normalized email address.
const ISBN10Pattern = `^(?:\d[ |-]?){9}[\d|X]$`
ISBN10Pattern matches an ISBN-10 with optional space or hyphen separators between digits.
const LCNAFPattern = `^[a-zA-Z0-9]+$`
LCNAFPattern matches a normalized Library of Congress Name Authority File identifier.
const MDToolsHelpText = `` /* 1444-byte string literal not displayed */
MDToolsHelpText holds the man page style documentation for the mdtools command line program.
const NewARXIVPattern = `^arxiv:\d{4}\.\d{4,5}(v\d+)?$`
NewARXIVPattern matches a normalized arXiv identifier in the new (post March 2007) YYMM.NNNNN form.
const ORCIDPattern = `^(\d{4}-\d{4}-\d{4}-\d{3}[\dX])$`
ORCIDPattern matches a normalized ORCID iD.
const OldARXIVPattern = `^arxiv:[a-z\-]+/\d{7}(v\d+)?$`
OldARXIVPattern matches a normalized arXiv identifier in the old (pre March 2007) archive/YYMMNNN form.
const PMCIDPattern = `^PMC\d+$`
PMCIDPattern matches a normalized PubMed Central identifier.
const PMIDPattern = `^[0-9]+$`
PMIDPattern matches a normalized PubMed identifier (digits only).
const RAiDPattern = `^https://raid\.org/10\.\d{4,9}/[^\s]+$`
RAiDPattern is the regular expression pattern matching a normalized (extended/full URL) RAiD.
RAiDs are issued as DOIs via DataCite, so this is the same shape as DOIPattern (10.<4-9 digit registrant code>/<suffix>) under the raid.org resolver host. See dev-notes/decisions_RAiD_support.md D8.
const RAiDPrefix = "https://raid.org/"
RAiDPrefix is the canonical resolver URL prefix for a RAiD.
const RAiDShortPattern = `^10\.\d{4,9}/[^\s]+$`
RAiDShortPattern is the regular expression pattern matching a normalized short-form (bare) RAiD. Identical to DOIShortPattern, since RAiDs are DOI-shaped. See dev-notes/decisions_RAiD_support.md D8.
const RORPattern = `^https://ror\.org/0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$|^0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$`
RORPattern matches a normalized ROR identifier, either as a full https://ror.org/ URL or as a bare ROR ID.
const RORPrefix = "https://ror.org/"
RORPrefix is the canonical URL prefix for a ROR identifier.
const SNACPattern = `^\d+$`
SNACPattern matches a normalized SNAC identifier, which is numeric.
const TELPattern = `^\+?(\d{1,3})?[-.\s]?(\(?\d{1,4}\)?)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}$`
TELPattern is a permissive regular expression pattern for telephone numbers in a variety of common formats.
const VIAFPattern = `^\d+$`
VIAFPattern matches a normalized VIAF identifier, which is numeric.
Variables ¶
This section is empty.
Functions ¶
func FmtHelp ¶
func FmtHelp(src string, appName string, version string, releaseDate string, releaseHash string) string
FmtHelp lets you process a text block with simple curly brace markup.
func GetObject ¶
func GetObject(identifier string, u string, validate ValidatorFunc) (interface{}, bool)
GetObject is a generic retrieval of a JSON value from a remote source. It validates identifier before fetching u. The second return value is false if validation fails, the request fails, the response is not a 2xx, or the response body cannot be parsed as JSON. The decoded value may be a map, slice, or scalar depending on what u returns.
func GetObjectDOI ¶
GetObjectDOI retrieves a DOI record from CrossRef, falling back to DataCite if CrossRef does not have it.
Example:
doi := "10.22002/bv2pv-2b295"
obj, ok := GetObjectDOI(doi)
if !ok {
fmt.Printf("%s did not return an object, maybe it is not valid\n", doi)
} else {
fmt.Printf("%s returns an object %v\n", doi, obj)
}
func GetObjectISBN ¶
GetObjectISBN retrieves an ISBN record from Open Library.
func NormalizeArXivID ¶
NormalizeArXivID trims whitespace from arxivID and lower cases it.
Example:
id := NormalizeArXivID("ARXIV:2412.03631")
// id == "arxiv:2412.03631"
func NormalizeDOI ¶
NormalizeDOI normalizes a DOI to its extended (full URL) form.
Example:
doi := NormalizeDOI("10.22002/bv2pv-2b295")
// doi == "https://doi.org/10.22002/bv2pv-2b295"
func NormalizeDOIShort ¶
NormalizeDOIShort normalizes a DOI to its short form by removing extraneous characters and enforcing lowercase.
Example:
doi := NormalizeDOIShort("https://www.doi.org/10.22002/bv2pv-2b295")
// doi == "10.22002/bv2pv-2b295"
func NormalizeEAN ¶
NormalizeEAN trims whitespace from ean and removes any non-digit characters.
Example:
ean := NormalizeEAN("9780201544282")
// ean == "9780201544282"
func NormalizeEMAIL ¶
NormalizeEMAIL trims whitespace from email and removes any internal whitespace.
Example:
email := NormalizeEMAIL(" jane.doe@example.edu ")
// email == "jane.doe@example.edu"
func NormalizeFundRefID ¶
NormalizeFundRefID trims whitespace from id and lower cases it.
Example:
id := NormalizeFundRefID("10.13039/100000001")
// id == "10.13039/100000001"
func NormalizeISBN ¶
NormalizeISBN removes hyphens and whitespace from isbn and reformats 10 or 13 digit ISBNs with hyphens.
Example:
isbn := NormalizeISBN("978-3-16-148410-0")
// isbn == "978-3-16-14841-00"
func NormalizeISNI ¶
NormalizeISNI removes whitespace and hyphens from isni and reformats it as four space-separated groups of four digits.
func NormalizeISSN ¶
NormalizeISSN removes any non-digit characters from issn and reformats it as NNNN-NNNN.
Example:
issn := NormalizeISSN("1058-6180")
// issn == "1058-6180"
func NormalizeLCNAF ¶
NormalizeLCNAF trims whitespace from id.
func NormalizeORCID ¶
NormalizeORCID strips whitespace, hyphens, and any "https://orcid.org/" prefix from orcid, then formats the remaining 16 characters as four hyphen-separated groups of four.
func NormalizePMCID ¶
NormalizePMCID trims whitespace from pmcid, upper cases it, and adds a leading "PMC" if pmcid does not already start with one.
func NormalizePMID ¶
NormalizePMID removes a leading "pmid:" label and surrounding whitespace from pubMedID.
func NormalizeRAiD ¶
NormalizeRAiD normalizes a RAiD to its extended (full URL) form.
Example:
raid := NormalizeRAiD("10.26259/0e59e9a5")
// raid == "https://raid.org/10.26259/0e59e9a5"
func NormalizeRAiDShort ¶
NormalizeRAiDShort normalizes a RAiD to its short form by removing extraneous characters and enforcing lowercase.
Example:
raid := NormalizeRAiDShort("https://raid.org/10.26259/0e59e9a5")
// raid == "10.26259/0e59e9a5"
func NormalizeROR ¶
NormalizeROR trims whitespace from ror, lower cases it, and ensures it has the RORPrefix.
func NormalizeTEL ¶
NormalizeTEL formats tel based on the number of digits it contains. If the digit count does not match a recognized length, tel is returned unchanged.
func NormalizeUUID ¶
NormalizeUUID lower cases uuid and removes any whitespace.
func ValidateArXivID ¶
ValidateArXivID normalizes arxivID then validates it against ARXIVPattern.
func ValidateDOI ¶
ValidateDOI validates the extended (full URL) form of a DOI.
func ValidateDOIShort ¶
ValidateDOIShort validates the short (bare) form of a DOI.
func ValidateEAN ¶
ValidateEAN validates an EAN (International Article Number, European Article Number, Japanese Article Number) in either its 13 digit or 8 digit form.
func ValidateEMAIL ¶
ValidateEMAIL validates the form of email after normalizing it.
func ValidateFundRefID ¶
ValidateFundRefID normalizes id then validates it against fundRefPattern.
func ValidateISBN ¶
ValidateISBN validates isbn as either an ISBN-10 or ISBN-13.
func ValidateISNI ¶
ValidateISNI validates the form and checksum of isni.
func ValidateISSN ¶
ValidateISSN normalizes issn then validates its checksum digit.
func ValidateLCNAF ¶
ValidateLCNAF normalizes id then validates it against LCNAFPattern.
func ValidateORCID ¶
ValidateORCID normalizes orcid, checks its form against ORCIDPattern, and verifies its ISO 7064 Mod 11-2 checksum digit.
func ValidatePMCID ¶
ValidatePMCID normalizes pmcid then validates it against PMCIDPattern.
func ValidatePMID ¶
ValidatePMID normalizes pubMedID then validates it against PMIDPattern.
func ValidateRAiD ¶
ValidateRAiD validates the extended (full URL) form of a RAiD.
func ValidateRAiDShort ¶
ValidateRAiDShort validates the short (bare) form of a RAiD.
func ValidateROR ¶
ValidateROR normalizes ror then validates it against RORPattern.
func ValidateSNAC ¶
ValidateSNAC normalizes id then validates it against SNACPattern.
func ValidateUUID ¶
ValidateUUID normalizes uuid then validates its form.
func ValidateVIAF ¶
ValidateVIAF normalizes id then validates it against VIAFPattern.
func VerifyArXivID ¶
VerifyArXivID verifies an arXiv identifier exists via the export.arxiv.org API. The identifier is normalized before verifying.
func VerifyDOI ¶
VerifyDOI verifies a DOI is registered via the DOI handle system (doi.org).
Example:
doi := "10.22002/bv2pv-2b295"
if VerifyDOI(doi) {
fmt.Printf("%s appears valid\n", doi)
} else {
fmt.Printf("%s is not valid\n", doi)
}
func VerifyFundRefID ¶
VerifyFundRefID verifies a FundRef ID exists via CrossRef's API. The identifier is normalized before verifying.
func VerifyISBN ¶
VerifyISBN verifies an ISBN exists via Open Library. The identifier is normalized before verifying.
func VerifyISNI ¶
VerifyISNI verifies an ISNI exists via isni.org. The identifier is normalized before verifying.
func VerifyISSN ¶
VerifyISSN verifies an ISSN exists via portal.issn.org. The identifier is normalized before verifying.
func VerifyIdentifier ¶
func VerifyIdentifier(identifier string, u string, validate ValidatorFunc) bool
VerifyIdentifier attempts to retrieve an object from a remote source. It validates identifier first; if validate returns false, or the GET to u fails or does not return a 2xx status, it returns false.
func VerifyLCNAF ¶
VerifyLCNAF verifies an LCNAF ID exists via id.loc.gov. The identifier is normalized before verifying.
func VerifyORCID ¶
VerifyORCID verifies an ORCID iD exists via orcid.org. The identifier is normalized before verifying.
func VerifyPMCID ¶
VerifyPMCID verifies a PMCID exists via www.ncbi.nlm.nih.gov/pmc. The identifier is normalized before verifying.
func VerifyPMID ¶
VerifyPMID verifies a PMID exists via pubmed.ncbi.nlm.nih.gov. The identifier is normalized before verifying.
func VerifyROR ¶
VerifyROR verifies a ROR identifier exists via ror.org. The identifier is normalized (and resolves directly to its ror.org URL) before verifying.
func VerifySNAC ¶
VerifySNAC verifies a SNAC ID exists via the SNAC Cooperative website. The identifier is normalized before verifying.
func VerifyVIAF ¶
VerifyVIAF verifies a VIAF ID exists via viaf.org. The identifier is normalized before verifying.
Types ¶
type NormalizorFunc ¶
NormalizorFunc returns an identifier in a regularized format.
type ValidatorFunc ¶
ValidatorFunc checks if the form of an identifier string is valid.
type VerifyFunc ¶
VerifyFunc checks with an authoritative source that an identifier exists.
Source Files
¶
- arxiv.go
- arxiv_record.go
- doi.go
- doi_record.go
- ean.go
- email.go
- fundref.go
- fundref_record.go
- helptext.go
- isbn.go
- isbn_record.go
- isni.go
- isni_record.go
- issn.go
- issn_record.go
- lcnaf.go
- lcnaf_record.go
- orcid.go
- orcid_record.go
- pmcid.go
- pmcid_record.go
- pmid.go
- pmid_record.go
- raid.go
- ror.go
- ror_record.go
- snac.go
- snac_record.go
- tel.go
- utility.go
- uuid.go
- version.go
- viaf.go
- viaf_record.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
mdtools
command
mdtools is a command line tool for normalizing, validating and verifying scholarly and bibliographic identifiers (ArXiv, DOI, ISBN, ORCID, ROR, etc.).
|
mdtools is a command line tool for normalizing, validating and verifying scholarly and bibliographic identifiers (ArXiv, DOI, ISBN, ORCID, ROR, etc.). |