crosswalk

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package crosswalk holds the small MARC-field helpers shared by the derivative export codecs (mods, dublincore, citation, schemaorg, unimarc): ISBD punctuation trimming, subfield joining, subject assembly, year extraction, and JSON string escaping. Centralizing them keeps a fix (or a change to the punctuation rules) in one place rather than drifting across five packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendJSONString

func AppendJSONString(b []byte, s string) []byte

AppendJSONString appends s to b as a quoted, escaped JSON string, escaping the characters JSON requires and dropping invalid UTF-8 bytes so the output is always well-formed.

func AppendXMLText added in v0.7.0

func AppendXMLText(b []byte, s string) []byte

AppendXMLText appends s to b as escaped XML character data: it escapes the markup-significant runes (& < >) and a carriage return, drops control characters XML 1.0 cannot represent (a lossy export), and drops invalid UTF-8 bytes so the output is always well-formed.

func JoinSub

func JoinSub(f codex.Field, codes, sep string) string

JoinSub joins the ISBD-trimmed values of f's subfields whose codes appear in codes, in field order, separated by sep. Empty values are skipped.

func Subject

func Subject(f codex.Field) string

Subject assembles a subject string from a 6XX field: the topical and subdivision subfields (a, x, y, z, v) in field order, joined with "--", each value trimmed of trailing spaces.

func TrimISBD

func TrimISBD(s string) string

TrimISBD trims trailing whitespace and a single trailing ISBD punctuation mark (one of "/:;,") together with the whitespace before it, the cleanup MARC display data needs when it is repurposed as a plain value.

func Year

func Year(s string) string

Year returns the first four-consecutive-digit run in s (a publication year embedded in a date string), or "" if there is none.

Types

This section is empty.

Jump to

Keyboard shortcuts

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