forked from JuroOravec/python-inline-source-2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.py
More file actions
120 lines (103 loc) · 1.98 KB
/
examples.py
File metadata and controls
120 lines (103 loc) · 1.98 KB
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
import sourcetypes
from sourcetypes import html, sql, cpp, hpp, golang, rust
test_html: html = """
<html>
<body>
<h1>Inline syntax highlighting!</h1>
</body>
</html>
"""
test_sql: sql = """
SELECT test
FROM a_table
"""
test_css: sourcetypes.css = """
body {
font-weight: bold;
color: #f00;
}
"""
test_javascript: sourcetypes.javascript = """
function() {
var text = "Some Text";
alert(text)
}
"""
test_typescript: sourcetypes.ts = """
function() {
var text = "Some Text";
alert(text)
}
"""
class x:
test_jsx: sourcetypes.jsx = """
function() {
const element = <h1>Hello, world!</h1>;
return element
}
"""
test_tsx: sourcetypes.tsx = """
function() {
const element = <h1>Hello, world!</h1>;
return element
}
"""
test_python: sourcetypes.python = """
test = "123"
def my_function():
return f"My string: {test}"
"""
test_sql2: sourcetypes.sql = """
SELECT test
FROM a_table
"""
test_html2: "html" = """
<html>
<body>
<h1>Inline syntax highlighting</h1>
</body>
</html>
"""
test_cpp: "cpp" = """
int main() {
cout << "Hello World!";
return 0;
}
"""
test_hpp: "hpp" = """
#ifndef MY_HEADER_H
#define MY_HEADER_H
void myCFunction() ;
#endif // MY_HEADER_H
"""
test_rust: "rust" = """
fn main() {
println!("Hello, world!");
}
"""
test_golang: "golang" = """
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
"""
# trs => tree-sitter
test_lsp2: sourcetypes.trs = """
(function_definition
name: (identifier) @function.name
parameters: (parameters
(typed_parameter
(asterisk) # Match the variadic argument (*nums)
(identifier) @param.name # Capture the name of the variadic parameter
type: (type (identifier)
(#eq? "int") # The type is int
)
)
)
return_type: (type (identifier)
(#eq? "int") # The return type is int
)
body: (block) @function.body # Match the body of the function (a block of statements)
)
"""