Skip to content

refactor(markdown-toolkit): detect elements in isMDElement - #195

Merged
Jason3S merged 1 commit into
mainfrom
claude/md-element-detection
Nov 11, 2026
Merged

Jason3S merged 1 commit into
mainfrom
claude/md-element-detection

Conversation

@Jason3S

@Jason3S Jason3S commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Summary

renderingOf did two jobs: it read an element's stored nodes and style, and its undefined result doubled as the test for "is this an element?". The test now lives in isMDElement, and the places that tested through renderingOf call it. No behavior changes.

Changes

Detection moved. isMDElement checks for the element key itself, instead of asking renderingOf and comparing with undefined.

Test sites switched. These five now call isMDElement:

  • isKind
  • describe
  • isFrontmatter
  • isPlainObject
  • isTemplateReplacement

The type guard narrows the value, so three as MDElement / as MDFrontmatter casts are gone.

Left for a follow-up. renderingOf is unchanged. It still takes unknown and returns undefined for a non-element, for the ten places that read nodes or style from it. Three of those (inlineNodes, blockNodes, substitutePlaceholders) still lean on that undefined; they change together with the getter.

`renderingOf` did two jobs: it read an element's stored nodes and style,
and callers also used its `undefined` result to test whether a value is
an element at all. The test now lives in `isMDElement`, which checks for
the key directly, and the five places that tested through `renderingOf`
call it instead. Its type guard removes three casts.

`renderingOf` is unchanged and now only serves the places that read from
it.
@Jason3S
Jason3S merged commit 4f0ad92 into main Nov 11, 2026
8 checks passed
@Jason3S
Jason3S deleted the claude/md-element-detection branch November 11, 2026 05:25
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