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

Commit

Permalink
fix: 🐛 create normalize as an option (#559)
Browse files Browse the repository at this point in the history
* 🐛 create normalize as an option

* 🔥 no need for an extra newline

* 🚨 prettier
  • Loading branch information
dok authored Mar 23, 2020
1 parent f3afe00 commit af577ba
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export function plain(text, opts = options) {
createElement: React.createElement,
Fragment: React.Fragment,
})
.processSync(text).contents;
.processSync(opts.normalize ? normalize(text) : text).contents;
}

/**
Expand Down Expand Up @@ -179,7 +179,7 @@ export function react(text, opts = options) {
img: Image(sanitize),
},
})
.processSync(text).contents;
.processSync(opts.normalize ? normalize(text) : text).contents;
}

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

return parseMarkdown(opts).use(rehypeStringify).processSync(text).contents;
return parseMarkdown(opts)
.use(rehypeStringify)
.processSync(opts.normalize ? normalize(text) : text).contents;
}

/**
* convert markdown to an mdast object
*/
export function ast(text, opts = options) {
if (!text) return null;
return parseMarkdown(opts).use(remarkStringify, opts.markdownOptions).parse(text);
return parseMarkdown(opts)
.use(remarkStringify, opts.markdownOptions)
.parse(opts.normalize ? normalize(text) : text);
}

/**
Expand Down

0 comments on commit af577ba

Please sign in to comment.