test: Improve comment parser to skip code blocks
It might be nicer to have some code blocks all by themselves on a single line.
This commit is contained in:
@@ -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) {
|
||||
@@ -265,6 +265,9 @@ func IsNewStart(word string) bool {
|
||||
if IsNumberBullet(word) {
|
||||
return true
|
||||
}
|
||||
if IsCodeBlock(word) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user