Skip to content

Commit

Permalink
test: Improve comment parser to skip code blocks
Browse files Browse the repository at this point in the history
It might be nicer to have some code blocks all by themselves on a single
line.
  • Loading branch information
purpleidea committed Jul 2, 2024
1 parent e10e925 commit 7a35bef
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/comment_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ func Check(filename string) error {

// TODO: how do we deal with multiline comments?
if strings.HasPrefix(s, CommentMultilinePrefix) {
break // skip
break // skip to the end of this block
}

// skip the magic compiler comments
if strings.HasPrefix(s, CommentGolangPrefix) {
break // skip
break // skip to the end of this block
}

if s != commentPrefixTrimmed && !strings.HasPrefix(s, CommentPrefix) {
Expand Down Expand Up @@ -265,6 +265,9 @@ func IsNewStart(word string) bool {
if IsNumberBullet(word) {
return true
}
if IsCodeBlock(word) {
return true
}

return false
}
Expand Down Expand Up @@ -293,3 +296,11 @@ func IsNumberBullet(word string) bool {
}
return matched
}

// IsCodeBlock returns true if the word starts with a code block backtick.
func IsCodeBlock(word string) bool {
if strings.HasPrefix(word, "`") {
return true
}
return false
}

0 comments on commit 7a35bef

Please sign in to comment.