-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
126 lines (117 loc) · 5.83 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Wenyan Lang | Monaco Editor</title>
<!-- Necessarily Declarations -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!-- Mobile Display Declarations -->
<meta name="apple-touch-fullscreen" content="yes">
<meta name="theme-color" content="#3E4551">
<!-- Desktop App Declarations -->
<meta name="msapplication-TileColor" content="#3E4551">
<style>
body{
margin: 0;
}
#vscode_container{
height: 100vh;
width: 100vw;
opacity: 0;
transition: .2s ease-out .0s;
}
</style>
</head>
<body>
<div id="vscode_container">
<div id="vscode" style="height:100%;"></div>
</div>
<script src="https://acm.njupt.edu.cn/static/library/jquery/dist/jquery.min.js"></script>
<script src="https://acm.njupt.edu.cn/static/library/monaco-editor/min/vs/loader.js"></script>
<script>
window.addEventListener("load",function() {
function load(name) {
let xhr = new XMLHttpRequest(),
okStatus = document.location.protocol === "file:" ? 0 : 200;
xhr.open('GET', name, false);
xhr.overrideMimeType("text/html;charset=utf-8");
xhr.send(null);
return xhr.status === okStatus ? xhr.responseText : null;
}
require.config({ paths: { 'vs': 'https://acm.njupt.edu.cn//static/library/monaco-editor/min/vs' }});
window.MonacoEnvironment = {
getWorkerUrl: function(workerId, label) {
return `data:text/javascript;charset=utf-8,${encodeURIComponent(`
self.MonacoEnvironment = {
baseUrl: 'https://acm.njupt.edu.cn//static/library/monaco-editor/min/'
};
importScripts('https://acm.njupt.edu.cn//static/library/monaco-editor/min/vs/base/worker/workerMain.js');`
)}`;
}
};
require(["vs/editor/editor.main"], function () {
monaco.editor.defineTheme('noj-dark', {
base: 'vs-dark',
inherit: true,
rules: [
{ token: 'keywordControl', foreground: 'c586c0' },
]
});
monaco.languages.register({ id: 'wenyan' });
monaco.languages.setMonarchTokensProvider('wenyan', {
constantNumeric: "又|負|零|一|二|三|四|五|六|七|八|九|十|百|千|萬|億|兆|京|垓|秭|穣|溝|澗|正|載|極|恆河沙|阿僧祇|那由他|不可思議|無量大數|分|釐|毫|絲|忽|微|纖|沙|塵|埃|渺|漠|模糊|逡巡|須臾|瞬息|彈指|剎那|六德|虛|空|清|淨",
constantBoolean: "陰|陽",
keywordsModifier: "吾有|今有|有",
keywordsType: "數|列|言|術|爻|物",
keywordsControl: "恆為是|若非|若|者|夫|乃得|乃歸空無|是謂|之術也|必先得|是術曰|乃行是術曰|欲行是術|也|云云|凡|中之|恆為是|為是|遍|乃止|其物如是",
keywordsOperator: "等於|不等於|不大於|不小於|大於|小於|吾嘗觀|之書|方悟|之義|加|減|乘|除|中有陽乎|中無陰乎|變|所餘幾何|以|於|之長|之|充|銜|其餘|昔之|今|是矣|其|不復存矣|是",
keywordsOther: "書之|名之曰|施|曰|噫|取|矣",
tokenizer: {
root: [
[/(注曰|疏曰|批曰)。「「/, 'comment', '@blockComment'],
[/(注曰|疏曰|批曰).*$/, 'comment'],
[/「「/, 'string', '@string'],
[/「/, 'variable.name', '@variableName'],
[/。/, 'delimiter'],
[/@constantNumeric/, "number"],
[/@constantBoolean/, "constant"],
[/@keywordsModifier/, "keyword"],
[/@keywordsType/, "type"],
[/@keywordsControl/, "keywordControl"],
[/@keywordsOperator/, "operators"],
[/@keywordsOther/, "keyword"],
],
blockComment:[
[/[^」]+/, 'comment'],
[/」」/, 'comment', '@pop'],
[/[」]/, 'comment']
],
string:[
[/[^」]+/, 'string'],
[/」」/, 'string', '@pop'],
[/[」]/, 'string']
],
variableName:[
[/[^」]+/, 'variable.name'],
[/」/, 'variable.name', '@pop']
]
},
brackets:[['「','」','bracket']]
});
editor = monaco.editor.create(document.getElementById('vscode'), {
value: load("example.wy"),
language: "wenyan",
theme: "noj-dark",
fontSize: 16,
formatOnPaste: true,
formatOnType: true,
automaticLayout: true
});
$("#vscode_container").css("opacity",1);
});
}, false);
</script>
</body>