Skip to content

Commit 15a45b4

Browse files
authored
Merge branch 'master' into yaml_highlight_fix
2 parents a2a2c16 + c7c561d commit 15a45b4

File tree

5 files changed

+24
-0
lines changed

5 files changed

+24
-0
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Language Improvements:
5757
- enh(plaintext) added `text` and `txt` as alias (#2360) [Taufik Nurrohman][]
5858
- enh(powershell) added PowerShell v5.1/v7 default aliases as "built_in"s (#2423) [Sean Williams][]
5959
- fix(yaml) Fix tags to include non-word characters (#2486) [Peter Plantinga][]
60+
- enh(yaml) added support for timestamps (#2475) [Peter Plantinga][]
6061

6162
Developer Tools:
6263

SUPPORTED_LANGUAGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Languages that listed a **Package** below are 3rd party languages and are not bu
4242
| Cap’n Proto | capnproto, capnp | |
4343
| Clojure | clojure, clj | |
4444
| CoffeeScript | coffeescript, coffee, cson, iced | |
45+
| CpcdosC+ | cpc | [highlightjs-cpcdos](https://github.com/SPinti-Software/highlightjs-cpcdos) |
4546
| Crmsh | crmsh, crm, pcmk | |
4647
| Crystal | crystal, cr | |
4748
| Cypher (Neo4j) | cypher | [highlightjs-cypher](https://github.com/highlightjs/highlightjs-cypher) |
@@ -177,6 +178,7 @@ Languages that listed a **Package** below are 3rd party languages and are not bu
177178
| Test Anything Protocol | tap | |
178179
| Thrift | thrift | |
179180
| TP | tp | |
181+
| Transact-SQL | tsql | [highlightjs-tsql](https://github.com/highlightjs/highlightjs-tsql) |
180182
| Twig | twig, craftcms | |
181183
| TypeScript | typescript, ts | |
182184
| VB.Net | vbnet, vb | |

src/languages/yaml.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ export default function(hljs) {
4747
]
4848
};
4949

50+
var DATE_RE = '[0-9]{4}(-[0-9][0-9]){0,2}';
51+
var TIME_RE = '([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?';
52+
var FRACTION_RE = '(\\.[0-9]*)?';
53+
var ZONE_RE = '([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?';
54+
var TIMESTAMP = {
55+
className: 'number',
56+
begin: '\\b' + DATE_RE + TIME_RE + FRACTION_RE + ZONE_RE + '\\b',
57+
}
58+
5059
return {
5160
name: 'YAML',
5261
case_insensitive: true,
@@ -104,6 +113,7 @@ export default function(hljs) {
104113
beginKeywords: LITERALS,
105114
keywords: {literal: LITERALS}
106115
},
116+
TIMESTAMP,
107117
// numbers are any valid C-style number that
108118
// sit isolated from other words
109119
{

test/markup/yaml/numbers.expect.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33
<span class="hljs-attr">hex:</span> <span class="hljs-number">0x999fff</span>
44
<span class="hljs-attr">numkey999:</span> <span class="hljs-number">1234</span>
55
<span class="hljs-attr">exp:</span> <span class="hljs-number">-2.3e-5</span>
6+
<span class="hljs-attr">canonical:</span> <span class="hljs-number">2001-12-15T02:59:43.1Z</span>
7+
<span class="hljs-attr">iso8601:</span> <span class="hljs-number">2001-12-14t21:59:43.10-05:00</span>
8+
<span class="hljs-attr">space:</span> <span class="hljs-number">2001-12-14 21:59:43.10 -5</span>
9+
<span class="hljs-attr">nozone:</span> <span class="hljs-number">2001-12-15 2:59:43.10</span>
10+
<span class="hljs-attr">date:</span> <span class="hljs-number">2002-12-14</span>
11+

test/markup/yaml/numbers.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ not_hex: 999fff
33
hex: 0x999fff
44
numkey999: 1234
55
exp: -2.3e-5
6+
canonical: 2001-12-15T02:59:43.1Z
7+
iso8601: 2001-12-14t21:59:43.10-05:00
8+
space: 2001-12-14 21:59:43.10 -5
9+
nozone: 2001-12-15 2:59:43.10
10+
date: 2002-12-14

0 commit comments

Comments
 (0)