1
1
{
2
- name: ["github_markdown", ".markdown", ".md" , ".mkd", ".mkdn", ".mdtxt", ".mdown "]
2
+ name: ["GitHub Flavored Markdown" , ".md "]
3
3
ignoreCase: false
4
4
colors: [
5
5
"title", #E06C75, #E06C75
6
6
"escape" > "strEscape"
7
- "ordered_list" > "number"
8
- "unordered_list" > "number"
9
- "short_code" > "string"
10
- "code_block", #7050E0, #835CBD
7
+ "list" > "number"
8
+ "footnote", #4493F8, #4493F8
9
+ "math_short" > "meta"
10
+ "code_short" > "string"
11
+ "code_block", #7050E0, #7050E0
11
12
"syntax_name", #871094, #A64EAD
12
- "code_content", #BABABA , #BABABA
13
+ "code_content", #AA9AB8 , #AA9AB8
13
14
"quote_note", #2F81F7, #2F81F7
14
15
"quote_note_text", #2F81F7, #2F81F7
15
16
"quote_tip", #238636, #238636
22
23
"quote_caution_text", #F85149, #F85149
23
24
"quote_text", #777, #858F9A
24
25
"quote_background", #DDD, #444
25
- "感叹号 ", #E8BF6A , #E8BF6A
26
+ "exclamation_mark ", #FF7000 , #D2B72D
26
27
"url_text", #508090, #58908A
27
28
"url_title" > "string"
28
29
"url", #508090, #58908A
29
- "括号 ", #999, #999
30
+ "bracket ", #999, #999
30
31
"split_line", #FFF000, #BBB529
31
32
]
32
33
// github可以使用html标签,注释后不渲染
33
34
comment: {startsWith: "<!--", endsWith: "-->"}
34
35
35
- // 暂时不打算适配制表符(因为会有bug/: )
36
+ // 暂时不打算适配制表符(因为会有bug)
36
37
defines: [
37
38
// (?m) ^匹配每行开头
38
- // 不使用是因为会导致代码块不渲染,优化暂时搁置
39
+ // 但这里使用会导致代码块不渲染
39
40
"prefix": /(?:^|\n) */
40
- "title": {match: include("prefix") + /#{1,6} .*/, 0: "title"}
41
- "escape": {match: /\\./, 0: "escape"}
41
+
42
+ // lineBackground有点bug暂时没法用include
43
+ // "quoteBackground": /(?m)^ *>.*/
42
44
43
- // 实现了基本渲染,暂时搁置优化匹配
44
- "link": {match: /(!)?(\[)(.*)(\])(\()(.*?)( ".*?")?(\)) /, 1 : "感叹号" 2: "括号" 3: "url_text" 4: "括号" 5: "括号" 6: "url" 7: "url_title" 8: "括号 "}
45
-
46
- "setextTitle": {match: /(?m)^.+(?<!^-+|=+)\n^(=+|-+)$/, 0: "title"}
47
- // "setextTitle": {match: /(?m)^\s^(?:.+\n){1,}^( {0,3}|-{3,}|={3,}) {0,}$/, recordAllGroups: true, 0: "title"}
45
+ "title": [
46
+ {match: /(?m)^ {0,3}#{1,6} .* /, 0 : "title "}
47
+ // setext 标题
48
+ {match: /(?m)^.+(?<!^-+|=+)\n^(=+|-+)$/, 0: "title"}
49
+ ]
48
50
49
51
"splitLine": {match: /(?m)^(\s*?$|[-=]*)^ {0,3}(\*{3,}|-{3,}|_{3,}) {0,}$/, 0: "split_line"}
52
+ "escape": {match: /\\[!"#$%&'()*+,-.\\\/:;<=>?@\[\]\^_`{|}~]/, 0: "escape"}
53
+
54
+ // 实现了基本渲染,暂时搁置优化
55
+ // 感觉已经没必要再改了……改复杂了不说,逻辑和效果也会变,暂时就这样
56
+ "link": {match: /(!)?(\[)(.*)(\])(\()(.*?)( ".*?")?(\))/, 1: "exclamation_mark" 2: "bracket" 3: "url_text" 4: "bracket" 5: "bracket" 6: "url" 7: "url_title" 8: "bracket"}
57
+
58
+ "all_list": [
59
+ {match: include("prefix") + /[1-9][0-9]*\. /}
60
+ {match: include("prefix") + /[*+-] /}
61
+ ]
62
+
63
+ "list": [
64
+ {start: {include: "all_list"}
65
+ end: {match: /(?m)$/}
66
+ color: "list"
67
+ matchEndFirst: true
68
+ contains: [
69
+ {include: "escape"}
70
+ {include: "footnote"}
71
+ {include: "link"}
72
+ ]}
73
+ ]
74
+
75
+ // LaTeX
76
+ "math": [
77
+ {start: {match: /\$/, 0: "math_short"}
78
+ end: {match: /(?m)\$|$/, 0: "math_short"}
79
+ color: "string"
80
+ matchEndFirst: true
81
+ contains: {
82
+ {match: /\\\$/, 0: "escape"}
83
+ }}
84
+ ]
85
+
86
+ "quote": [
87
+ {match: /(?m)^> *\[(!)(?:(NOTE)|(TIP)|(IMPORTANT)|(WARNING)|(CAUTION))\](?:\n>(.*))+/, recordAllGroups: true,0: "quote_text" 1: "exclamation_mark" 2: "quote_note_text" 3: "quote_tip_text" 4: "quote_important_text" 5: "quote_warning_text" 6: "quote_caution_text" 7: "default"}
88
+ {match: /(?m)^ *>.*/, 0: "quote_text"}
89
+ ]
50
90
51
- // 有点bug暂时没法用
52
- // "quoteBackground": include("prefix") + />.*/
91
+ "footnote": [
92
+ {match: /(?m)^\[\^.+?\]: /, 0: "footnote"}
93
+ {match: /\[\^.+?\]/, 0: "footnote"}
94
+ ]
53
95
]
54
96
55
- // lineBackground: {match: include("quoteBackground"), color: "quote_background"}
56
- lineBackground: {match: /(?m)^ *>.*/, color: "quote_background"}
57
-
97
+ // ##################################################################
58
98
// 取消注释下行,为分割线添加背景
59
99
// lineBackground: {match: /^( {0,3}\*{3,}|-{3,}|_{3,})$/, color: "default"}
100
+ // ##################################################################
101
+
102
+ // lineBackground: {match: include("quoteBackground"), color: "quote_background"}
103
+ lineBackground: {match: /(?m)^ *>.*/, color: "quote_background"}
60
104
61
105
contains: [
106
+ // 这样写是为了后续方便调整顺序,以最佳顺序高亮语法,避免bug
62
107
{include: "title"}
63
- {include: "setextTitle"}
64
108
{include: "link"}
65
109
{include: "escape"}
110
+ {include: "footnote"}
111
+ {include: "math"}
66
112
{include: "splitLine"}
67
- {match: include("prefix") + /[1-9][0-9]*\. .*/, 0: "ordered_list"}
68
- {match: include("prefix") + /[*+-] .*/, 0: "unordered_list"}
69
- {match: /> *\[(!)(?:(NOTE)|(TIP)|(IMPORTANT)|(WARNING)|(CAUTION))\](?:\n>(.*))+/, recordAllGroups: true,0: "quote_text" 1: "感叹号" 2: "quote_note_text" 3: "quote_tip_text" 4: "quote_important_text" 5: "quote_warning_text" 6: "quote_caution_text" 7: "default"}
70
- {match: /(?m)^ *>.*/, 0: "quote_text"}
71
-
72
- // 已经把链接匹配的优化雏形放这了,等待我的后续更新吧~
73
- // 或者你也可以自行将下方代码补全
74
- // {
75
- // start: {
76
- // start: {match: /\[/}
77
- // end: {match: /\]/}
78
- // }
79
- // end: {
80
- // start: {match: /\(/}
81
- // end: {match: /\)/}
82
- // }
83
- // color: "string"
84
- // matchEndFirst: true //优先匹配结尾
85
- // contains: [
86
-
87
- // ]
88
- // }
113
+ {include: "list"}
114
+ {include: "quote"}
89
115
90
116
{
91
117
start: {match: include("prefix") + /(?i)`{3}([ a-z]*)/, 0: "code_block" 1: "syntax_name"}
99
125
}
100
126
{
101
127
start: {match: /`/}
102
- end: {match: /`|$/}
103
- color: "short_code"
104
- contains: [
105
- {include: "escape"}
106
- ]
128
+ end: {match: /(?m)`|$/}
129
+ color: "code_short"
130
+ // matchEndFirst: true
131
+ // contains: [
132
+ // 以我当前水平和mt的局限性,只能做到没有`闭合的后面所有字符不渲染,但这个`还是会渲染,有能力的大牛可以自己尝试一下(: 但这又会让后面所有内容全都不渲染……放弃了):
133
+ // {match: /(?m)(?<=`).*$/, 0: "default"}
134
+ // ]
107
135
}
108
- {builtin: #ESCAPED_CHAR#}
109
136
]
110
137
}
0 commit comments