omd2tex.tools.frontmatter_parser#

Classes

FrontMatterParser([filename, abs_path, text])

class omd2tex.tools.frontmatter_parser.FrontMatterParser(filename: str | None = None, abs_path: str | None = None, text: List[str] | str = '')[source]#

Bases: object

static quote_sensitive_yaml_values(yaml_text: str) str[source]#

Safely quote time-like YAML fields to preserve strings.

Wraps values for keys startTime, endTime, and date in quotes so yaml.safe_load does not coerce them to numeric or timestamp types.

Parameters:

yaml_text – Raw YAML frontmatter text.

Returns:

YAML text with targeted values quoted.

Raises:

None explicitly.

update(new_dict: Dict) FrontMatterParser[source]#

Update the stored YAML dictionary with new keys and values.

Parameters:

new_dict – Mapping of keys to merge into the existing YAML data.

Returns:

Self instance after update.

update_file(new_dict: Dict = {}) None[source]#

Persist updated YAML back to the associated file.

Merges new data into the current YAML, reconstructs the file with the updated frontmatter, and writes it to disk.

Parameters:

new_dict – Optional mapping of additional values to merge before writing.

Returns:

None

Raises:
  • FileNotFoundError – If the target file is missing.

  • IOError – Propagated on write failures.