Skip to main content

Module utils

Module utils 

Source

Functionsยง

color_discourse_label
current_utc_iso8601
Current time in YYYY-MM-DDTHH:MM:SSZ form, derived directly from SystemTime to avoid a chrono dependency where one is not otherwise needed. Used for the pulled_at front-matter stamp.
ensure_dir
Ensure a directory exists.
normalize_baseurl
Trim trailing slashes from a base URL.
parse_relative_duration
Parse a relative duration like 7d, 24h, 1w, 1m, 90s, 1y.
parse_since_cutoff
Parse a --since-style value. Accepts either a relative duration (7d, 24h, 30m, 1w, 90s) or an ISO-8601 absolute timestamp (2026-04-01, 2026-04-01T12:00:00Z). Returns the resulting cutoff instant (now - duration, or the ISO value itself).
read_markdown
Read a Markdown file.
resolve_topic_path
Resolve a topic path from a user-provided path and a topic title.
slugify
Create a URL-safe slug from arbitrary input.
strip_frontmatter
Split a Markdown document into its leading YAML front matter (if any) and the body that follows.
write_markdown
Write a Markdown file, creating parent directories if needed.
yaml_scalar
Quote a YAML scalar if it contains characters that would confuse the parser. Keeps simple values unquoted. Shared by every command that writes YAML front matter (topic pull --full, category pull).