refactor(tui): clean markdown.tsx per KISS/DRY#13719
Merged
Merged
Conversation
- Drop the outer no-op capture group from INLINE_RE and restructure the source as an ordered list of patterns-with-index-comments so each alternative is individually greppable. Shift group indices in MdInline down by one accordingly. - Inline single-use helpers (parseFence, isFenceClose, isMarkdownFence, trimBareUrl) and intermediate variables (path, lang, raw, prefix, body, depth, task body, setext match, etc.). - Hoist block-level regexes used inside MdImpl (FENCE_CLOSE_RE, SETEXT_RE, BULLET_RE, TASK_RE, NUMBERED_RE, QUOTE_RE) to top-level consts so they're compiled once instead of per-line. - Collapse the duplicate compact-vs-normal blank-line branches into one if/!compact gap call. - Move Fence and MdProps types to the bottom per house style. - Shorten splitTableRow → splitRow and use optional chaining in a few match sites. No behavior change; 162/162 tests pass. Net -22 LoC.
fa76afb to
b97b4c4
Compare
ulasbilgen
pushed a commit
to ulasbilgen/hermes-adhd-agent
that referenced
this pull request
May 1, 2026
…wn-cleanup refactor(tui): clean markdown.tsx per KISS/DRY
aj-nt
pushed a commit
to aj-nt/hermes-agent
that referenced
this pull request
May 1, 2026
…wn-cleanup refactor(tui): clean markdown.tsx per KISS/DRY
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
…wn-cleanup refactor(tui): clean markdown.tsx per KISS/DRY
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
…wn-cleanup refactor(tui): clean markdown.tsx per KISS/DRY
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
…wn-cleanup refactor(tui): clean markdown.tsx per KISS/DRY
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.
Summary
Stacks on top of #13715 — merge that first, then this rebases to just the cleanup commit.
Pure refactor of
markdown.tsxper KISS/DRY house rules. The file had accumulated shapes that violate our rules:INLINE_REwas a single ~500-char escaped string with an outer no-op capture group — so the 17 inner groups were indexed m[2]-m[17] instead of m[1]-m[16], and the alternatives weren't individually readable.parseFence,isFenceClose,isMarkdownFence,trimBareUrl) added indirection without meaningful naming wins.path,raw,lang,depth,body,task body,setext match, etc.) were bound once and used once.!line.trim()under compact vs normal flow.whileloop — compiled fresh per line.Fence,MdProps) were at the top instead of at the bottom.Changes
INLINE_REsource → ordered array of patterns with// 1,2 image/// 3,4 link/ … comments mapping to capture indices. Outer wrapping group removed.MdInlinecapture-group references shifted -1 (m[1]–m[16]).parseFence/isFenceClose/isMarkdownFence/trimBareUrl.FENCE_CLOSE_RE,SETEXT_RE,BULLET_RE,TASK_RE,NUMBERED_RE,QUOTE_RE.Fenceto a localKindunion. Move types to the bottom.splitTableRow→splitRow(it's not specific to tables).?.[1],?.[2]) on match results where we only want one capture.Test plan
npm test— 167/167 (picks up the 5 new subscript/kaomoji tests from fix(tui): don't swallow Kimi/Qwen ~! ~? kaomoji as subscript spans #13715 base)npm run type-check— cleannpm run lint— clean (one pre-existing unrelated warning inuseInputHandlers.ts)npx prettier --check src/components/markdown.tsx— compliantNet for this commit alone: -22 LoC, same behavior.