parser

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: BSD-2-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package parser provides markdown parsing and VCTM generation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateIntegrity

func CalculateIntegrity(path string) (string, error)

CalculateIntegrity is a public helper to calculate SRI integrity for a file

func OutputFileName added in v1.3.0

func OutputFileName(baseName, formatName string) string

OutputFileName returns the output filename for a given format

Types

type ClaimDef

type ClaimDef struct {
	// Name is the claim name
	Name string

	// Type is the value type
	Type string

	// Description is the claim description
	Description string

	// Mandatory indicates if the claim is mandatory
	Mandatory bool

	// SD indicates selective disclosure
	SD string

	// SvgId is the ID for SVG template reference
	SvgId string

	// DisplayName is the friendly display label for the claim
	DisplayName string

	// Localizations contains locale-specific display names and descriptions
	Localizations map[string]ClaimLocalization
}

ClaimDef represents a claim definition

type ClaimLocalization added in v1.1.0

type ClaimLocalization struct {
	// Label is the display label in this locale
	Label string

	// Description is the description in this locale
	Description string
}

ClaimLocalization contains localized display information for a claim

type DisplayLocalization added in v1.2.0

type DisplayLocalization struct {
	// Name is the localized credential name
	Name string `yaml:"name"`

	// Description is the localized credential description
	Description string `yaml:"description"`
}

DisplayLocalization contains localized display properties for the credential

type ImageRef

type ImageRef struct {
	// Path is the original path in the markdown
	Path string

	// AltText is the alt text for the image
	AltText string

	// AbsolutePath is the resolved absolute path
	AbsolutePath string
}

ImageRef represents a reference to an image

type ParsedMarkdown

type ParsedMarkdown struct {
	// Title is extracted from the first H1 heading
	Title string

	// Description is extracted from the first paragraph after the title
	Description string

	// Sections contains content organized by section headings
	Sections map[string]string

	// Images contains paths to images found in the markdown
	Images []ImageRef

	// Claims contains claim definitions extracted from the markdown
	Claims map[string]ClaimDef

	// Metadata contains front matter or metadata extracted from the markdown
	Metadata map[string]string

	// DisplayLocalizations contains locale-specific display properties for the credential
	DisplayLocalizations map[string]DisplayLocalization
}

ParsedMarkdown represents the parsed structure from a markdown file

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser parses markdown files and generates VCTM

func NewParser

func NewParser(cfg *config.Config) *Parser

NewParser creates a new parser with the given configuration

func (*Parser) Generate added in v1.3.0

func (p *Parser) Generate(cred *formats.ParsedCredential, formatNames []string) (map[string][]byte, error)

Generate generates output for the specified formats

func (*Parser) GenerateAll added in v1.3.0

func (p *Parser) GenerateAll(cred *formats.ParsedCredential) (map[string][]byte, error)

GenerateAll generates output for all registered formats

func (*Parser) Parse

func (p *Parser) Parse(inputPath string) (*ParsedMarkdown, error)

Parse parses a markdown file and returns the parsed structure

func (*Parser) ParseContent

func (p *Parser) ParseContent(content []byte, basePath string) (*ParsedMarkdown, error)

ParseContent parses markdown content and returns the parsed structure

func (*Parser) ParseContentToCredential added in v1.3.0

func (p *Parser) ParseContentToCredential(content []byte, basePath string) (*formats.ParsedCredential, error)

ParseContentToCredential parses markdown content and returns a ParsedCredential

func (*Parser) ParseToCredential added in v1.3.0

func (p *Parser) ParseToCredential(inputPath string) (*formats.ParsedCredential, error)

ParseToCredential parses a markdown file and returns a ParsedCredential

func (*Parser) ToCredential added in v1.3.0

func (p *Parser) ToCredential(parsed *ParsedMarkdown) *formats.ParsedCredential

ToCredential converts ParsedMarkdown to the format-agnostic ParsedCredential

func (*Parser) ToVCTM

func (p *Parser) ToVCTM(parsed *ParsedMarkdown) (*vctm.VCTM, error)

ToVCTM converts parsed markdown to a VCTM document

Jump to

Keyboard shortcuts

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