Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@
"markdown": {
"title": "Markdown",
"require": "markup",
"optional": "yaml",
"alias": "md",
"owner": "Golmote"
},
Expand Down
13 changes: 13 additions & 0 deletions components/prism-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@

Prism.languages.markdown = Prism.languages.extend('markup', {});
Prism.languages.insertBefore('markdown', 'prolog', {
'front-matter-block': {
pattern: /(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,
lookbehind: true,
greedy: true,
inside: {
'punctuation': /^---|---$/,
'font-matter': {
pattern: /\S+(?:\s+\S+)*/,
alias: ['yaml', 'language-yaml'],
inside: Prism.languages.yaml
}
}
},
'blockquote': {
// > ...
pattern: /^>(?:[\t ]*>)*/m,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-markdown.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions tests/languages/markdown/front-matter-block_empty_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
---

# Title

---
normal paragraph

---

----------------------------------------------------

[
["front-matter-block", [
["punctuation", "---"],
["punctuation", "---"]
]],

["title", [
["punctuation", "#"],
" Title"
]],

["hr", "---"],
"\r\nnormal paragraph\r\n\r\n",

["hr", "---"]
]
31 changes: 31 additions & 0 deletions tests/languages/markdown/front-matter-block_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
layout: post
title: Blogging Like a Hacker
---

# Title

---
normal paragraph

---

----------------------------------------------------

[
["front-matter-block", [
["punctuation", "---"],
["font-matter", "layout: post\r\ntitle: Blogging Like a Hacker"],
["punctuation", "---"]
]],

["title", [
["punctuation", "#"],
" Title"
]],

["hr", "---"],
"\r\nnormal paragraph\r\n\r\n",

["hr", "---"]
]
24 changes: 24 additions & 0 deletions tests/languages/yaml+markdown/front-matter_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
layout: post
title: Blogging Like a Hacker
---

# Title

----------------------------------------------------

[
["front-matter-block", [
["punctuation", "---"],
["font-matter", [
["key", "layout"], ["punctuation", ":"], " post\n",
["key", "title"], ["punctuation", ":"], " Blogging Like a Hacker"
]],
["punctuation", "---"]
]],

["title", [
["punctuation", "#"],
" Title"
]]
]