vdoc: fix panic on empty // comment on v doc -f html file.v; turn expected code block after empty example to a warning

This commit is contained in:
Delyan Angelov 2022-05-02 23:48:37 +03:00
parent cf92224248
commit 4da2908d63
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
6 changed files with 36 additions and 13 deletions

View file

@ -303,7 +303,7 @@ fn html_highlight(code string, tb &ast.Table) string {
} else if typ == .char {
'`$tok.lit`'
} else if typ == .comment {
if tok.lit[0] == 1 { '//${tok.lit[1..]}' } else { '//$tok.lit' }
if tok.lit != '' && tok.lit[0] == 1 { '//${tok.lit[1..]}' } else { '//$tok.lit' }
} else {
tok.lit
}