From 0ba29e43edd7b599f2d64a33101f20aeecf39ce3 Mon Sep 17 00:00:00 2001 From: Spencer Brower <6729162+sbrow@users.noreply.github.com> Date: Tue, 14 Jul 2026 11:26:05 -0400 Subject: [PATCH] feat: Added margin notes support. --- AGENTS.md | 49 ++++++++++++++++++----- HUGO.md | 54 +++++++++++++++++++++++++ TODOS.md | 3 ++ content.odin | 4 +- footnotes.odin | 91 ++++++++++++++++++++++++++++++----------- footnotes_test.odin | 98 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 262 insertions(+), 37 deletions(-) create mode 100644 HUGO.md create mode 100644 footnotes_test.odin diff --git a/AGENTS.md b/AGENTS.md index 0b1fc80..9e7541a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,10 +5,10 @@ Thor is a static site generator written in [Odin](https://odin-lang.org), replac ## Architecture ``` -thor.json ← site config (title, base_url, author, params) +thor.json ← site config (title, base_url, author, params, sectionate) content/ ← markdown and HTML content files -layouts/ ← Mustache templates + partials -assets/ ← CSS (Tufte-based) and JS +layouts/ ← Mustache templates + partials (including icons) +assets/ ← CSS (Tufte-based, no build step) and JS public/ ← build output (generated) ``` @@ -16,13 +16,16 @@ public/ ← build output (generated) | File | Responsibility | |---|---| -| `main.odin` | Entry point. Calls `init_site`, `walk_content`, `render_site` | +| `main.odin` | Entry point. Sets `context.logger`, calls `init_site`, `walk_content`, `render_site` | | `site.odin` | `Site` struct (config + arena), `init_site`, `load_site_config`, `site_merge`, `site_allocator`, `destroy_site` | | `frontmatter.odin` | JSON frontmatter parser (`{ }` delimited) | -| `content.odin` | `Page` struct, content walker, page loader, cmark integration, footnote/alert/emoji pipeline | -| `footnotes.odin` | Footnote definition stripping (pre-cmark) + sidenote injection (post-cmark) | +| `content.odin` | `Page` struct, content walker, page loader, cmark integration, full markdown pipeline | +| `footnotes.odin` | Note definition stripping (pre-cmark) + sidenote/marginnote injection (post-cmark) | | `alerts.odin` | GitHub alert post-processor (`> [!CAUTION]` → styled blockquote) | | `emoji.odin` | Emoji shortcode expander (`:shrug:` → `¯\_(ツ)_/¯`) | +| `highlight.odin` | Post-cmark Tree-sitter syntax highlighter; loads grammars/queries from Helix, caches loaded grammars, reports syntax errors with file/line | +| `tree_sitter.odin` | C FFI bindings for Tree-sitter (TSParser, TSQuery, TSQueryCursor, node traversal, dlopen/dlsym) | +| `sectionate.odin` | `wrap_sections` proc — splits HTML at `` wrappers | | `render.odin` | Mustache template rendering, all page types, RSS, sitemap, robots.txt, `load_partials` recursive scan | | `feed.odin` | RSS feed + sitemap XML generation | | `mustache/` | Vendored [odin-mustache](https://github.com/benjamindblock/odin-mustache) library | @@ -34,20 +37,21 @@ Icon SVGs live as HTML partials in `layouts/partials/icons/` (home, github, rss, ``` thor.json → init_site → Site (config + Dynamic_Arena) ↓ -content/ → walk_content → []Page (with body_html from cmark pipeline) +content/ → walk_content → []Page (with body_html from pipeline) ↓ layouts/*.html → render_site (Mustache render_in_layout) → public/ ``` ### Config system -`Site` has `params: json.Value` for arbitrary user-defined data from `thor.json`. Social links and other template-only data live under `"params"`: +`Site` has `params: json.Value` for arbitrary user-defined data from `thor.json`. Social links and other template-only data live under `"params"`. `sectionate: bool` controls automatic `
` wrapping at `

` boundaries. ```json { "title": "...", "base_url": "...", "author": "...", + "sectionate": true, "params": { "social": [ { "name": "github", "url": "...", "icon": "icons/github" } @@ -69,10 +73,24 @@ raw markdown → cmark markdown_to_html (Unsafe mode for HTML passthrough) → inject_sidenotes (post-cmark: [^id] →