Skip to content

fix(generator): resolve expr-based headings to the target filename - #83

Closed
toiroakr wants to merge 1 commit into
jackchuka:mainfrom
toiroakr:fix/generate-heading-placeholder
Closed

fix(generator): resolve expr-based headings to the target filename#83
toiroakr wants to merge 1 commit into
jackchuka:mainfrom
toiroakr:fix/generate-heading-placeholder

Conversation

@toiroakr

@toiroakr toiroakr commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • generate scaffolds an expr-based heading (e.g. filename == heading) as that literal expression text, since the generator doesn't know the target filename — the file then fails its own check.
  • Now tries the filename itself as the heading, verifies it against the real expression (vast.EvaluateHeadingExpr), and only falls back to the old text if that candidate doesn't actually satisfy it.
$ mdschema generate --schema schema.yml --output CreateOrder.md
$ head -1 CreateOrder.md
# filename == heading      # before
# CreateOrder              # after

generate previously printed a HeadingPattern.Expr's literal text (e.g.
"filename == heading") as the scaffolded H1 when it had no way to derive
a concrete value, since the generator had no knowledge of the target
filename.

Generate now takes the filename and tries it as the heading for an
expr-based pattern: any expression of the shape "f(filename) ==
f(heading)" (documented example: slug(filename) == slug(heading)) is
trivially satisfied once heading == filename. This is verified against
the real expression via the same expr-lang evaluator already used for
validation (exported as vast.EvaluateHeadingExpr), so an expression that
doesn't hold for heading == filename falls back to the previous
behavior.
@toiroakr
toiroakr force-pushed the fix/generate-heading-placeholder branch from a59e2ec to 857a2c9 Compare August 27, 2026 01:58
@toiroakr toiroakr closed this Aug 27, 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