Skip to content

Commit 265ff35

Browse files
committed
Add robots.txt support
Closes #9
1 parent 839081e commit 265ff35

File tree

5 files changed

+96
-1
lines changed

5 files changed

+96
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ code --install-extension install EdwinKofler.vscode-assorted-languages
1111
## Language Support
1212

1313
<!-- block-start -->
14-
1514
- asl (`.asl`, `.dsl`)
1615
- asm-intel-x86-generic (`.asm`, `.nasm`, `.yasm`, `.inc`, `.s`)
1716
- m4 (`configure.ac`, `configure.in`, `.m4`)
@@ -65,6 +64,7 @@ code --install-extension install EdwinKofler.vscode-assorted-languages
6564
- textproto (`.pbtxt`, `.prototxt`, `.textproto`)
6665
- qlik (`.qvs`)
6766
- hlsl (`.sf`)
67+
- robots-txt
6868
- stylus (`.styl`, `.stylus`)
6969
- sxhkdrc (`.sxhkdrc.conf`)
7070
- systemd-unit (`.link`, `.netdev`, `.network`, `.service`, `.socket`, `.device`, `.mount`, `.automount`, `.swap`, `.target`, `.path`, `.timer`, `.snapshot`, `.slice`, `.scope`)
@@ -84,6 +84,7 @@ code --install-extension install EdwinKofler.vscode-assorted-languages
8484

8585
## Acknowledgements
8686

87+
- [vscode-robots-dot-txt-support](https://github.com/BeardedFish/vscode-robots-dot-txt-support) by BeardedFish (MIT)
8788
- [vscode-asl](https://github.com/marysaka/vscode-asl) by marysaka (MIT)
8889
- [x86_64-assembly-vscode](https://github.com/13xforever/x86_64-assembly-vscode) by 13xforever (MIT)
8990
- [vscode_autotools](https://github.com/maelvls/vscode_autotools) by maelvls (GPL-3.0)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"comments": {
3+
"lineComment": "#"
4+
},
5+
"folding": {
6+
"markers": {
7+
"start": "^User-agent:",
8+
"end": "^\\s*$"
9+
}
10+
},
11+
"indentationRules": {
12+
"increaseIndentPattern": "^User-agent:",
13+
"decreaseIndentPattern": "^\\s*$"
14+
}
15+
}

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,14 @@
656656
".sf"
657657
]
658658
},
659+
{
660+
"id": "robots-txt",
661+
"filenames": [
662+
"robots.txt",
663+
"robots-txt"
664+
],
665+
"configuration": "./language-configuration/robots-txt.language-configuration.json"
666+
},
659667
{
660668
"id": "stylus",
661669
"aliases": [
@@ -1170,6 +1178,11 @@
11701178
"scopeName": "source.qvs",
11711179
"path": "./syntaxes/qlik.tmLanguage.json"
11721180
},
1181+
{
1182+
"language": "robots-txt",
1183+
"scopeName": "text.robots-txt",
1184+
"path": "./syntaxes/robots-txt.tmLanguage.json"
1185+
},
11731186
{
11741187
"language": "stylus",
11751188
"scopeName": "source.stylus",
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tmLanguage.json",
3+
"name": "robots.txt",
4+
"patterns": [
5+
{
6+
"include": "#comment"
7+
},
8+
{
9+
"include": "#rule-block"
10+
}
11+
],
12+
"repository": {
13+
"comment": {
14+
"patterns": [
15+
{
16+
"name": "comment.line.number-sign.robots-txt",
17+
"match": "#.*$"
18+
}
19+
]
20+
},
21+
"rule-block": {
22+
"patterns": [
23+
{
24+
"match": "(?i)^([\\s*a-zA-Z0-9-/\\\\.]+\\s*)(:)?\\s*([^\\#]*)",
25+
"captures": {
26+
"1": {
27+
"name": "constant.language.robots-txt",
28+
"patterns": [
29+
{
30+
"name": "invalid.illegal.directive.robots-txt",
31+
"match": "(?i)^(?!\\s*(allow|crawl-delay|disallow|host|sitemap|user-agent)\\s*$).*"
32+
}
33+
]
34+
},
35+
"2": {
36+
"name": "punctuation.colon.robots-txt"
37+
},
38+
"3": {
39+
"name": "string.unquoted.value.robots-txt",
40+
"patterns": [
41+
{
42+
"match": "-?\\d+(\\.\\d+)?",
43+
"name": "constant.numeric.robots-txt"
44+
},
45+
{
46+
"match": "true|false",
47+
"name": "constant.language.robots-txt"
48+
}
49+
]
50+
}
51+
}
52+
}
53+
]
54+
}
55+
},
56+
"scopeName": "text.robots-txt"
57+
}

testdata/robots.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
User-agent: *
2+
Disallow: /
3+
4+
User-agent: *
5+
Disallow: /~joe/junk.html
6+
Disallow: /~joe/foo.html
7+
Disallow: /~joe/bar.html
8+
9+
# this is a comment

0 commit comments

Comments
 (0)