Skip to content

Commit d9e8393

Browse files
committed
typst, highlighting - Add tests for new syntax higlighting options
1 parent a4e7370 commit d9e8393

6 files changed

Lines changed: 157 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Custom Theme File
3+
format:
4+
typst:
5+
keep-typ: true
6+
syntax-highlighting: custom-theme.theme
7+
_quarto:
8+
tests:
9+
typst:
10+
ensureTypstFileRegexMatches:
11+
# Custom theme has KeywordTok color from custom-theme.theme
12+
- ["#Skylighting", "#KeywordTok", 'rgb\("#008000"\)']
13+
# Should NOT have default arrow color or raw fenced blocks
14+
- ['rgb\("#003b4f"\)', "```python"]
15+
---
16+
17+
Test that `syntax-highlighting` works with a custom `.theme` file.
18+
19+
```python
20+
def hello():
21+
print("world")
22+
```
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"text-color": "#000000",
3+
"background-color": "#f8f8f8",
4+
"line-number-color": "#aaaaaa",
5+
"line-number-background-color": null,
6+
"text-styles": {
7+
"Other": {
8+
"text-color": "#007020",
9+
"background-color": null,
10+
"bold": false,
11+
"italic": false,
12+
"underline": false
13+
},
14+
"Keyword": {
15+
"text-color": "#008000",
16+
"background-color": null,
17+
"bold": true,
18+
"italic": false,
19+
"underline": false
20+
},
21+
"DataType": {
22+
"text-color": "#902000",
23+
"background-color": null,
24+
"bold": false,
25+
"italic": false,
26+
"underline": false
27+
},
28+
"String": {
29+
"text-color": "#4070a0",
30+
"background-color": null,
31+
"bold": false,
32+
"italic": false,
33+
"underline": false
34+
},
35+
"Comment": {
36+
"text-color": "#60a0b0",
37+
"background-color": null,
38+
"bold": false,
39+
"italic": true,
40+
"underline": false
41+
},
42+
"Function": {
43+
"text-color": "#06287e",
44+
"background-color": null,
45+
"bold": false,
46+
"italic": false,
47+
"underline": false
48+
}
49+
}
50+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: Highlight Style Alias
3+
format:
4+
typst:
5+
keep-typ: true
6+
highlight-style: tango
7+
_quarto:
8+
tests:
9+
typst:
10+
ensureTypstFileRegexMatches:
11+
# highlight-style (deprecated alias) should still work
12+
- ["#Skylighting", "#KeywordTok"]
13+
---
14+
Test that `highlight-style` (deprecated) still works as an alias for `syntax-highlighting`.
15+
16+
```python
17+
def hello():
18+
print("world")
19+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Native Typst Highlighting
3+
format:
4+
typst:
5+
keep-typ: true
6+
syntax-highlighting: idiomatic
7+
_quarto:
8+
tests:
9+
typst:
10+
ensureTypstFileRegexMatches:
11+
# idiomatic = native typst highlighting = raw fenced code blocks
12+
- ["```python"]
13+
# Should NOT have Skylighting tokens
14+
- ["#Skylighting", "#KeywordTok", "#StringTok"]
15+
---
16+
17+
Test that `syntax-highlighting: idiomatic` produces native typst highlighting.
18+
19+
```python
20+
def hello():
21+
print("world")
22+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: No Highlighting
3+
format:
4+
typst:
5+
keep-typ: true
6+
syntax-highlighting: none
7+
_quarto:
8+
tests:
9+
typst:
10+
ensureTypstFileRegexMatches:
11+
# none = no highlighting, plain code block
12+
- ["```"]
13+
# Should NOT have any highlighting tokens or classes on code cell
14+
- ["#Skylighting", "#KeywordTok", "```python"]
15+
---
16+
17+
Test that `syntax-highlighting: none` disables highlighting in typst.
18+
19+
```python
20+
def hello():
21+
print("world")
22+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Skylighting Style
3+
format:
4+
typst:
5+
keep-typ: true
6+
syntax-highlighting: tango
7+
_quarto:
8+
tests:
9+
typst:
10+
ensureTypstFileRegexMatches:
11+
# tango style has specific KeywordTok color
12+
- ["#Skylighting", "#KeywordTok", 'rgb\("#204a87"\)']
13+
# Should NOT have default arrow color or raw fenced blocks
14+
- ['rgb\("#003b4f"\)', "```python"]
15+
---
16+
17+
Test that `syntax-highlighting: tango` forces skylighting in typst.
18+
19+
```python
20+
def hello():
21+
print("world")
22+
```

0 commit comments

Comments
 (0)