Skip to content

Commit 84cc8d8

Browse files
committed
Refactor internals to escape smarter
1 parent 8ea3942 commit 84cc8d8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ function value(token) {
8989
* Extension for `mdast-util-to-markdown`.
9090
*/
9191
export function frontmatterToMarkdown(options) {
92-
// To do: use an extension object with `satisfies` later.
9392
/** @type {ToMarkdownExtension['unsafe']} */
9493
const unsafe = []
9594
/** @type {ToMarkdownExtension['handlers']} */
@@ -104,8 +103,13 @@ export function frontmatterToMarkdown(options) {
104103
// Typing those is the responsibility of the end user.
105104
handlers[matter.type] = handler(matter)
106105

107-
// To do: idea: perhaps make this smarter, with an `after` of the second char?
108-
unsafe.push({atBreak: true, character: fence(matter, 'open').charAt(0)})
106+
const open = fence(matter, 'open')
107+
108+
unsafe.push({
109+
atBreak: true,
110+
character: open.charAt(0),
111+
after: open.charAt(1)
112+
})
109113
}
110114

111115
return {unsafe, handlers}

0 commit comments

Comments
 (0)