Skip to content

Commit bbc77d1

Browse files
Added support for URIs (#2708)
1 parent b37987d commit bbc77d1

18 files changed

+708
-94
lines changed

components.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,8 @@
501501
"css",
502502
"javascript",
503503
"json",
504-
"markup"
504+
"markup",
505+
"uri"
505506
],
506507
"owner": "danielgtaylor"
507508
},
@@ -1210,6 +1211,14 @@
12101211
"alias": ["uscript", "uc"],
12111212
"owner": "RunDevelopment"
12121213
},
1214+
"uri": {
1215+
"title": "URI",
1216+
"alias": "url",
1217+
"aliasTitles": {
1218+
"url": "URL"
1219+
},
1220+
"owner": "RunDevelopment"
1221+
},
12131222
"v": {
12141223
"title": "V",
12151224
"require": "clike",

components/prism-http.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
'request-target': {
1313
pattern: /^(\s)(?:https?:\/\/|\/)\S*(?=\s)/,
1414
lookbehind: true,
15-
alias: 'url'
15+
alias: 'url',
16+
inside: Prism.languages.uri
1617
},
1718
// HTTP Version
1819
'http-version': {

components/prism-http.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/prism-uri.js

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// https://tools.ietf.org/html/rfc3986#appendix-A
2+
3+
Prism.languages.uri = {
4+
'scheme': {
5+
pattern: /^[a-z][a-z0-9+.-]*:/im,
6+
greedy: true,
7+
inside: {
8+
'scheme-delimiter': /:$/
9+
}
10+
},
11+
'fragment': {
12+
pattern: /#[\w\-.~!$&'()*+,;=%:@/?]*/,
13+
inside: {
14+
'fragment-delimiter': /^#/
15+
}
16+
},
17+
'query': {
18+
pattern: /\?[\w\-.~!$&'()*+,;=%:@/?]*/,
19+
inside: {
20+
'query-delimiter': {
21+
pattern: /^\?/,
22+
greedy: true
23+
},
24+
'pair-delimiter': /[&;]/,
25+
'pair': {
26+
pattern: /^[^=][\s\S]*/,
27+
inside: {
28+
'key': /^[^=]+/,
29+
'value': {
30+
pattern: /(^=)[\s\S]+/,
31+
lookbehind: true
32+
}
33+
}
34+
}
35+
}
36+
},
37+
'authority': {
38+
pattern: RegExp(
39+
/^\/\//.source
40+
// [ userinfo "@" ]
41+
+ /(?:[\w\-.~!$&'()*+,;=%:]*@)?/.source
42+
// host
43+
+ (
44+
'(?:'
45+
// IP-literal
46+
+ /\[(?:[0-9a-fA-F:.]{2,48}|v[0-9a-fA-F]+\.[\w\-.~!$&'()*+,;=]+)\]/.source
47+
+ '|'
48+
// IPv4address or registered name
49+
+ /[\w\-.~!$&'()*+,;=%]*/.source
50+
+ ')'
51+
)
52+
// [ ":" port ]
53+
+ /(?::\d*)?/.source,
54+
'm'
55+
),
56+
inside: {
57+
'authority-delimiter': /^\/\//,
58+
'user-info-segment': {
59+
pattern: /^[\w\-.~!$&'()*+,;=%:]*@/,
60+
inside: {
61+
'user-info-delimiter': /@$/,
62+
'user-info': /^[\w\-.~!$&'()*+,;=%:]+/
63+
}
64+
},
65+
'port-segment': {
66+
pattern: /:\d*$/,
67+
inside: {
68+
'port-delimiter': /^:/,
69+
'port': /^\d+/
70+
}
71+
},
72+
'host': {
73+
pattern: /[\s\S]+/,
74+
inside: {
75+
'ip-literal': {
76+
pattern: /^\[[\s\S]+\]$/,
77+
inside: {
78+
'ip-literal-delimiter': /^\[|\]$/,
79+
'ipv-future': /^v[\s\S]+/,
80+
'ipv6-address': /^[\s\S]+/
81+
}
82+
},
83+
'ipv4-address': /^(?:(?:[03-9]\d?|[12]\d{0,2})\.){3}(?:[03-9]\d?|[12]{0,2})$/
84+
}
85+
}
86+
}
87+
},
88+
'path': {
89+
pattern: /^[\w\-.~!$&'()*+,;=%:@/]+/m,
90+
inside: {
91+
'path-separator': /\//
92+
}
93+
}
94+
};
95+
96+
Prism.languages.url = Prism.languages.uri;

components/prism-uri.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-uri.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<h2>Full example</h2>
2+
<pre><code>https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top
3+
https://example.com/path/resource.txt#fragment
4+
ldap://[2001:db8::7]/c=GB?objectClass?one
5+
mailto:John.Doe@example.com
6+
news:comp.infosystems.www.servers.unix
7+
tel:+1-816-555-1212
8+
telnet://192.0.2.16:80/
9+
urn:oasis:names:specification:docbook:dtd:xml:4.1.2
10+
//example.com/path/resource.txt
11+
/path/resource.txt
12+
path/resource.txt
13+
</code></pre>

plugins/autoloader/prism-autoloader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@
224224
"tsconfig": "typoscript",
225225
"uscript": "unrealscript",
226226
"uc": "unrealscript",
227+
"url": "uri",
227228
"vb": "visual-basic",
228229
"vba": "visual-basic",
229230
"xeoracube": "xeora",

plugins/autoloader/prism-autoloader.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/show-language/prism-show-language.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@
199199
"tsconfig": "TSConfig",
200200
"uscript": "UnrealScript",
201201
"uc": "UnrealScript",
202+
"uri": "URI",
203+
"url": "URL",
202204
"vbnet": "VB.Net",
203205
"vhdl": "VHDL",
204206
"vim": "vim",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy