File tree Expand file tree Collapse file tree 1 file changed +63
-0
lines changed Expand file tree Collapse file tree 1 file changed +63
-0
lines changed Original file line number Diff line number Diff line change
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 >
You can’t perform that action at this time.
0 commit comments