fix(generator): let expr win over pattern and guard empty filenames - #85
Merged
Conversation
resolveHeadingText only resolved the filename when neither pattern nor literal was set, but PatternMatcher.MatchesHeading checks expr first and ignores pattern/literal entirely. A schema with both pattern and expr still generated a file that failed its own check. It also lacked the `filename == ""` guard that matchesHeadingExpr has, so an output path like `out/.md` evaluated `"" == ""` to true and emitted a bare `# ` heading that check time can never accept.
jackchuka
marked this pull request as ready for review
August 27, 2026 17:29
tmeijn
pushed a commit
to tmeijn/dotfiles
that referenced
this pull request
Aug 28, 2026
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [jackchuka/mdschema](https://github.com/jackchuka/mdschema) | patch | `v0.15.1` → `v0.15.2` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>jackchuka/mdschema (jackchuka/mdschema)</summary> ### [`v0.15.2`](https://github.com/jackchuka/mdschema/releases/tag/v0.15.2) [Compare Source](jackchuka/mdschema@v0.15.1...v0.15.2) #### What's Changed - fix(generator): resolve expr-based headings to the target filename by [@​toiroakr](https://github.com/toiroakr) in [#​84](jackchuka/mdschema#84) - fix(generator): let expr win over pattern and guard empty filenames by [@​jackchuka](https://github.com/jackchuka) in [#​85](jackchuka/mdschema#85) #### New Contributors - [@​toiroakr](https://github.com/toiroakr) made their first contribution in [#​84](jackchuka/mdschema#84) **Full Changelog**: <jackchuka/mdschema@v0.15.1...v0.15.2> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yODguMCIsInVwZGF0ZWRJblZlciI6IjQzLjI4OC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6cGF0Y2giXX0=-->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #84 — two cases where
generatestill emits a file that fails its owncheck.1. Inverted precedence vs. the matcher
resolveHeadingTextresolved the filename only whenPattern == "" && Literal == "" && Expr != "", butvast.PatternMatcher.MatchesHeadingchecksExprfirst and ignoresPattern/Literalwhen it is set. Nothing rejects a heading carrying both keys, so:Now gated on
hp.Expr != "" && outputPath != "", mirroringMatchesHeading. Output is# Bar, check passes.2. Missing
filename == ""guardmatchesHeadingExprreturns early when the extracted filename is empty;resolveHeadingTextdid not. For an output path whose base is only an extension (-o out/.md),filename == headingevaluated"" == ""→ true and a bare#heading was written — one that check time, with the guard in place, can never accept. The generator now falls back to the expression text for that case.Tests
docs/.mdrow added toTestGenerateExprHeadingTestGenerateExprWinsOverPatternAndLiteralgo build ./...andgo test ./...pass.