Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit af577ba

Browse files
authored
fix: 🐛 create normalize as an option (#559)
* 🐛 create normalize as an option * 🔥 no need for an extra newline * 🚨 prettier
1 parent f3afe00 commit af577ba

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/markdown/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export function plain(text, opts = options) {
143143
createElement: React.createElement,
144144
Fragment: React.Fragment,
145145
})
146-
.processSync(text).contents;
146+
.processSync(opts.normalize ? normalize(text) : text).contents;
147147
}
148148

149149
/**
@@ -179,7 +179,7 @@ export function react(text, opts = options) {
179179
img: Image(sanitize),
180180
},
181181
})
182-
.processSync(text).contents;
182+
.processSync(opts.normalize ? normalize(text) : text).contents;
183183
}
184184

185185
/**
@@ -188,15 +188,19 @@ export function react(text, opts = options) {
188188
export function html(text, opts = options) {
189189
if (!text) return null;
190190

191-
return parseMarkdown(opts).use(rehypeStringify).processSync(text).contents;
191+
return parseMarkdown(opts)
192+
.use(rehypeStringify)
193+
.processSync(opts.normalize ? normalize(text) : text).contents;
192194
}
193195

194196
/**
195197
* convert markdown to an mdast object
196198
*/
197199
export function ast(text, opts = options) {
198200
if (!text) return null;
199-
return parseMarkdown(opts).use(remarkStringify, opts.markdownOptions).parse(text);
201+
return parseMarkdown(opts)
202+
.use(remarkStringify, opts.markdownOptions)
203+
.parse(opts.normalize ? normalize(text) : text);
200204
}
201205

202206
/**

0 commit comments

Comments
 (0)