Hwaro::Utils::FrontmatterWriter
Constants
YAML 1.1 words that reparse as booleans/null when left bare (Jekyll
runs on Psych). y/n included defensively.
Class methods
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 (\u is exactly four digits —
ext/toml_unicode_escape_fix.cr — so a following hex digit is literal).
Quote a frontmatter key that isn't a bare TOML key (spaces, dots, non-ASCII — all valid in YAML/JSON source).
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).
The bare-date shortcut applies only to a UTC or LOCAL-ZONE midnight —
the shapes a parsed bare date actually takes (local midnight; YAML
gave UTC midnight before ext/yaml_local_time_fix) — so authored bare
dates round-trip unchanged through their own format. Note the UTC branch is
deliberately lossy for an authored ...T00:00:00Z timestamp when
the file is later reparsed as TOML (local zone); that trade-off keeps
YAML bare dates stable and predates this rule. A midnight with any
other fixed offset is a genuine timestamp: collapsing it to
YYYY-MM-DD silently shifted the instant, so it keeps its offset.
Fractional seconds are preserved in both timestamp forms.
Any other local-zone value is a zone-less date-time as authored
(2024-01-02T03:04:05, which TOML and YAML both parse in the local
zone), so it is written without an offset rather than pinning the
converting machine's zone. On a UTC machine it can't be told from an
authored Z, so it stays Z there.
Convert a parsed TOML value into the YAML::Any tree the emitters
consume. Time leaves become frontmatter date strings (see
serialize_time).