Skip to content

Commit ba70085

Browse files
LingDong-Lingdong Huang
authored andcommitted
add spec page
1 parent 193fc37 commit ba70085

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

static/spec.html

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<style>
2+
:target {
3+
background: linen;
4+
}
5+
a:link {
6+
color:#248;
7+
background:transparent;
8+
text-decoration: none;
9+
}
10+
a:visited {
11+
color:#248;
12+
background:transparent;
13+
text-decoration: none;
14+
}
15+
16+
a:hover {
17+
color:#248;
18+
background:transparent;
19+
text-decoration: underline;
20+
}
21+
22+
a:active {
23+
color:#248;
24+
background:transparent;
25+
text-decoration: underline;
26+
}
27+
body{
28+
margin:50px;
29+
}
30+
</style>
31+
<script>
32+
var bnf_path = "https://raw.githubusercontent.com/LingDong-/wenyan-lang/new_compiler/antlr/cpp/wenyan.g4"
33+
34+
function rich(txt){
35+
function anchor(t,other){
36+
return `<div id="${t.trim()}">${link(t)}${other}</div>`
37+
}
38+
function link(t){
39+
return t.replace(/([A-z]+)/g,`<a href="#$1">$1</a>`)
40+
}
41+
var s = "<pre>";
42+
var txtlines = txt.split("\n");
43+
for (var i = 0; i < txtlines.length; i++){
44+
if (txtlines[i].includes(":")){
45+
var sp = txtlines[i].split(/:/);
46+
var other = ":"+link(sp[1])
47+
s += anchor(sp[0],other)
48+
49+
}else{
50+
s += `<div>${link(txtlines[i])}</div>`;
51+
}
52+
}
53+
s+="</pre>"
54+
return s
55+
}
56+
fetch(bnf_path)
57+
.then((response) => {
58+
return response.text();
59+
})
60+
.then((txt) => {
61+
document.body.innerHTML = "<i>Wenyan Language Specification</i>"+rich(txt);
62+
});
63+
</script>

0 commit comments

Comments
 (0)