Documentation
¶
Overview ¶
Package mdfile implements reading and writing of Markdown translation files.
Each Markdown file is split into translatable segments:
Frontmatter scalar fields (YAML between --- delimiters) are stored as individual segments with keys like "fm:title", "fm:hero.text", "fm:features.0.title".
The Markdown body is split on headings (# to ######) and horizontal rules (---, ***, ___) into sections, stored as segments with keys like "sec:0", "sec:1", ...
Code blocks (``` ... ```) and HTML blocks are NOT split on and are included verbatim in the section that contains them.
The round-trip serialization reconstructs the original file structure.
Index ¶
- func SyncKeys(src, target *File)
- type File
- func (f *File) Get(key string) (string, bool)
- func (f *File) Keys() []string
- func (f *File) Marshal() ([]byte, error)
- func (f *File) Set(key, value string) bool
- func (f *File) SourceValues() map[string]string
- func (f *File) Stats() (int, int, float64)
- func (f *File) UntranslatedKeys() []string
- func (f *File) WriteFile(path string) error
- type Segment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents a parsed Markdown translation file.
func NewTranslationFile ¶
NewTranslationFile creates an empty target File with the same structure as srcFile but all values cleared.
func (*File) SourceValues ¶
SourceValues returns a map of key → value.
func (*File) UntranslatedKeys ¶
UntranslatedKeys returns keys whose value is empty.