Skip to content

Commit 049de1e

Browse files
committed
enh(markdown) add entity support
1 parent af0ded2 commit 049de1e

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Core Grammars:
2828
- fix(types) fix interface LanguageDetail > keywords [Patrick Chiu]
2929
- enh(java) add `goto` to be recognized as a keyword in Java [Alvin Joy][]
3030
- enh(bash) add keyword `sudo` [Alvin Joy][]
31+
- enh(markdown) add entity support [David Schach][] [TaraLei][]
3132

3233
New Grammars:
3334

@@ -62,6 +63,7 @@ Themes:
6263
[Vitaly Barilko]: https://github.com/Diversus23
6364
[Patrick Chiu]: https://github.com/patrick-kw-chiu
6465
[Alvin Joy]: https://github.com/alvinsjoy
66+
[TaraLei]: https://github.com/TaraLei
6567

6668

6769
## Version 11.9.0

src/languages/markdown.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ export default function(hljs) {
216216
end: '$'
217217
};
218218

219+
const ENTITY = {
220+
//https://spec.commonmark.org/0.31.2/#entity-references
221+
scope: 'literal',
222+
match: /&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/
223+
};
224+
219225
return {
220226
name: 'Markdown',
221227
aliases: [
@@ -233,7 +239,8 @@ export default function(hljs) {
233239
CODE,
234240
HORIZONTAL_RULE,
235241
LINK,
236-
LINK_REFERENCE
242+
LINK_REFERENCE,
243+
ENTITY
237244
]
238245
};
239246
}
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<span class="hljs-bullet">-</span> named entities: <span class="hljs-literal">&amp;amp;</span>, <span class="hljs-literal">&amp;frac34;</span>, <span class="hljs-literal">&amp;AElig;</span>
2+
<span class="hljs-bullet">-</span> decimal entities: <span class="hljs-literal">&amp;#65;</span> <span class="hljs-literal">&amp;#164;</span>
3+
<span class="hljs-bullet">-</span> hexadecimal entities: <span class="hljs-literal">&amp;#xFFFD;</span> <span class="hljs-literal">&amp;#x48;</span>.

test/markup/markdown/entity.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- named entities: &amp;, &frac34;, &AElig;
2+
- decimal entities: &#65; &#164;
3+
- hexadecimal entities: &#xFFFD; &#x48;.

0 commit comments

Comments
 (0)