Skip to content

Commit 806b73c

Browse files
committed
review: restore astutil.CountLeadingSpaces in isPIOpenLine for consistency
Round-3 review found that the round-2 efficiency fix (inline len(raw)-len(trimmed) > 3) created inconsistency with the identical CommonMark "≤3 leading spaces" gate in sibling functions fenceOpenRun and fenceClose, both of which call astutil.CountLeadingSpaces. Restore the named-helper call so all three functions express the same spec rule the same way; the second TrimLeft on this path is negligible. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gj8AvSb7r12iqa7r3vYYof
1 parent 1043d55 commit 806b73c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • internal/rules/requiredstructure

internal/rules/requiredstructure/rule.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,10 +1475,10 @@ func fenceRun(line []byte, ch byte) int {
14751475
// (the bytes up to the first whitespace or `?>`). An indented code
14761476
// example showing a directive is therefore not mistaken for one.
14771477
func isPIOpenLine(raw []byte) bool {
1478-
trimmed := bytes.TrimLeft(raw, " ")
1479-
if len(raw)-len(trimmed) > 3 {
1478+
if astutil.CountLeadingSpaces(raw) > 3 {
14801479
return false
14811480
}
1481+
trimmed := bytes.TrimLeft(raw, " ")
14821482
trimmed = bytes.TrimRight(trimmed, " \t\r\n")
14831483
if !bytes.HasPrefix(trimmed, piOpenPrefix) {
14841484
return false

0 commit comments

Comments
 (0)