Skip to content

Commit 5cf9cfb

Browse files
authoredNov 25, 2020
Markdown: Added support for YAML front matter (#2634)
1 parent 8fa8dd2 commit 5cf9cfb

7 files changed

+99
-2
lines changed
 

‎components.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎components.json

+1
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@
703703
"markdown": {
704704
"title": "Markdown",
705705
"require": "markup",
706+
"optional": "yaml",
706707
"alias": "md",
707708
"owner": "Golmote"
708709
},

‎components/prism-markdown.js

+13
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@
2626

2727
Prism.languages.markdown = Prism.languages.extend('markup', {});
2828
Prism.languages.insertBefore('markdown', 'prolog', {
29+
'front-matter-block': {
30+
pattern: /(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,
31+
lookbehind: true,
32+
greedy: true,
33+
inside: {
34+
'punctuation': /^---|---$/,
35+
'font-matter': {
36+
pattern: /\S+(?:\s+\S+)*/,
37+
alias: ['yaml', 'language-yaml'],
38+
inside: Prism.languages.yaml
39+
}
40+
}
41+
},
2942
'blockquote': {
3043
// > ...
3144
pattern: /^>(?:[\t ]*>)*/m,

‎components/prism-markdown.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
---
3+
4+
# Title
5+
6+
---
7+
normal paragraph
8+
9+
---
10+
11+
----------------------------------------------------
12+
13+
[
14+
["front-matter-block", [
15+
["punctuation", "---"],
16+
["punctuation", "---"]
17+
]],
18+
19+
["title", [
20+
["punctuation", "#"],
21+
" Title"
22+
]],
23+
24+
["hr", "---"],
25+
"\r\nnormal paragraph\r\n\r\n",
26+
27+
["hr", "---"]
28+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
layout: post
3+
title: Blogging Like a Hacker
4+
---
5+
6+
# Title
7+
8+
---
9+
normal paragraph
10+
11+
---
12+
13+
----------------------------------------------------
14+
15+
[
16+
["front-matter-block", [
17+
["punctuation", "---"],
18+
["font-matter", "layout: post\r\ntitle: Blogging Like a Hacker"],
19+
["punctuation", "---"]
20+
]],
21+
22+
["title", [
23+
["punctuation", "#"],
24+
" Title"
25+
]],
26+
27+
["hr", "---"],
28+
"\r\nnormal paragraph\r\n\r\n",
29+
30+
["hr", "---"]
31+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
layout: post
3+
title: Blogging Like a Hacker
4+
---
5+
6+
# Title
7+
8+
----------------------------------------------------
9+
10+
[
11+
["front-matter-block", [
12+
["punctuation", "---"],
13+
["font-matter", [
14+
["key", "layout"], ["punctuation", ":"], " post\n",
15+
["key", "title"], ["punctuation", ":"], " Blogging Like a Hacker"
16+
]],
17+
["punctuation", "---"]
18+
]],
19+
20+
["title", [
21+
["punctuation", "#"],
22+
" Title"
23+
]]
24+
]

0 commit comments

Comments
 (0)