Skip to content

Commit 2a2627f

Browse files
authored
Merge pull request #4516 from handrews/event-stream-hljs
Add highlight.js support for text/event-stream
2 parents beb56e0 + ec5892b commit 2a2627f

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

scripts/md2html/md2html.js

+16
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ hljs.registerLanguage('uri', function() {
4848
],
4949
}
5050
});
51+
hljs.registerLanguage('eventstream', function() {
52+
return {
53+
contains: [
54+
{
55+
scope: "attr",
56+
begin: /^/,
57+
end: ":",
58+
},
59+
{
60+
scope: "literal",
61+
begin: /: */,
62+
end: /$/,
63+
},
64+
],
65+
}
66+
});
5167
const cheerio = require('cheerio');
5268

5369
let argv = require('yargs')

tests/md2html/fixtures/basic-new.html

+8
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@
4545
</code></pre>
4646
<pre class="nohighlight" tabindex="0"><code>https://foo.com/bar{<span class="hljs-attr">?baz*</span>,<span class="hljs-attr">qux</span>}
4747
</code></pre>
48+
<pre class="nohighlight" tabindex="0"><code><span class="hljs-attr">data:</span> This data is formatted
49+
<span class="hljs-attr">data:</span> across two lines
50+
<span class="hljs-attr">retry:</span> 5
51+
<span class="hljs-attr">
52+
event:</span> add
53+
<span class="hljs-attr">data:</span> 1234.5678
54+
<span class="hljs-attr">unknown-field:</span> this is ignored
55+
<span class="hljs-attr"></span></code></pre>
4856
</section></section><section class="appendix"><h1>Appendix A: Revision History</h1>
4957
<table>
5058
<thead>

tests/md2html/fixtures/basic-new.md

+10
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ https://foo.com/bar?baz=qux&fred=waldo#fragment
6262
https://foo.com/bar{?baz*,qux}
6363
```
6464

65+
```eventstream
66+
data: This data is formatted
67+
data: across two lines
68+
retry: 5
69+
70+
event: add
71+
data: 1234.5678
72+
unknown-field: this is ignored
73+
```
74+
6575
## Appendix A: Revision History
6676

6777
Version | Date

0 commit comments

Comments
 (0)