Skip to content

Commit 6db7cd4

Browse files
committed
fix(placeholders): remove redundant MatchString guard and update all rule READMEs
- Drop the MatchString pre-check before ReplaceAllLiteralString in MaskBodyTokens and stripBodyTokens: ReplaceAllLiteralString returns the original string when the regex finds no match, so MatchString + ReplaceAll was scanning the regex engine twice per matching node. ContainsBodyToken correctly keeps the double guard since it needs a boolean return without side effects. - Update Useful tokens line in MDS003, MDS004, MDS018, MDS023, MDS024, and MDS027 per-rule READMEs to list apm-input-token alongside the existing tokens (the global placeholder-grammar.md table was already updated; these were overlooked). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Cua8NLiPy6fhj58LvUWf1
1 parent fe3a98b commit 6db7cd4

7 files changed

Lines changed: 8 additions & 8 deletions

File tree

internal/placeholders/placeholders.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func MaskBodyTokens(text string, tokens []string) string {
110110
return neutralText[PlaceholderSection]
111111
}
112112
case APMInputToken:
113-
if strings.Contains(text, apmInputPrefix) && apmInputRe.MatchString(text) {
113+
if strings.Contains(text, apmInputPrefix) {
114114
text = apmInputRe.ReplaceAllLiteralString(text, neutralText[APMInputToken])
115115
}
116116
}
@@ -147,7 +147,7 @@ func stripBodyTokens(text string, tokens []string) string {
147147
return ""
148148
}
149149
case APMInputToken:
150-
if strings.Contains(text, apmInputPrefix) && apmInputRe.MatchString(text) {
150+
if strings.Contains(text, apmInputPrefix) {
151151
text = apmInputRe.ReplaceAllLiteralString(text, "")
152152
}
153153
}

internal/rules/MDS003-heading-increment/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Heading levels should increment by one. No jumping from `#` to `###`.
4747
| -------------- | ---- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
4848
| `placeholders` | list | `[]` | Placeholder tokens to treat as opaque; see [placeholder grammar](../../../docs/background/concepts/placeholder-grammar.md) |
4949

50-
Useful tokens: `heading-question`, `placeholder-section`, `var-token`.
50+
Useful tokens: `heading-question`, `placeholder-section`, `var-token`, `apm-input-token`.
5151

5252
## Config
5353

internal/rules/MDS004-first-line-heading/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ First line of the file should be a heading.
3636
| `level` | int | 1 | Required heading level for the first line |
3737
| `placeholders` | list | `[]` | Placeholder tokens to treat as opaque; see [placeholder grammar](../../../docs/background/concepts/placeholder-grammar.md) |
3838

39-
Useful tokens: `heading-question`, `var-token`, `placeholder-section`.
39+
Useful tokens: `heading-question`, `var-token`, `placeholder-section`, `apm-input-token`.
4040

4141
## Config
4242

internal/rules/MDS018-no-emphasis-as-heading/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Don't use bold or emphasis on a standalone line as a heading substitute.
3939
| -------------- | ---- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
4040
| `placeholders` | list | `[]` | Placeholder tokens to treat as opaque; see [placeholder grammar](../../../docs/background/concepts/placeholder-grammar.md) |
4141

42-
Useful tokens: `var-token`, `heading-question`, `placeholder-section`.
42+
Useful tokens: `var-token`, `heading-question`, `placeholder-section`, `apm-input-token`.
4343

4444
## Config
4545

internal/rules/MDS023-paragraph-readability/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Paragraph readability index must not exceed a threshold.
2525
| `min-words` | int | 20 | Minimum word count to check a paragraph |
2626
| `placeholders` | list | `[]` | Placeholder tokens to treat as opaque; see [placeholder grammar](../../../docs/background/concepts/placeholder-grammar.md) |
2727

28-
Useful tokens: `var-token`, `heading-question`, `placeholder-section`.
28+
Useful tokens: `var-token`, `heading-question`, `placeholder-section`, `apm-input-token`.
2929

3030
Paragraphs with fewer words than `min-words` are skipped.
3131
Markdown tables and code blocks are skipped.

internal/rules/MDS024-paragraph-structure/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Paragraphs must not exceed sentence and word limits.
2525
| `max-words-per-sentence` | int | 40 | Maximum words per sentence |
2626
| `placeholders` | list | `[]` | Placeholder tokens to treat as opaque; see [placeholder grammar](../../../docs/background/concepts/placeholder-grammar.md) |
2727

28-
Useful tokens: `var-token`, `heading-question`, `placeholder-section`.
28+
Useful tokens: `var-token`, `heading-question`, `placeholder-section`, `apm-input-token`.
2929

3030
Markdown tables and code blocks are skipped.
3131

internal/rules/MDS027-cross-file-reference-integrity/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Links to local files and heading anchors must resolve.
4444
| `wikilinks` | bool | `false` | Validate Obsidian-style `[[Page]]`, `[[Page#anchor]]`, `[[Page\|alias]]`, and `![[file.png]]` targets against the workspace. |
4545
| `wikilink-style` | string | `"obsidian"` | Resolution style for wikilinks. Only `obsidian` ships today; other values are rejected at config load. |
4646

47-
Useful tokens: `var-token`, `heading-question`, `placeholder-section`.
47+
Useful tokens: `var-token`, `heading-question`, `placeholder-section`, `apm-input-token`.
4848

4949
With `strict: false`, only Markdown targets (`.md`, `.markdown`)
5050
are checked (except images — see `links.validate-images`).

0 commit comments

Comments
 (0)