Skip to content

Build the blog example, with relative includes and code-safe Markdown - #7

Merged
Demonstrandum merged 6 commits into
macrosfrom
blog
Nov 3, 2026
Merged

Demonstrandum merged 6 commits into
macrosfrom
blog

Conversation

@Demonstrandum

@Demonstrandum Demonstrandum commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #6.

Builds out the blog concept in samples/blog-concept as a working blog in samples/blog, and adds the features it needed. The concept itself is left as it was.

cd samples/blog
seam --text build.sex   # Writes the site into public/.

The blog

  • Posts are Markdown with YAML frontmatter (title, date, tags, description, draft).
  • site.sex defines %posts: every post's frontmatter, read with %markdown :only frontmatter, without drafts, newest first. It also defines the %page layout, with the head, header and footer as in the concept.
  • The index lists posts with their date, reading time and tags. A tags page groups the posts by tag, and there's an RSS feed and a stylesheet.
  • build.sex renders each page with %formatter/html :document true and saves it with %write. Each post page gets its details through %with.
  • index.sex, tags.sex, feed.sex and style.sex can also each be rendered alone.

Features it needed

  • Relative includes: %include and %embed look relative to the including file first, then in the include directories. The concept's Entry 1.sex, which includes ./includes/head.sex, now renders.
  • Code in Markdown: macro calls inside code blocks and spans are shown, not expanded. Without this, a post quoting build.sex's loop ran that loop and recursed until the stack overflowed.
  • New macros: %unique and %contains, for tags.
  • Dates: %timestamp accepts a date without a time.
  • Booleans: "false" counts as false, since YAML and TOML booleans arrive as strings.
  • %intercalate: it keeps only the separator's whitespace, so meta, seam no longer has a double space.

Testing: 43 tests pass and clippy is clean. I built the site and checked the HTML, feed and CSS output. I didn't view it in a browser.


Note

Medium Risk
Touches core expansion (includes, markdown, lazy typing), filesystem writes, and subprocess I/O; behavior changes could affect existing templates and build scripts.

Overview
Adds seam run, which expands a .sex file only for side effects (%write, %exec, %log) and prints each action on STDOUT (like make), without emitting a formatted document or requiring --html/--xml.

Includes and paths: %include / %embed resolve paths relative to the calling file first, then -I / the working directory. A large %path/... surface (cwd, this, here, join, split, normalise, canonical, absolute, relative, existence checks, etc.) supports portable build scripts. samples/blog is a full static blog driven by seam run build.sex.

Markdown / literate: Macro calls inside code blocks and spans are left literal (escaped during literate expansion). After frontmatter is stripped, the body is rendered without treating a leading --- as more frontmatter. Embedded file text is sited in its source file so %markdown and nested includes resolve paths correctly. XML/CSS output now passes Raw nodes through for literate hand-written text.

Macros and semantics: New %unique and %contains; %timestamp accepts date-only strings; "false" is falsy for %if; %intercalate whitespace is tidied; lazy typed macro arguments are type-checked when expanded; %exec avoids pipe deadlocks by writing stdin on a background thread.

Reviewed by Cursor Bugbot for commit b6d9d84. Bugbot is set up for automated code reviews on this repo. Configure here.

…nique, %contains.

- %include and %embed look for files relative to the including file
  first, then in the include directories.
- Macro calls inside Markdown code blocks and spans are shown as
  written, not expanded (otherwise a post quoting seam runs it).
- %unique and %contains, for collecting and filtering tags.
- %timestamp accepts a date without a time (as midnight).
- "false" counts as false, as YAML and TOML booleans arrive as strings.
- %intercalate keeps the separator's whitespace, not the items'.
Markdown posts with frontmatter, a shared layout, an index sorted by
date, a tags page and an RSS feed, all generated by build.sex with
%write and the formatter macros. Drafts are left out.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/seam/src/parse/expander.rs Resolved
- `seam run file.sex` expands a file only for its side effects, echoing
  each `%write`, `%exec` and `%log` on STDOUT.
- %path/cwd, this-file, this-directory, join, split, stem, with-extension,
  normalise, canonical, absolute, relative, exists, is-file, is-directory.
- The blog builds with `seam run` from any directory, using write/html.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6a04caa. Configure here.

Comment thread crates/seam/src/parse/expander.rs Resolved
- XML and CSS write literate (Raw) text as it is, instead of failing.
- Markdown content is rendered without frontmatter parsing once its
  frontmatter is split off, so a body starting with --- is kept.
- %exec writes :stdin from another thread, so large input and output
  cannot deadlock on full pipes.
- Typed lazy parameters (~n:number) are checked once expanded, each time
  they are used, instead of in their unexpanded form.
- %embed sites its text in the embedded file, and %markdown names its
  literate source after that file, so %include, %embed and %path/this and
  %path/here within markdown work relative to the markdown file.
@Demonstrandum
Demonstrandum merged commit ffb55d6 into macros Nov 3, 2026
2 checks passed
This was referenced Nov 3, 2026
Demonstrandum added a commit that referenced this pull request Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant