Skip to content

Commit 5cf9cfb

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

File tree

7 files changed

+99
-2
lines changed

7 files changed

+99
-2
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: 1 addition & 0 deletions
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

Lines changed: 13 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 0 deletions
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+
]
Lines changed: 31 additions & 0 deletions
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+
]
Lines changed: 24 additions & 0 deletions
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)
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