Skip to content

fix: ignore headings inside code fences in rule sections, and clear Test Rule's loading text - #373

Open
thelastbackspace wants to merge 1 commit into
microsoft:mainfrom
thelastbackspace:fix/343-rule-sections-code-fences
Open

thelastbackspace wants to merge 1 commit into
microsoft:mainfrom
thelastbackspace:fix/343-rule-sections-code-fences

Conversation

@thelastbackspace

Copy link
Copy Markdown

Description

Two fixes from #343.

The rule parser ended a section at any line starting with #, including lines inside a fenced code block. So a Description with a fenced example like # When Triggered got cut off at the fence, and the fenced line was read as the When Triggered section. parseSection and the Rule Editor form's sectionBlocks now both skip headings inside a closed fence (a small shared fencedLines helper in src/core/markdown-fences.ts), so they still read sections the same way. A fence marker that never closes doesn't count, so a stray ``` can't hide the rest of the rule.

Test Rule set its loading text with textContent on the element preact renders into. Preact doesn't own that text node, so it stayed above the result, and for a rule without thresholds the second run showed only the loading text. I render it through preact instead.

I updated the three tests that pinned the old behavior. The "heading inside the detect block" tests now open the detect block mid-line, which is the case where a heading inside it can still happen, so the read-only handling stays covered. None of the 45 built-in rules change.

Related Issues

Fixes #343

Checklist

  • npm run check passes (typecheck + lint + spellcheck + knip + tests). The 8 failing tests also fail on main.
  • Changes are covered by tests
  • Documentation updated (not needed)

… Test Rule's loading text

parseSection and the Rule Editor form's section reader treated every
`# ...` line as a heading, even inside a fenced example, so a fenced
`# When Triggered` line cut the Description short and was read as the
When Triggered section. Both now skip lines inside a closed code fence,
using a shared fencedLines helper.

Test Rule wrote its loading text with textContent into the element preact
renders into. Preact doesn't own that text node, so it stayed above the
result, and for a rule without thresholds every run after the first showed
only the loading text. It's rendered through preact now.

Fixes microsoft#343
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.

Rule sections end at headings inside code fences, and Test Rule can show only "Running rule…" instead of its result

1 participant