md2html

package
v1.20250729.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const CatsSeriesName = "cats"

Variables

View Source
var AutoIdsMap = map[string]func(parser goldmark.Markdown, sys_ids []string) parser.IDs{}
View Source
var ErrBadAutoIdsType = errors.New("bad auto IDs type")
View Source
var ErrInvalidFrontMatter = errors.New("invalid front matter")
View Source
var ErrInvalidSmCardParam = errors.New("invalid sm_card_config parameter")

Functions

func FindHtmlIds added in v1.20250729.0

func FindHtmlIds(r io.Reader) ([]string, error)

func NewAutoIds added in v1.20250513.0

func NewAutoIds(parser goldmark.Markdown, id_type string, sys_ids []string) (parser.IDs, error)

func NewGfmIDs

func NewGfmIDs(p goldmark.Markdown, sys_ids []string) parser.IDs

func NewParserExts added in v1.20250513.0

func NewParserExts(mc *MdConfig) []goldmark.Extender

func NewSafeIDs

func NewSafeIDs(p goldmark.Markdown, sys_ids []string) parser.IDs

Types

type AlertTitleMapping added in v1.20250513.0

type AlertTitleMapping alerts.TitleHtmlMapping

func (*AlertTitleMapping) Initialize added in v1.20250513.0

func (ppm *AlertTitleMapping) Initialize()

func (*AlertTitleMapping) MakeNew added in v1.20250513.0

func (_ *AlertTitleMapping) MakeNew() *AlertTitleMapping

func (*AlertTitleMapping) UnmarshalTOML added in v1.20250513.0

func (thm *AlertTitleMapping) UnmarshalTOML(decode func(interface{}) error) error

type AlertsOptions added in v1.20250513.0

type AlertsOptions struct {
	TitleMapping upath.Import[*AlertTitleMapping] `toml:",omitempty"`
}

type AudioOpt

type AudioOpt struct {
	SiteId string
	Host   string
	Path   string         `toml:",omitempty"`
	Regex  *regexp.Regexp `toml:",omitempty"`
}

func (*AudioOpt) UnmarshalTOML

func (ao *AudioOpt) UnmarshalTOML(decode func(interface{}) error) error

type AutoIdsOptions

type AutoIdsOptions struct {
	Type string `toml:",omitempty"`
}

type CustomPageConfig added in v1.20250513.0

type CustomPageConfig struct {
	FrontMatter FrontMatterConfig `toml:",omitempty"`
	SmCard      SmCardConfig      `toml:",omitempty"`
	LinkMenu    LinkMenuConfig    `toml:",omitempty"`
	PrintPaper  PrintPaperConfig  `toml:",omitempty"`
	CustomParam CustomParamConfig `toml:",omitempty"`

	PageStyle string `toml:",omitempty"`
	// contains filtered or unexported fields
}

func (*CustomPageConfig) Initialize added in v1.20250513.0

func (cpc *CustomPageConfig) Initialize()

func (*CustomPageConfig) MakeNew added in v1.20250513.0

func (_ *CustomPageConfig) MakeNew() *CustomPageConfig

func (*CustomPageConfig) UnmarshalTOML added in v1.20250513.0

func (cpc *CustomPageConfig) UnmarshalTOML(decode func(interface{}) error) error

type CustomParam added in v1.20250513.0

type CustomParam map[string]any

type CustomParamConfig added in v1.20250513.0

type CustomParamConfig struct {
	Default CustomParam `toml:",omitempty"`
}

type EmbedOptions

type EmbedOptions struct {
	Rules upath.Import[*EmbedRules] `toml:",omitempty"`
}

type EmbedRules

type EmbedRules struct {
	AudioExt []string    `toml:",omitempty"`
	VideoExt []string    `toml:",omitempty"`
	Video    []VideoOpt  `toml:",omitempty"`
	Audio    []AudioOpt  `toml:",omitempty"`
	Iframe   []IframeOpt `toml:",omitempty"`
	// contains filtered or unexported fields
}

func (*EmbedRules) Initialize

func (er *EmbedRules) Initialize()

func (*EmbedRules) IsZero

func (er *EmbedRules) IsZero() bool

func (*EmbedRules) MakeNew

func (_ *EmbedRules) MakeNew() *EmbedRules

func (*EmbedRules) UnmarshalTOML

func (er *EmbedRules) UnmarshalTOML(decode func(interface{}) error) error

type EmojiConfig

type EmojiConfig struct {
	Emoji   string
	Aliases []string
}

type EmojiMapping

type EmojiMapping map[string]*EmojiConfig

func (*EmojiMapping) Initialize

func (em *EmojiMapping) Initialize()

func (*EmojiMapping) MakeNew

func (_ *EmojiMapping) MakeNew() *EmojiMapping

func (*EmojiMapping) UnmarshalTOML

func (em *EmojiMapping) UnmarshalTOML(decode func(interface{}) error) error

type EmojiOptions

type EmojiOptions struct {
	Mapping upath.Import[*EmojiMapping] `toml:",omitempty"`
}

type ExtFlags

type ExtFlags struct {
	Table          bool `toml:",omitempty"`
	Strikethrough  bool `toml:",omitempty"`
	TaskList       bool `toml:",omitempty"`
	DefinitionList bool `toml:",omitempty"`
	Footnote       bool `toml:",omitempty"`
	Autolinks      bool `toml:",omitempty"`
	Cjk            bool `toml:",omitempty"`
	Emoji          bool `toml:",omitempty"`
	Highlight      bool `toml:",omitempty"`
	Math           bool `toml:",omitempty"`
	Mermaid        bool `toml:",omitempty"`
	GeoMap         bool `toml:",omitempty"`
	Embed          bool `toml:",omitempty"`
	Alerts         bool `toml:",omitempty"`
}

type FootnoteOptions

type FootnoteOptions struct {
	BacklinkHTML string `toml:",omitempty"`
}

type FrontMatterConfig added in v1.20250513.0

type FrontMatterConfig struct {
	Yaml bool `toml:",omitempty"`
	Toml bool `toml:",omitempty"`
	Json bool `toml:",omitempty"`

	UsedForHtml bool `toml:",omitempty"`
	UsedForText bool `toml:",omitempty"`
}

func (*FrontMatterConfig) IsEnabled added in v1.20250513.0

func (fmc *FrontMatterConfig) IsEnabled() bool

func (*FrontMatterConfig) TrimAndParse added in v1.20250513.0

func (fmc *FrontMatterConfig) TrimAndParse(bin []byte) ([]byte, *FrontMatterParam, error)

type FrontMatterParam added in v1.20250513.0

type FrontMatterParam struct {
	Product           string  `yaml:"product,omitempty" toml:"product,omitempty" json:"product,omitempty"`
	Title             string  `yaml:"title,omitempty" toml:"title,omitempty" json:"title,omitempty"`
	MarkdownConfig    string  `yaml:"markdown_config,omitempty" toml:"markdown_config,omitempty" json:"markdown_config,omitempty"`
	ThemeStyle        string  `yaml:"theme_style,omitempty" toml:"theme_style,omitempty" json:"theme_style,omitempty"`
	LocationNavi      string  `yaml:"location_navi,omitempty" toml:"location_navi,omitempty" json:"location_navi,omitempty"`
	TocNavi           string  `yaml:"toc_navi,omitempty" toml:"toc_navi,omitempty" json:"toc_navi,omitempty"`
	PageStyle         string  `yaml:"page_style,omitempty" toml:"page_style,omitempty" json:"page_style,omitempty"`
	DirectoryViewMode string  `yaml:"directory_view_mode,omitempty" toml:"directory_view_mode,omitempty" json:"directory_view_mode,omitempty"`
	PaperType         string  `yaml:"paper_type,omitempty" toml:"paper_type,omitempty" json:"paper_type,omitempty"`
	PrintZoom         float32 `yaml:"print_zoom,omitempty" toml:"print_zoom,omitempty" json:"print_zoom,omitempty"`

	SmCard      SmCardParam `yaml:"sm_card,omitempty" toml:"sm_card,omitempty" json:"sm_card,omitempty"`
	CustomParam CustomParam `yaml:"custom_param,omitempty" toml:"custom_param,omitempty" json:"custom_param,omitempty"`
	LinkMenu    []Link      `yaml:"link_menu,omitempty" toml:"link_menu,omitempty" json:"link_menu,omitempty"`

	Config *FrontMatterConfig `yaml:"-" toml:"-" json:"-"`
}

type GfmIDs

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

func (*GfmIDs) Generate

func (ids *GfmIDs) Generate(value []byte, kind ast.NodeKind) []byte

func (*GfmIDs) Put

func (ids *GfmIDs) Put(value []byte)
type Head struct {
	Id    string
	Text  string
	Level int
}

type IframeOpt

type IframeOpt struct {
	SiteId string
	Host   string
	Type   string
	Path   string         `toml:",omitempty"`
	Query  string         `toml:",omitempty"`
	Regex  *regexp.Regexp `toml:",omitempty"`
	Player string
}

func (*IframeOpt) UnmarshalTOML

func (ifo *IframeOpt) UnmarshalTOML(decode func(interface{}) error) error
type Link struct {
	Label string `yaml:"label,omitempty" toml:"label,omitempty" json:"label,omitempty"`
	Url   string `yaml:"url,omitempty" toml:"url,omitempty" json:"url,omitempty"`
}

func (*Link) UnmarshalTOML added in v1.20250513.0

func (l *Link) UnmarshalTOML(decode func(interface{}) error) error

func (*Link) UnmarshalYAML added in v1.20250513.0

func (l *Link) UnmarshalYAML(src []byte) error

type LinkMenuConfig added in v1.20250513.0

type LinkMenuConfig struct {
	Default []Link `toml:",omitempty"`
}

type Md2Html

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

func NewMd2Html

func NewMd2Html(cfg *Md2HtmlConfig) *Md2Html

func (*Md2Html) Convert

func (m2h *Md2Html) Convert(md []byte) ([]byte, []byte, []byte, error)

type Md2HtmlConfig added in v1.20250729.0

type Md2HtmlConfig struct {
	MdConfig  *MdConfig
	SystemIds []string
}

type MdConfig

type MdConfig struct {
	Extension ExtFlags
	AutoIds   AutoIdsOptions  `toml:",omitempty"`
	Footnote  FootnoteOptions `toml:",omitempty"`
	Emoji     EmojiOptions    `toml:",omitempty"`
	Embed     EmbedOptions    `toml:",omitempty"`
	Alerts    AlertsOptions   `toml:",omitempty"`

	ModTime time.Time `toml:"-"`
	// contains filtered or unexported fields
}

func NewMdConfig added in v1.20250513.0

func NewMdConfig(fsys fs.FS, name string) (*MdConfig, error)

func NewMdConfigDefault

func NewMdConfigDefault() *MdConfig

func (*MdConfig) Initialize

func (mc *MdConfig) Initialize()

func (*MdConfig) MakeNew

func (_ *MdConfig) MakeNew() *MdConfig

func (*MdConfig) UnmarshalTOML

func (mc *MdConfig) UnmarshalTOML(decode func(interface{}) error) error

type PrintPaperConfig added in v1.20250513.0

type PrintPaperConfig struct {
	Mapping upath.Import[*PrintPaperMapping] `toml:",omitempty"`
	Default struct {
		PaperType string  `toml:",omitempty"`
		PrintZoom float32 `toml:",omitempty"`
	} `toml:",omitempty"`
}

type PrintPaperMapping added in v1.20250513.0

type PrintPaperMapping map[string]string

func (*PrintPaperMapping) GetCss added in v1.20250513.0

func (ppm *PrintPaperMapping) GetCss(name string) (string, bool)

func (*PrintPaperMapping) Initialize added in v1.20250513.0

func (ppm *PrintPaperMapping) Initialize()

func (*PrintPaperMapping) MakeNew added in v1.20250513.0

func (_ *PrintPaperMapping) MakeNew() *PrintPaperMapping

func (*PrintPaperMapping) UnmarshalTOML added in v1.20250513.0

func (ppm *PrintPaperMapping) UnmarshalTOML(decode func(interface{}) error) error

type SafeIDs

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

func (*SafeIDs) Generate

func (ids *SafeIDs) Generate(value []byte, kind ast.NodeKind) []byte

func (*SafeIDs) Put

func (ids *SafeIDs) Put(value []byte)

type SmCardConfig added in v1.20250513.0

type SmCardConfig struct {
	Enabled    bool   `toml:",omitempty"`
	SiteTopUrl string `toml:",omitempty"`

	Default struct {
		Image         string `toml:",omitempty"`
		UseXcomLarge  bool   `toml:",omitempty"`
		Description   string `toml:",omitempty"`
		SiteName      string `toml:",omitempty"`
		SiteXcomId    string `toml:",omitempty"`
		CreatorXcomId string `toml:",omitempty"`
	}
}

func (*SmCardConfig) UnmarshalTOML added in v1.20250513.0

func (scc *SmCardConfig) UnmarshalTOML(decode func(interface{}) error) error

type SmCardParam added in v1.20250513.0

type SmCardParam struct {
	Description string `yaml:"description" toml:"description" json:"description"`

	Image        string `yaml:"image,omitempty" toml:"image,omitempty" json:"image,omitempty"`
	UseXcomLarge bool   `yaml:"is_large,omitempty" toml:"card_type,omitempty" json:"card_type,omitempty"`
	Alt          string `yaml:"alt,omitempty" toml:"alt,omitempty" json:"alt,omitempty"`

	Title         string `yaml:"title,omitempty" toml:"title,omitempty" json:"title,omitempty"`
	SiteName      string `yaml:"site_name,omitempty" toml:"site_name,omitempty" json:"site_name,omitempty"`
	SiteUrl       string `yaml:"site_url,omitempty" toml:"site_url,omitempty" json:"site_url,omitempty"`
	SiteXcomId    string `yaml:"site_xcom_id,omitempty" toml:"site_xcom_id,omitempty" json:"site_xcom_id,omitempty"`
	CreatorXcomId string `yaml:"creator_xcom_id,omitempty" toml:"creator_xcom_id,omitempty" json:"creator_xcom_id,omitempty"`
}

func (*SmCardParam) Fix added in v1.20250513.0

func (scp *SmCardParam) Fix(scc *SmCardConfig, abs_cur string)

type Toc

type Toc struct {
	Title      string
	TitleLevel int
	Heads      []*Head
}

func NewToc

func NewToc(html_bin []byte) (*Toc, error)

func (*Toc) ConvertHtml

func (tc *Toc) ConvertHtml() []byte

type UnmarshalFunc added in v1.20250513.0

type UnmarshalFunc func([]byte, any) error

type VideoOpt

type VideoOpt struct {
	SiteId string
	Host   string
	Path   string         `toml:",omitempty"`
	Regex  *regexp.Regexp `toml:",omitempty"`
}

func (*VideoOpt) UnmarshalTOML

func (vo *VideoOpt) UnmarshalTOML(decode func(interface{}) error) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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