Skip to content

Commit 704ec38

Browse files
committed
migrate from vweb to veb
1 parent 5001da5 commit 704ec38

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+878
-937
lines changed

git/libgit.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub fn new_repo(path string) &Repo {
168168
println('ff ${ret}')
169169
// git_reference_free(head_ref);
170170
return &Repo{
171-
obj: repo_obj
171+
obj: repo_obj
172172
path: path
173173
}
174174
}

git/util.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub fn check_git_repo_url(url string) bool {
5151
headers.add_custom('User-Agent', 'git/2.30.0') or {}
5252
headers.add_custom('Git-Protocol', 'version=2') or {}
5353
config := http.FetchConfig{
54-
url: refs_url
54+
url: refs_url
5555
header: headers
5656
}
5757
response := http.fetch(config) or { return false }

highlight/c.v

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ module highlight
22

33
fn init_c() Lang {
44
return Lang{
5-
name: 'C'
5+
name: 'C'
66
lang_extensions: ['c']
7-
line_comments: '//'
8-
mline_comments: ['/*', '*/']
9-
string_start: ['"', "'"]
10-
color: '#555555'
11-
keywords: [
7+
line_comments: '//'
8+
mline_comments: ['/*', '*/']
9+
string_start: ['"', "'"]
10+
color: '#555555'
11+
keywords: [
1212
'auto',
1313
'double',
1414
'int',

highlight/cpp.v

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ module highlight
22

33
fn init_cpp() Lang {
44
return Lang{
5-
name: 'C++'
5+
name: 'C++'
66
lang_extensions: ['cpp', 'cc', 'hh', 'h']
7-
line_comments: '//'
8-
mline_comments: ['/*', '*/']
9-
string_start: ['"', "'"]
10-
color: '#f34b7d'
11-
keywords: [
7+
line_comments: '//'
8+
mline_comments: ['/*', '*/']
9+
string_start: ['"', "'"]
10+
color: '#f34b7d'
11+
keywords: [
1212
'int',
1313
'float',
1414
'while',

highlight/d.v

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ module highlight
22

33
fn init_d() Lang {
44
return Lang{
5-
name: 'D'
5+
name: 'D'
66
lang_extensions: ['d']
7-
line_comments: '//'
8-
mline_comments: ['/*', '*/', '/+', '+/']
9-
string_start: ['"', "'"]
10-
color: '#ba595e'
11-
keywords: [
7+
line_comments: '//'
8+
mline_comments: ['/*', '*/', '/+', '+/']
9+
string_start: ['"', "'"]
10+
color: '#ba595e'
11+
keywords: [
1212
'abstract',
1313
'alias',
1414
'align',

highlight/go.v

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ module highlight
22

33
fn init_go() Lang {
44
return Lang{
5-
name: 'Go'
5+
name: 'Go'
66
lang_extensions: ['go']
7-
line_comments: '//'
8-
mline_comments: ['/*', '*/']
9-
string_start: ['"', '`']
10-
color: '#00add8'
11-
keywords: [
7+
line_comments: '//'
8+
mline_comments: ['/*', '*/']
9+
string_start: ['"', '`']
10+
color: '#00add8'
11+
keywords: [
1212
'break',
1313
'chan',
1414
'const',

highlight/highlight.v

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
// Use of this source code is governed by a GPL license that can be found in the LICENSE file.
33
module highlight
44

5-
const (
6-
tab = ' ' // '
7-
)
5+
const tab = ' ' // '
86

97
// returns HTML code, number of lines, number of lines with source code
108
pub fn highlight_text(st string, file_path string, commit bool) (string, int, int) {
@@ -69,7 +67,7 @@ pub fn highlight_text(st string, file_path string, commit bool) (string, int, in
6967
continue
7068
}
7169
if c == `\t` {
72-
res << highlight.tab.bytes()
70+
res << tab.bytes()
7371
continue
7472
}
7573
if in_comment {

highlight/javascript.v

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ module highlight
22

33
fn init_js() Lang {
44
return Lang{
5-
name: 'JavaScript'
5+
name: 'JavaScript'
66
lang_extensions: ['js', 'mjs', 'jsx']
7-
line_comments: '//'
8-
mline_comments: ['/*', '*/']
9-
string_start: ['"', "'"]
10-
color: '#f1e05a'
11-
keywords: [
7+
line_comments: '//'
8+
mline_comments: ['/*', '*/']
9+
string_start: ['"', "'"]
10+
color: '#f1e05a'
11+
keywords: [
1212
'break',
1313
'do',
1414
'instanceof',

highlight/langs.v

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22
// Use of this source code is governed by a GPL license that can be found in the LICENSE file.
33
module highlight
44

5-
const (
6-
lang_path = 'langs'
7-
)
5+
const lang_path = 'langs'
86

9-
const (
10-
langs = init_langs()
11-
)
7+
const langs = init_langs()
128

139
pub struct Lang {
1410
keywords []string
@@ -28,7 +24,7 @@ fn is_source(ext string) bool {
2824

2925
pub fn extension_to_lang(ext string) !Lang {
3026
ending := ext.split('.').last()
31-
for lang in highlight.langs {
27+
for lang in langs {
3228
if ending in lang.lang_extensions {
3329
return lang
3430
}

highlight/lua.v

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ module highlight
22

33
fn init_lua() Lang {
44
return Lang{
5-
name: 'Lua'
5+
name: 'Lua'
66
lang_extensions: ['lua']
7-
line_comments: '--'
8-
mline_comments: ['--[[', ']]']
9-
string_start: ['"', "'"]
10-
color: '#00007d'
11-
keywords: [
7+
line_comments: '--'
8+
mline_comments: ['--[[', ']]']
9+
string_start: ['"', "'"]
10+
color: '#00007d'
11+
keywords: [
1212
'and',
1313
'break',
1414
'do',

highlight/markdown.v

+68-70
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,71 @@ module highlight
33
import markdown
44
import pcre
55

6-
const (
7-
allowed_tags = [
8-
'a',
9-
'abbr',
10-
'b',
11-
'blockquote',
12-
'body',
13-
'br',
14-
'center',
15-
'code',
16-
'dd',
17-
'details',
18-
'div',
19-
'dl',
20-
'dt',
21-
'em',
22-
'font',
23-
'h1',
24-
'h2',
25-
'h3',
26-
'h4',
27-
'h5',
28-
'h6',
29-
'hr',
30-
'i',
31-
'img',
32-
'kbd',
33-
'label',
34-
'li',
35-
'ol',
36-
'p',
37-
'pre',
38-
'small',
39-
'source',
40-
'span',
41-
'strong',
42-
'sub',
43-
'summary',
44-
'sup',
45-
'table',
46-
'tbody',
47-
'tr',
48-
'td',
49-
'th',
50-
'thead',
51-
'ul',
52-
'u',
53-
'video',
54-
]
55-
allowed_attributes = [
56-
'align',
57-
'color',
58-
'controls',
59-
'height',
60-
'href',
61-
'id',
62-
'src',
63-
'style',
64-
'target',
65-
'title',
66-
'type',
67-
'width',
68-
]
69-
unallowed_schemas = [
70-
'javascript:',
71-
]
72-
)
6+
const allowed_tags = [
7+
'a',
8+
'abbr',
9+
'b',
10+
'blockquote',
11+
'body',
12+
'br',
13+
'center',
14+
'code',
15+
'dd',
16+
'details',
17+
'div',
18+
'dl',
19+
'dt',
20+
'em',
21+
'font',
22+
'h1',
23+
'h2',
24+
'h3',
25+
'h4',
26+
'h5',
27+
'h6',
28+
'hr',
29+
'i',
30+
'img',
31+
'kbd',
32+
'label',
33+
'li',
34+
'ol',
35+
'p',
36+
'pre',
37+
'small',
38+
'source',
39+
'span',
40+
'strong',
41+
'sub',
42+
'summary',
43+
'sup',
44+
'table',
45+
'tbody',
46+
'tr',
47+
'td',
48+
'th',
49+
'thead',
50+
'ul',
51+
'u',
52+
'video',
53+
]
54+
const allowed_attributes = [
55+
'align',
56+
'color',
57+
'controls',
58+
'height',
59+
'href',
60+
'id',
61+
'src',
62+
'style',
63+
'target',
64+
'title',
65+
'type',
66+
'width',
67+
]
68+
const unallowed_schemas = [
69+
'javascript:',
70+
]
7371

7472
pub fn convert_markdown_to_html(code string) string {
7573
markdown_code := sanitize_markdown_code(code)
@@ -121,7 +119,7 @@ fn sanitize_html_tags_with_re(re string, code string) string {
121119
tag_name := tag_parts[0].trim_space().to_lower()
122120
tag_attributes := tag_parts[1].trim_space()
123121
tag_content := tag_parts[2].trim_space()
124-
is_allowed_tag := highlight.allowed_tags.contains(tag_name)
122+
is_allowed_tag := allowed_tags.contains(tag_name)
125123

126124
if !is_allowed_tag {
127125
result = result.replace(tag, '')
@@ -174,8 +172,8 @@ fn sanitize_html_attributes(attributes string) string {
174172
attribute_name := attribute_parts[0].trim_space().to_lower()
175173
attribute_value := attribute_parts[1].trim_space()
176174

177-
is_allowed_attribute := highlight.allowed_attributes.contains(attribute_name)
178-
is_unallowed_schemas := highlight.unallowed_schemas.any(attribute_value.starts_with(it))
175+
is_allowed_attribute := allowed_attributes.contains(attribute_name)
176+
is_unallowed_schemas := unallowed_schemas.any(attribute_value.starts_with(it))
179177

180178
if !is_allowed_attribute || is_unallowed_schemas {
181179
result = result.replace(attribute, '')

highlight/markdown_test.v

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
module highlight
22

3-
const (
4-
markdown = '<script> alert(true) </script> <!-- comment -->test'
5-
html = '<p>test</p>'
6-
)
3+
const markdown = '<script> alert(true) </script> <!-- comment -->test'
4+
const html = '<p>test</p>'
75

86
fn test_convert_markdown_to_html() {
9-
assert convert_markdown_to_html(highlight.markdown) == highlight.html
7+
assert convert_markdown_to_html(markdown) == html
108
}

highlight/python.v

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ module highlight
22

33
fn init_py() Lang {
44
return Lang{
5-
name: 'Python'
5+
name: 'Python'
66
lang_extensions: ['py', 'ipynb']
7-
line_comments: '#'
8-
string_start: ['"', "'", '"""', "'''"]
9-
color: '#3572A5'
10-
keywords: [
7+
line_comments: '#'
8+
string_start: ['"', "'", '"""', "'''"]
9+
color: '#3572A5'
10+
keywords: [
1111
'None',
1212
'True',
1313
'and',

highlight/typescript.v

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ module highlight
22

33
fn init_ts() Lang {
44
return Lang{
5-
name: 'TypeScript'
5+
name: 'TypeScript'
66
lang_extensions: ['ts', 'tsx']
7-
line_comments: '//'
8-
mline_comments: ['/*', '*/']
9-
string_start: ['"', "'"]
10-
color: '#2b7489'
11-
keywords: [
7+
line_comments: '//'
8+
mline_comments: ['/*', '*/']
9+
string_start: ['"', "'"]
10+
color: '#2b7489'
11+
keywords: [
1212
'any',
1313
'as',
1414
'boolean',

0 commit comments

Comments
 (0)