Skip to content

Commit

Permalink
vdoc: fmt html.v and utils.v
Browse files Browse the repository at this point in the history
  • Loading branch information
nedpals committed Nov 6, 2023
1 parent 697312e commit 0736cfe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions cmd/tools/vdoc/html.v
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ fn html_highlight(code string, tb &ast.Table) string {
.key_true, .key_false {
tok_typ = .boolean
}
.lpar, .lcbr, .rpar, .rcbr, .lsbr, .rsbr, .semicolon, .colon, .comma, .dot,
.dotdot, .ellipsis {
.lpar, .lcbr, .rpar, .rcbr, .lsbr, .rsbr, .semicolon, .colon, .comma, .dot, .dotdot,
.ellipsis {
tok_typ = .punctuation
}
else {
Expand All @@ -430,7 +430,7 @@ fn html_highlight(code string, tb &ast.Table) string {
// expectation: "${a}.${b}${c}"
// reality: "${a.${b}${c}"
if tok.lit.len != 0 {
write_token(token.Token{kind: .rcbr}, .unone, mut buf)
write_token(token.Token{ kind: .rcbr }, .unone, mut buf)
}

inside_string_interp = false
Expand Down
8 changes: 5 additions & 3 deletions cmd/tools/vdoc/utils.v
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ fn gen_footer_text(d &doc.Doc, include_timestamp bool) string {
return '${footer_text} Generated on: ${time_str}'
}

const highlight_builtin_types = ['bool', 'string', 'i8', 'i16', 'int', 'i64', 'i128', 'isize', 'byte', 'u8', 'u16',
'u32', 'u64', 'usize', 'u128', 'rune', 'f32', 'f64', 'byteptr', 'voidptr', 'any']
const highlight_builtin_types = ['bool', 'string', 'i8', 'i16', 'int', 'i64', 'i128', 'isize',
'byte', 'u8', 'u16', 'u32', 'u64', 'usize', 'u128', 'rune', 'f32', 'f64', 'byteptr', 'voidptr',
'any']

fn color_highlight(code string, tb &ast.Table) string {
highlight_code := fn (tok token.Token, typ HighlightTokenTyp) string {
Expand Down Expand Up @@ -215,7 +216,8 @@ fn color_highlight(code string, tb &ast.Table) string {
(next_tok.kind in [.lcbr, .rpar, .eof, .comma, .pipe, .name, .rcbr, .assign, .key_pub, .key_mut, .pipe, .comma, .comment, .lt, .lsbr]
&& next_tok.lit !in highlight_builtin_types)
&& (prev.kind in [.name, .amp, .lcbr, .rsbr, .key_type, .assign, .dot, .question, .rpar, .key_struct, .key_enum, .pipe, .key_interface, .comment, .ellipsis]
&& prev.lit !in highlight_builtin_types) && ((tok.lit != '' && tok.lit[0].is_capital())
&& prev.lit !in highlight_builtin_types)
&& ((tok.lit != '' && tok.lit[0].is_capital())
|| prev_prev.lit in ['C', 'JS']) {
tok_typ = .symbol
} else if next_tok.kind == .lpar
Expand Down

0 comments on commit 0736cfe

Please sign in to comment.