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

Commit

Permalink
chore(markdown): nix loose mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rafegoldberg committed Apr 14, 2020
1 parent 27bb73d commit 82f17b2
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions packages/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,32 +83,6 @@ sanitize.tagNames.push('figcaption');
sanitize.tagNames.push('input'); // allow GitHub-style todo lists
sanitize.ancestors.input = ['li'];

const toggleLoosemode = ({ loosemode = false }) => {
if (loosemode) {
const tags = ['iframe', 'button', 'label', 'input', 'video', 'source', 'script'];
const attr = [
'id',
'style',
'class',
'height',
'width',
'src',
'name',
'checked',
'controls',
'type',
'disabled',
'placeholder',
'*',
];
tags.forEach(tag => {
sanitize.attributes[tag] = attr;
});
sanitize.tagNames.push(...tags);
sanitize.required = {};
delete sanitize.ancestors.input;
}
};
/**
* Normalize Magic Block Raw Text
*/
Expand Down Expand Up @@ -167,7 +141,6 @@ export function processor(opts = {}) {

export function plain(text, opts = options, components = {}) {
if (!text) return null;
toggleLoosemode(opts);

return processor(opts)
.use(rehypeReact, {
Expand All @@ -183,7 +156,6 @@ export function plain(text, opts = options, components = {}) {
*/
export function react(text, opts = options, components = {}) {
if (!text) return null;
toggleLoosemode(opts);

// eslint-disable-next-line react/prop-types
const PinWrap = ({ children }) => <div className="pin">{children}</div>;
Expand Down Expand Up @@ -222,7 +194,6 @@ export function react(text, opts = options, components = {}) {
*/
export function html(text, opts = options) {
if (!text) return null;
toggleLoosemode(opts);

return processor(opts)
.use(rehypeStringify)
Expand All @@ -234,7 +205,6 @@ export function html(text, opts = options) {
*/
export function ast(text, opts = options) {
if (!text) return null;
toggleLoosemode(opts);

return processor(opts)
.use(remarkStringify, opts.markdownOptions)
Expand All @@ -246,7 +216,6 @@ export function ast(text, opts = options) {
*/
export function md(tree, opts = options) {
if (!tree) return null;
toggleLoosemode(opts);

return processor(opts)
.use(remarkStringify, opts.markdownOptions)
Expand Down

0 comments on commit 82f17b2

Please sign in to comment.