module

Hwaro::Utils::FrontmatterWriter

Constants

YAML_RESERVED_WORDS = ["true", "false", "yes", "no", "on", "off", "null", "none", "y", "n", "~"] of ::String

YAML 1.1 words that reparse as booleans/null when left bare (Jekyll runs on Psych). y/n included defensively.

Class methods

escape_toml_string(str : String) : String

Escape a string for a double-quoted TOML basic string. Unlike Crystal's String#inspect, this never emits TOML-invalid escapes (\a, \e, \v) and leaves non-ASCII text raw — toml.cr's \uXXXX reader greedily consumes a following hex digit, so escaping U+200B in "Auto​build" would produce an unparseable file.

Source
format_toml_key(key : String) : String

Quote a frontmatter key that isn't a bare TOML key (spaces, dots, non-ASCII — all valid in YAML/JSON source).

Source
serialize_time(time : Time) : String

Serialize a frontmatter date/time value without corrupting the calendar day or the author's zone.

Frontmatter dates are commonly written as TOML/YAML local dates such as 2026-05-20, which parse to midnight in the local time zone. Rendering those through to_rfc3339 (always UTC) rolls the day back in any positive-offset zone — e.g. in KST 2026-05-20 becomes 2026-05-19T15:00:00Z. When the value carries no time-of-day we emit a bare YYYY-MM-DD; genuine timestamps keep their own offset (to_rfc3339 would silently convert 08:00+09:00 to the previous day's 23:00Z).

Source
toml_to_yaml_any(value : TOML::Any) : YAML::Any

Convert a parsed TOML value into the YAML::Any tree the emitters consume. Time leaves become frontmatter date strings (see serialize_time).

Source
yaml_scalar(str : String) : String

Render a string as a YAML flow scalar, leaving simple values bare and double-quoting anything YAML would reinterpret — beta: gamma parses as a mapping, NO as false, 2024-01-15 as a date, *x as an alias.

Source

Nested types