-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for separate open and close markers, custom fences
- Loading branch information
Showing
27 changed files
with
709 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
'use strict'; | ||
|
||
var fence = require('./fence'); | ||
|
||
module.exports = create; | ||
|
||
function create(matter) { | ||
var type = matter.type; | ||
var marker = matter.marker; | ||
var fence = marker + marker + marker; | ||
var open = fence(matter, 'open'); | ||
var close = fence(matter, 'close'); | ||
|
||
frontmatter.displayName = type + 'FrontMatter'; | ||
|
||
return [type, frontmatter]; | ||
|
||
function frontmatter(node) { | ||
return fence + (node.value ? '\n' + node.value : '') + '\n' + fence; | ||
return open + (node.value ? '\n' + node.value : '') + '\n' + close; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
module.exports = fence; | ||
|
||
function fence(matter, prop) { | ||
var marker; | ||
|
||
if (matter.marker) { | ||
marker = pick(matter.marker, prop); | ||
return marker + marker + marker; | ||
} | ||
|
||
return pick(matter.fence, prop); | ||
} | ||
|
||
function pick(schema, prop) { | ||
return typeof schema === 'string' ? schema : schema[prop]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"type": "jsonml", "fence": "=f-e*n_c$e"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
=f-e*n_c$e | ||
{ | ||
title: "Custom", | ||
// A comment *** | ||
} | ||
=f-e*n_c$e | ||
|
||
# Deep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"type": "root", | ||
"children": [ | ||
{ | ||
"type": "jsonml", | ||
"value": "{\n title: \"Custom\",\n // A comment ***\n}", | ||
"position": { | ||
"start": { | ||
"line": 1, | ||
"column": 1, | ||
"offset": 0 | ||
}, | ||
"end": { | ||
"line": 6, | ||
"column": 11, | ||
"offset": 63 | ||
}, | ||
"indent": [ | ||
1, | ||
1, | ||
1, | ||
1, | ||
1 | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "heading", | ||
"depth": 1, | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"value": "Deep", | ||
"position": { | ||
"start": { | ||
"line": 8, | ||
"column": 3, | ||
"offset": 67 | ||
}, | ||
"end": { | ||
"line": 8, | ||
"column": 7, | ||
"offset": 71 | ||
}, | ||
"indent": [] | ||
} | ||
} | ||
], | ||
"position": { | ||
"start": { | ||
"line": 8, | ||
"column": 1, | ||
"offset": 65 | ||
}, | ||
"end": { | ||
"line": 8, | ||
"column": 7, | ||
"offset": 71 | ||
}, | ||
"indent": [] | ||
} | ||
} | ||
], | ||
"position": { | ||
"start": { | ||
"line": 1, | ||
"column": 1, | ||
"offset": 0 | ||
}, | ||
"end": { | ||
"line": 9, | ||
"column": 1, | ||
"offset": 72 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"type": "jsonml", "fence": {"open": "$$OPEN", "close": "CLOSE##"}}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
$$OPEN | ||
{ | ||
title: "Custom", | ||
// A comment *** | ||
} | ||
CLOSE## | ||
# Deep |
Oops, something went wrong.