Socket
Socket
Sign inDemoInstall

markdown-to-jsx

Package Overview
Dependencies
Maintainers
1
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-to-jsx - npm Package Compare versions

Comparing version 6.6.5 to 6.6.6

119

index.cjs.js

@@ -30,44 +30,44 @@ 'use strict';

var ATTRIBUTE_TO_JSX_PROP_MAP = {
'accesskey': 'accessKey',
'allowfullscreen': 'allowFullScreen',
'allowtransparency': 'allowTransparency',
'autocomplete': 'autoComplete',
'autofocus': 'autoFocus',
'autoplay': 'autoPlay',
'cellpadding': 'cellPadding',
'cellspacing': 'cellSpacing',
'charset': 'charSet',
'class': 'className',
'classid': 'classId',
'colspan': 'colSpan',
'contenteditable': 'contentEditable',
'contextmenu': 'contextMenu',
'crossorigin': 'crossOrigin',
'enctype': 'encType',
'for': 'htmlFor',
'formaction': 'formAction',
'formenctype': 'formEncType',
'formmethod': 'formMethod',
'formnovalidate': 'formNoValidate',
'formtarget': 'formTarget',
'frameborder': 'frameBorder',
'hreflang': 'hrefLang',
'inputmode': 'inputMode',
'keyparams': 'keyParams',
'keytype': 'keyType',
'marginheight': 'marginHeight',
'marginwidth': 'marginWidth',
'maxlength': 'maxLength',
'mediagroup': 'mediaGroup',
'minlength': 'minLength',
'novalidate': 'noValidate',
'radiogroup': 'radioGroup',
'readonly': 'readOnly',
'rowspan': 'rowSpan',
'spellcheck': 'spellCheck',
'srcdoc': 'srcDoc',
'srclang': 'srcLang',
'srcset': 'srcSet',
'tabindex': 'tabIndex',
'usemap': 'useMap'
accesskey: 'accessKey',
allowfullscreen: 'allowFullScreen',
allowtransparency: 'allowTransparency',
autocomplete: 'autoComplete',
autofocus: 'autoFocus',
autoplay: 'autoPlay',
cellpadding: 'cellPadding',
cellspacing: 'cellSpacing',
charset: 'charSet',
class: 'className',
classid: 'classId',
colspan: 'colSpan',
contenteditable: 'contentEditable',
contextmenu: 'contextMenu',
crossorigin: 'crossOrigin',
enctype: 'encType',
for: 'htmlFor',
formaction: 'formAction',
formenctype: 'formEncType',
formmethod: 'formMethod',
formnovalidate: 'formNoValidate',
formtarget: 'formTarget',
frameborder: 'frameBorder',
hreflang: 'hrefLang',
inputmode: 'inputMode',
keyparams: 'keyParams',
keytype: 'keyType',
marginheight: 'marginHeight',
marginwidth: 'marginWidth',
maxlength: 'maxLength',
mediagroup: 'mediaGroup',
minlength: 'minLength',
novalidate: 'noValidate',
radiogroup: 'radioGroup',
readonly: 'readOnly',
rowspan: 'rowSpan',
spellcheck: 'spellCheck',
srcdoc: 'srcDoc',
srclang: 'srcLang',
srcset: 'srcSet',
tabindex: 'tabIndex',
usemap: 'useMap'
};

@@ -154,3 +154,3 @@

*/
var HTML_BLOCK_ELEMENT_R = /^ *<([^ >/]+) ?([^>]*)\/{0}>\s*((?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1)[\s\S])*?)<\/\1>\n*/;
var HTML_BLOCK_ELEMENT_R = /^ *<([A-Za-z][^ >/]*) ?([^>]*)\/{0}>\s*((?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1)[\s\S])*?)<\/\1>\n*/;

@@ -162,5 +162,5 @@ var HTML_COMMENT_R = /^<!--.*?-->/;

*/
var HTML_CUSTOM_ATTR_R = /^(data|aria)-[a-z_][a-z\d_.-]*$/;
var HTML_CUSTOM_ATTR_R = /^(data|aria|x)-[a-z_][a-z\d_.-]*$/;
var HTML_SELF_CLOSING_ELEMENT_R = /^ *<([\w:]+)\s*((?:<.*?>|[^>])*)>(?!<\/\1>)\s*/;
var HTML_SELF_CLOSING_ELEMENT_R = /^ *<([A-Za-z][\w:]*)\s*((?:<.*?>|[^>])*)>(?!<\/\1>)\s*/;
var INTERPOLATION_R = /^\{.*\}$/;

@@ -197,3 +197,3 @@ var LINK_AUTOLINK_BARE_URL_R = /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/;

*/
var TRIM_HTML = /^\s*| {4,}|\s*$/g;
var TRIM_HTML = /^\s*| {4,}|\s*$/gm;

@@ -316,3 +316,2 @@ var UNESCAPE_URL_R = /\\([^0-9A-Z\s])/gi;

return value.split(/;\s?/).reduce(function (styles, kvPair) {
var key = kvPair.slice(0, kvPair.indexOf(':'));

@@ -666,5 +665,5 @@

/**
* should not contain any block-level markdown like newlines, lists, headings,
* thematic breaks, blockquotes, tables, etc
*/
* should not contain any block-level markdown like newlines, lists, headings,
* thematic breaks, blockquotes, tables, etc
*/
inline = SHOULD_RENDER_AS_BLOCK_R.test(input) === false;

@@ -932,4 +931,7 @@ }

parse: function parse(capture, _parse4, state) {
var parseFunc = capture[3].match(HTML_BLOCK_ELEMENT_R) || DETECT_BLOCK_SYNTAX.test(capture[3]) ? parseBlock : parseInline;
var trimmed = capture[3].replace(TRIM_HTML, '');
var parseFunc = DETECT_BLOCK_SYNTAX.test(trimmed) ? parseBlock : parseInline;
var noInnerParse = DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(capture[1]) !== -1;
return {

@@ -941,4 +943,6 @@ attrs: attrStringToMap(capture[2]),

*/
content: DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(capture[1]) !== -1 ? capture[3] : parseFunc(_parse4, capture[3].replace(TRIM_HTML, ''), state),
content: noInnerParse ? capture[3] : parseFunc(_parse4, trimmed, state),
noInnerParse: noInnerParse,
tag: capture[1]

@@ -951,3 +955,3 @@ };

_extends({ key: state.key }, node.attrs),
DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(node.tag) !== -1 ? node.content : output(node.content, state)
node.noInnerParse ? node.content : output(node.content, state)
);

@@ -980,5 +984,3 @@ }

react: function react(node, output, state) {
return h(node.tag, _extends({}, node.attrs, {
key: state.key
}));
return h(node.tag, _extends({}, node.attrs, { key: state.key }));
}

@@ -1317,3 +1319,6 @@ },

'td',
{ key: c, style: getTableStyle(node, c) },
{
key: c,
style: getTableStyle(node, c)
},
output(content, state)

@@ -1320,0 +1325,0 @@ );

@@ -16,44 +16,44 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var ATTRIBUTE_TO_JSX_PROP_MAP = {
'accesskey': 'accessKey',
'allowfullscreen': 'allowFullScreen',
'allowtransparency': 'allowTransparency',
'autocomplete': 'autoComplete',
'autofocus': 'autoFocus',
'autoplay': 'autoPlay',
'cellpadding': 'cellPadding',
'cellspacing': 'cellSpacing',
'charset': 'charSet',
'class': 'className',
'classid': 'classId',
'colspan': 'colSpan',
'contenteditable': 'contentEditable',
'contextmenu': 'contextMenu',
'crossorigin': 'crossOrigin',
'enctype': 'encType',
'for': 'htmlFor',
'formaction': 'formAction',
'formenctype': 'formEncType',
'formmethod': 'formMethod',
'formnovalidate': 'formNoValidate',
'formtarget': 'formTarget',
'frameborder': 'frameBorder',
'hreflang': 'hrefLang',
'inputmode': 'inputMode',
'keyparams': 'keyParams',
'keytype': 'keyType',
'marginheight': 'marginHeight',
'marginwidth': 'marginWidth',
'maxlength': 'maxLength',
'mediagroup': 'mediaGroup',
'minlength': 'minLength',
'novalidate': 'noValidate',
'radiogroup': 'radioGroup',
'readonly': 'readOnly',
'rowspan': 'rowSpan',
'spellcheck': 'spellCheck',
'srcdoc': 'srcDoc',
'srclang': 'srcLang',
'srcset': 'srcSet',
'tabindex': 'tabIndex',
'usemap': 'useMap'
accesskey: 'accessKey',
allowfullscreen: 'allowFullScreen',
allowtransparency: 'allowTransparency',
autocomplete: 'autoComplete',
autofocus: 'autoFocus',
autoplay: 'autoPlay',
cellpadding: 'cellPadding',
cellspacing: 'cellSpacing',
charset: 'charSet',
class: 'className',
classid: 'classId',
colspan: 'colSpan',
contenteditable: 'contentEditable',
contextmenu: 'contextMenu',
crossorigin: 'crossOrigin',
enctype: 'encType',
for: 'htmlFor',
formaction: 'formAction',
formenctype: 'formEncType',
formmethod: 'formMethod',
formnovalidate: 'formNoValidate',
formtarget: 'formTarget',
frameborder: 'frameBorder',
hreflang: 'hrefLang',
inputmode: 'inputMode',
keyparams: 'keyParams',
keytype: 'keyType',
marginheight: 'marginHeight',
marginwidth: 'marginWidth',
maxlength: 'maxLength',
mediagroup: 'mediaGroup',
minlength: 'minLength',
novalidate: 'noValidate',
radiogroup: 'radioGroup',
readonly: 'readOnly',
rowspan: 'rowSpan',
spellcheck: 'spellCheck',
srcdoc: 'srcDoc',
srclang: 'srcLang',
srcset: 'srcSet',
tabindex: 'tabIndex',
usemap: 'useMap'
};

@@ -140,3 +140,3 @@

*/
var HTML_BLOCK_ELEMENT_R = /^ *<([^ >/]+) ?([^>]*)\/{0}>\s*((?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1)[\s\S])*?)<\/\1>\n*/;
var HTML_BLOCK_ELEMENT_R = /^ *<([A-Za-z][^ >/]*) ?([^>]*)\/{0}>\s*((?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1)[\s\S])*?)<\/\1>\n*/;

@@ -148,5 +148,5 @@ var HTML_COMMENT_R = /^<!--.*?-->/;

*/
var HTML_CUSTOM_ATTR_R = /^(data|aria)-[a-z_][a-z\d_.-]*$/;
var HTML_CUSTOM_ATTR_R = /^(data|aria|x)-[a-z_][a-z\d_.-]*$/;
var HTML_SELF_CLOSING_ELEMENT_R = /^ *<([\w:]+)\s*((?:<.*?>|[^>])*)>(?!<\/\1>)\s*/;
var HTML_SELF_CLOSING_ELEMENT_R = /^ *<([A-Za-z][\w:]*)\s*((?:<.*?>|[^>])*)>(?!<\/\1>)\s*/;
var INTERPOLATION_R = /^\{.*\}$/;

@@ -183,3 +183,3 @@ var LINK_AUTOLINK_BARE_URL_R = /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/;

*/
var TRIM_HTML = /^\s*| {4,}|\s*$/g;
var TRIM_HTML = /^\s*| {4,}|\s*$/gm;

@@ -302,3 +302,2 @@ var UNESCAPE_URL_R = /\\([^0-9A-Z\s])/gi;

return value.split(/;\s?/).reduce(function (styles, kvPair) {
var key = kvPair.slice(0, kvPair.indexOf(':'));

@@ -652,5 +651,5 @@

/**
* should not contain any block-level markdown like newlines, lists, headings,
* thematic breaks, blockquotes, tables, etc
*/
* should not contain any block-level markdown like newlines, lists, headings,
* thematic breaks, blockquotes, tables, etc
*/
inline = SHOULD_RENDER_AS_BLOCK_R.test(input) === false;

@@ -918,4 +917,7 @@ }

parse: function parse(capture, _parse4, state) {
var parseFunc = capture[3].match(HTML_BLOCK_ELEMENT_R) || DETECT_BLOCK_SYNTAX.test(capture[3]) ? parseBlock : parseInline;
var trimmed = capture[3].replace(TRIM_HTML, '');
var parseFunc = DETECT_BLOCK_SYNTAX.test(trimmed) ? parseBlock : parseInline;
var noInnerParse = DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(capture[1]) !== -1;
return {

@@ -927,4 +929,6 @@ attrs: attrStringToMap(capture[2]),

*/
content: DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(capture[1]) !== -1 ? capture[3] : parseFunc(_parse4, capture[3].replace(TRIM_HTML, ''), state),
content: noInnerParse ? capture[3] : parseFunc(_parse4, trimmed, state),
noInnerParse: noInnerParse,
tag: capture[1]

@@ -937,3 +941,3 @@ };

_extends({ key: state.key }, node.attrs),
DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(node.tag) !== -1 ? node.content : output(node.content, state)
node.noInnerParse ? node.content : output(node.content, state)
);

@@ -966,5 +970,3 @@ }

react: function react(node, output, state) {
return h(node.tag, _extends({}, node.attrs, {
key: state.key
}));
return h(node.tag, _extends({}, node.attrs, { key: state.key }));
}

@@ -1303,3 +1305,6 @@ },

'td',
{ key: c, style: getTableStyle(node, c) },
{
key: c,
style: getTableStyle(node, c)
},
output(content, state)

@@ -1306,0 +1311,0 @@ );

@@ -12,44 +12,44 @@ /* @jsx h */

const ATTRIBUTE_TO_JSX_PROP_MAP = {
'accesskey': 'accessKey',
'allowfullscreen': 'allowFullScreen',
'allowtransparency': 'allowTransparency',
'autocomplete': 'autoComplete',
'autofocus': 'autoFocus',
'autoplay': 'autoPlay',
'cellpadding': 'cellPadding',
'cellspacing': 'cellSpacing',
'charset': 'charSet',
'class': 'className',
'classid': 'classId',
'colspan': 'colSpan',
'contenteditable': 'contentEditable',
'contextmenu': 'contextMenu',
'crossorigin': 'crossOrigin',
'enctype': 'encType',
'for': 'htmlFor',
'formaction': 'formAction',
'formenctype': 'formEncType',
'formmethod': 'formMethod',
'formnovalidate': 'formNoValidate',
'formtarget': 'formTarget',
'frameborder': 'frameBorder',
'hreflang': 'hrefLang',
'inputmode': 'inputMode',
'keyparams': 'keyParams',
'keytype': 'keyType',
'marginheight': 'marginHeight',
'marginwidth': 'marginWidth',
'maxlength': 'maxLength',
'mediagroup': 'mediaGroup',
'minlength': 'minLength',
'novalidate': 'noValidate',
'radiogroup': 'radioGroup',
'readonly': 'readOnly',
'rowspan': 'rowSpan',
'spellcheck': 'spellCheck',
'srcdoc': 'srcDoc',
'srclang': 'srcLang',
'srcset': 'srcSet',
'tabindex': 'tabIndex',
'usemap': 'useMap',
accesskey: 'accessKey',
allowfullscreen: 'allowFullScreen',
allowtransparency: 'allowTransparency',
autocomplete: 'autoComplete',
autofocus: 'autoFocus',
autoplay: 'autoPlay',
cellpadding: 'cellPadding',
cellspacing: 'cellSpacing',
charset: 'charSet',
class: 'className',
classid: 'classId',
colspan: 'colSpan',
contenteditable: 'contentEditable',
contextmenu: 'contextMenu',
crossorigin: 'crossOrigin',
enctype: 'encType',
for: 'htmlFor',
formaction: 'formAction',
formenctype: 'formEncType',
formmethod: 'formMethod',
formnovalidate: 'formNoValidate',
formtarget: 'formTarget',
frameborder: 'frameBorder',
hreflang: 'hrefLang',
inputmode: 'inputMode',
keyparams: 'keyParams',
keytype: 'keyType',
marginheight: 'marginHeight',
marginwidth: 'marginWidth',
maxlength: 'maxLength',
mediagroup: 'mediaGroup',
minlength: 'minLength',
novalidate: 'noValidate',
radiogroup: 'radioGroup',
readonly: 'readOnly',
rowspan: 'rowSpan',
spellcheck: 'spellCheck',
srcdoc: 'srcDoc',
srclang: 'srcLang',
srcset: 'srcSet',
tabindex: 'tabIndex',
usemap: 'useMap',
};

@@ -136,3 +136,3 @@

*/
const HTML_BLOCK_ELEMENT_R = /^ *<([^ >/]+) ?([^>]*)\/{0}>\s*((?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1)[\s\S])*?)<\/\1>\n*/;
const HTML_BLOCK_ELEMENT_R = /^ *<([A-Za-z][^ >/]*) ?([^>]*)\/{0}>\s*((?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1)[\s\S])*?)<\/\1>\n*/;

@@ -144,5 +144,5 @@ const HTML_COMMENT_R = /^<!--.*?-->/;

*/
const HTML_CUSTOM_ATTR_R = /^(data|aria)-[a-z_][a-z\d_.-]*$/;
const HTML_CUSTOM_ATTR_R = /^(data|aria|x)-[a-z_][a-z\d_.-]*$/;
const HTML_SELF_CLOSING_ELEMENT_R = /^ *<([\w:]+)\s*((?:<.*?>|[^>])*)>(?!<\/\1>)\s*/;
const HTML_SELF_CLOSING_ELEMENT_R = /^ *<([A-Za-z][\w:]*)\s*((?:<.*?>|[^>])*)>(?!<\/\1>)\s*/;
const INTERPOLATION_R = /^\{.*\}$/;

@@ -179,3 +179,3 @@ const LINK_AUTOLINK_BARE_URL_R = /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/;

*/
const TRIM_HTML = /^\s*| {4,}|\s*$/g;
const TRIM_HTML = /^\s*| {4,}|\s*$/gm;

@@ -201,4 +201,6 @@ const UNESCAPE_URL_R = /\\([^0-9A-Z\s])/gi;

LIST_ITEM_PREFIX +
'[^\\n]*(?:\\n' +
'(?!\\1' + LIST_BULLET + ' )[^\\n]*)*(\\n|$)',
'[^\\n]*(?:\\n' +
'(?!\\1' +
LIST_BULLET +
' )[^\\n]*)*(\\n|$)',
'gm'

@@ -210,12 +212,17 @@ );

const LIST_R = new RegExp(
'^( *)(' + LIST_BULLET + ') ' +
'[\\s\\S]+?(?:\\n{2,}(?! )' +
'(?!\\1' + LIST_BULLET + ' )\\n*' +
// the \\s*$ here is so that we can parse the inside of nested
// lists, where our content might end before we receive two `\n`s
'|\\s*\\n*$)'
'^( *)(' +
LIST_BULLET +
') ' +
'[\\s\\S]+?(?:\\n{2,}(?! )' +
'(?!\\1' +
LIST_BULLET +
' )\\n*' +
// the \\s*$ here is so that we can parse the inside of nested
// lists, where our content might end before we receive two `\n`s
'|\\s*\\n*$)'
);
const LINK_INSIDE = '(?:\\[[^\\]]*\\]|[^\\[\\]]|\\](?=[^\\[]*\\]))*';
const LINK_HREF_AND_TITLE = '\\s*<?((?:[^\\s\\\\]|\\\\.)*?)>?(?:\\s+[\'"]([\\s\\S]*?)[\'"])?\\s*';
const LINK_HREF_AND_TITLE =
'\\s*<?((?:[^\\s\\\\]|\\\\.)*?)>?(?:\\s+[\'"]([\\s\\S]*?)[\'"])?\\s*';

@@ -232,20 +239,19 @@ const LINK_R = new RegExp(

// not complete, but probably good enough
function slugify (str) {
function slugify(str) {
return str
.replace(/[ÀÁÂÃÄÅàáâãäåæÆ]/g,'a')
.replace(/[çÇ]/g,'c')
.replace(/[ðÐ]/g,'d')
.replace(/[ÈÉÊËéèêë]/g,'e')
.replace(/[ÏïÎîÍíÌì]/g,'i')
.replace(/[Ññ]/g,'n')
.replace(/[øØœŒÕõÔôÓóÒò]/g,'o')
.replace(/[ÜüÛûÚúÙù]/g,'u')
.replace(/[ŸÿÝý]/g,'y')
.replace(/[^a-z0-9- ]/gi,'')
.replace(/ /gi,'-')
.toLowerCase()
;
.replace(/[ÀÁÂÃÄÅàáâãäåæÆ]/g, 'a')
.replace(/[çÇ]/g, 'c')
.replace(/[ðÐ]/g, 'd')
.replace(/[ÈÉÊËéèêë]/g, 'e')
.replace(/[ÏïÎîÍíÌì]/g, 'i')
.replace(/[Ññ]/g, 'n')
.replace(/[øØœŒÕõÔôÓóÒò]/g, 'o')
.replace(/[ÜüÛûÚúÙù]/g, 'u')
.replace(/[ŸÿÝý]/g, 'y')
.replace(/[^a-z0-9- ]/gi, '')
.replace(/ /gi, '-')
.toLowerCase();
}
function parseTableAlignCapture (alignCapture) {
function parseTableAlignCapture(alignCapture) {
if (TABLE_RIGHT_ALIGN.test(alignCapture)) {

@@ -262,3 +268,3 @@ return 'right';

function parseTableHeader (capture, parse, state) {
function parseTableHeader(capture, parse, state) {
const headerText = capture[1]

@@ -269,6 +275,8 @@ .replace(TABLE_TRIM_PIPES, '')

return headerText.map(function (text) { return parse(text, state); });
return headerText.map(function(text) {
return parse(text, state);
});
}
function parseTableAlign (capture/*, parse, state*/) {
function parseTableAlign(capture /*, parse, state*/) {
const alignText = capture[2]

@@ -282,3 +290,3 @@ .replace(TABLE_TRIM_PIPES, '')

function parseTableCells (capture, parse, state) {
function parseTableCells(capture, parse, state) {
const rowsText = capture[3]

@@ -289,10 +297,13 @@ .replace(TABLE_TRIM_PIPES, '')

return rowsText.map(function (rowText) {
return rowText.replace(TABLE_TRIM_PIPES, '').split(TABLE_ROW_SPLIT).map(function (text) {
return parse(text.trim(), state);
});
return rowsText.map(function(rowText) {
return rowText
.replace(TABLE_TRIM_PIPES, '')
.split(TABLE_ROW_SPLIT)
.map(function(text) {
return parse(text.trim(), state);
});
});
}
function parseTable (capture, parse, state) {
function parseTable(capture, parse, state) {
state.inline = true;

@@ -312,14 +323,18 @@ const header = parseTableHeader(capture, parse, state);

function getTableStyle (node, colIndex) {
return node.align[colIndex] == null ? {} : {
textAlign: node.align[colIndex],
};
function getTableStyle(node, colIndex) {
return node.align[colIndex] == null
? {}
: {
textAlign: node.align[colIndex],
};
}
/** TODO: remove for react 16 */
function normalizeAttributeKey (key) {
function normalizeAttributeKey(key) {
const hyphenIndex = key.indexOf('-');
if (hyphenIndex !== -1 && key.match(HTML_CUSTOM_ATTR_R) === null) {
key = key.replace(CAPTURE_LETTER_AFTER_HYPHEN, function (_, letter) { return letter.toUpperCase(); });
key = key.replace(CAPTURE_LETTER_AFTER_HYPHEN, function(_, letter) {
return letter.toUpperCase();
});
}

@@ -330,10 +345,9 @@

function isInterpolation (value) {
function isInterpolation(value) {
return INTERPOLATION_R.test(value);
}
function attributeValueToJSXPropValue (key, value) {
function attributeValueToJSXPropValue(key, value) {
if (key === 'style') {
return value.split(/;\s?/).reduce(function (styles, kvPair) {
return value.split(/;\s?/).reduce(function(styles, kvPair) {
const key = kvPair.slice(0, kvPair.indexOf(':'));

@@ -343,3 +357,5 @@

// also handles PascalCasing vendor prefixes
const camelCasedKey = key.replace(/(-[a-z])/g, function toUpper (substr) {
const camelCasedKey = key.replace(/(-[a-z])/g, function toUpper(
substr
) {
return substr[1].toUpperCase();

@@ -352,5 +368,3 @@ });

return styles;
}, {});
} else if (isInterpolation(value)) {

@@ -370,8 +384,7 @@ // return as a string and let the consumer decide what to do with it

function normalizeWhitespace (source) {
function normalizeWhitespace(source) {
return source
.replace(CR_NEWLINE_R, '\n')
.replace(FORMFEED_R, '')
.replace(TAB_R, ' ')
;
.replace(TAB_R, ' ');
}

@@ -398,3 +411,3 @@

*/
function parserFor (rules) {
function parserFor(rules) {
// Sorts rules in order of increasing order, then

@@ -406,12 +419,14 @@ // ascending rule name in case of ties.

if (process.env.NODE_ENV !== 'production') {
ruleList.forEach(function (type) {
ruleList.forEach(function(type) {
let order = rules[type].order;
if (
process.env.NODE_ENV !== 'production'
&& (typeof order !== 'number' || !isFinite(order))
&& typeof console !== 'undefined'
process.env.NODE_ENV !== 'production' &&
(typeof order !== 'number' || !isFinite(order)) &&
typeof console !== 'undefined'
) {
console.warn(
'markdown-to-jsx: Invalid order for rule `' + type + '`: ' +
order
'markdown-to-jsx: Invalid order for rule `' +
type +
'`: ' +
order
);

@@ -422,3 +437,3 @@ }

ruleList.sort(function (typeA, typeB) {
ruleList.sort(function(typeA, typeB) {
let orderA = rules[typeA].order;

@@ -431,3 +446,3 @@ let orderB = rules[typeB].order;

// Then based on increasing unicode lexicographic ordering
// Then based on increasing unicode lexicographic ordering
} else if (typeA < typeB) {

@@ -440,3 +455,3 @@ return -1;

function nestedParse (source, state) {
function nestedParse(source, state) {
let result = [];

@@ -482,3 +497,3 @@

return function outerParse (source, state) {
return function outerParse(source, state) {
return nestedParse(normalizeWhitespace(source), state);

@@ -489,4 +504,4 @@ };

// Creates a match function for an inline scoped or simple element from a regex
function inlineRegex (regex) {
return function match (source, state) {
function inlineRegex(regex) {
return function match(source, state) {
if (state.inline) {

@@ -501,4 +516,4 @@ return regex.exec(source);

// basically any inline element except links
function simpleInlineRegex (regex) {
return function match (source, state) {
function simpleInlineRegex(regex) {
return function match(source, state) {
if (state.inline || state.simple) {

@@ -513,4 +528,4 @@ return regex.exec(source);

// Creates a match function for a block scoped element from a regex
function blockRegex (regex) {
return function match (source, state) {
function blockRegex(regex) {
return function match(source, state) {
if (state.inline || state.simple) {

@@ -525,4 +540,4 @@ return null;

// Creates a match function from a regex, ignoring block/inline scope
function anyScopeRegex (regex) {
return function match (source/*, state*/) {
function anyScopeRegex(regex) {
return function match(source /*, state*/) {
return regex.exec(source);

@@ -532,4 +547,4 @@ };

function reactFor (outputFunc) {
return function nestedReactOutput (ast, state) {
function reactFor(outputFunc) {
return function nestedReactOutput(ast, state) {
state = state || {};

@@ -568,8 +583,7 @@ if (Array.isArray(ast)) {

function sanitizeUrl (url) {
function sanitizeUrl(url) {
try {
const prot = decodeURIComponent(url)
.replace(/[^A-Z0-9/:]/gi, '')
.toLowerCase()
;
.toLowerCase();

@@ -589,3 +603,3 @@ if (prot.indexOf('javascript:') === 0) {

function unescapeUrl (rawUrlString) {
function unescapeUrl(rawUrlString) {
return rawUrlString.replace(UNESCAPE_URL_R, '$1');

@@ -597,3 +611,3 @@ }

*/
function parseInline (parse, content, state) {
function parseInline(parse, content, state) {
const isCurrentlyInline = state.inline || false;

@@ -612,3 +626,3 @@ const isCurrentlySimple = state.simple || false;

*/
function parseSimpleInline (parse, content, state) {
function parseSimpleInline(parse, content, state) {
const isCurrentlyInline = state.inline || false;

@@ -624,3 +638,3 @@ const isCurrentlySimple = state.simple || false;

function parseBlock (parse, content, state) {
function parseBlock(parse, content, state) {
state.inline = false;

@@ -630,3 +644,3 @@ return parse(content + '\n\n', state);

function parseCaptureInline (capture, parse, state) {
function parseCaptureInline(capture, parse, state) {
return {

@@ -637,7 +651,11 @@ content: parseInline(parse, capture[1], state),

function captureNothing () { return {}; }
function renderNothing () { return null; }
function captureNothing() {
return {};
}
function renderNothing() {
return null;
}
function ruleOutput (rules) {
return function nestedRuleOutput (ast, outputFunc, state) {
function ruleOutput(rules) {
return function nestedRuleOutput(ast, outputFunc, state) {
return rules[ast.type].react(ast, outputFunc, state);

@@ -647,7 +665,10 @@ };

function cx () {
return Array.prototype.slice.call(arguments).filter(Boolean).join(' ');
function cx() {
return Array.prototype.slice
.call(arguments)
.filter(Boolean)
.join(' ');
}
function get (src, path, fb) {
function get(src, path, fb) {
let ptr = src;

@@ -666,8 +687,7 @@ const frags = path.split('.');

function getTag (tag, overrides) {
function getTag(tag, overrides) {
const override = get(overrides, tag);
return typeof override === 'function'
? override
: get(overrides, `${tag}.component`, tag)
;
: get(overrides, `${tag}.component`, tag);
}

@@ -700,3 +720,3 @@

export function compiler (markdown, options) {
export function compiler(markdown, options) {
options = options || {};

@@ -708,13 +728,19 @@ options.overrides = options.overrides || {};

// eslint-disable-next-line no-unused-vars
function h (tag, props, ...children) {
function h(tag, props, ...children) {
const overrideProps = get(options.overrides, `${tag}.props`, {});
return createElementFn(getTag(tag, options.overrides), {
...overrideProps,
...props,
className: cx(props && props.className, overrideProps.className) || undefined,
}, ...children);
return createElementFn(
getTag(tag, options.overrides),
{
...overrideProps,
...props,
className:
cx(props && props.className, overrideProps.className) ||
undefined,
},
...children
);
}
function compile (input) {
function compile(input) {
let inline = false;

@@ -726,5 +752,5 @@

/**
* should not contain any block-level markdown like newlines, lists, headings,
* thematic breaks, blockquotes, tables, etc
*/
* should not contain any block-level markdown like newlines, lists, headings,
* thematic breaks, blockquotes, tables, etc
*/
inline = SHOULD_RENDER_AS_BLOCK_R.test(input) === false;

@@ -737,4 +763,7 @@ }

? input
: `${input.replace(TRIM_NEWLINES_AND_TRAILING_WHITESPACE_R, '')}\n\n`
, { inline }
: `${input.replace(
TRIM_NEWLINES_AND_TRAILING_WHITESPACE_R,
''
)}\n\n`,
{ inline }
)

@@ -761,29 +790,36 @@ );

function attrStringToMap (str) {
function attrStringToMap(str) {
const attributes = str.match(ATTR_EXTRACTOR_R);
return attributes ? attributes.reduce(function (map, raw, index) {
const delimiterIdx = raw.indexOf('=');
return attributes
? attributes.reduce(function(map, raw, index) {
const delimiterIdx = raw.indexOf('=');
if (delimiterIdx !== -1) {
const key = normalizeAttributeKey(raw.slice(0, delimiterIdx)).trim();
const value = unquote(raw.slice(delimiterIdx + 1).trim());
if (delimiterIdx !== -1) {
const key = normalizeAttributeKey(
raw.slice(0, delimiterIdx)
).trim();
const value = unquote(raw.slice(delimiterIdx + 1).trim());
const mappedKey = ATTRIBUTE_TO_JSX_PROP_MAP[key] || key;
const normalizedValue = map[mappedKey] = attributeValueToJSXPropValue(key, value);
const mappedKey = ATTRIBUTE_TO_JSX_PROP_MAP[key] || key;
const normalizedValue = (map[
mappedKey
] = attributeValueToJSXPropValue(key, value));
if (
HTML_BLOCK_ELEMENT_R.test(normalizedValue)
|| HTML_SELF_CLOSING_ELEMENT_R.test(normalizedValue)
) {
map[mappedKey] = React.cloneElement(
compile(normalizedValue.trim()), { key: index }
);
}
} else {
map[ATTRIBUTE_TO_JSX_PROP_MAP[raw] || raw] = true;
}
if (
HTML_BLOCK_ELEMENT_R.test(normalizedValue) ||
HTML_SELF_CLOSING_ELEMENT_R.test(normalizedValue)
) {
map[mappedKey] = React.cloneElement(
compile(normalizedValue.trim()),
{ key: index }
);
}
} else {
map[ATTRIBUTE_TO_JSX_PROP_MAP[raw] || raw] = true;
}
return map;
}, {}) : undefined;
return map;
}, {})
: undefined;
}

@@ -798,3 +834,6 @@

if (Object.prototype.toString.call(options.overrides) !== '[object Object]') {
if (
Object.prototype.toString.call(options.overrides) !==
'[object Object]'
) {
throw new Error(`markdown-to-jsx: options.overrides (second argument property) must be

@@ -822,8 +861,14 @@ undefined or an object literal with shape:

order: PARSE_PRIORITY_HIGH,
parse (capture, parse, state) {
parse(capture, parse, state) {
return {
content: parse(capture[0].replace(BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, ''), state),
content: parse(
capture[0].replace(
BLOCKQUOTE_TRIM_LEFT_MULTILINE_R,
''
),
state
),
};
},
react (node, output, state) {
react(node, output, state) {
return (

@@ -841,6 +886,4 @@ <blockquote key={state.key}>

parse: captureNothing,
react (_, __, state) {
return (
<br key={state.key} />
);
react(_, __, state) {
return <br key={state.key} />;
},

@@ -853,6 +896,4 @@ },

parse: captureNothing,
react (_, __, state) {
return (
<hr key={state.key} />
);
react(_, __, state) {
return <hr key={state.key} />;
},

@@ -864,3 +905,3 @@ },

order: PARSE_PRIORITY_MAX,
parse (capture/*, parse, state*/) {
parse(capture /*, parse, state*/) {
let content = capture[0]

@@ -875,3 +916,3 @@ .replace(/^ {4}/gm, '')

react (node, output, state) {
react(node, output, state) {
return (

@@ -890,3 +931,3 @@ <pre key={state.key}>

order: PARSE_PRIORITY_MAX,
parse (capture/*, parse, state*/) {
parse(capture /*, parse, state*/) {
return {

@@ -903,3 +944,3 @@ content: capture[3],

order: PARSE_PRIORITY_LOW,
parse (capture/*, parse, state*/) {
parse(capture /*, parse, state*/) {
return {

@@ -909,8 +950,4 @@ content: capture[2],

},
react (node, output, state) {
return (
<code key={state.key}>
{node.content}
</code>
);
react(node, output, state) {
return <code key={state.key}>{node.content}</code>;
},

@@ -925,3 +962,3 @@ },

order: PARSE_PRIORITY_MAX,
parse (capture/*, parse, state*/) {
parse(capture /*, parse, state*/) {
footnotes.push({

@@ -940,3 +977,3 @@ footnote: capture[2],

order: PARSE_PRIORITY_HIGH,
parse (capture/*, parse*/) {
parse(capture /*, parse*/) {
return {

@@ -947,8 +984,6 @@ content: capture[1],

},
react (node, output, state) {
react(node, output, state) {
return (
<a key={state.key} href={sanitizeUrl(node.target)}>
<sup key={state.key}>
{node.content}
</sup>
<sup key={state.key}>{node.content}</sup>
</a>

@@ -962,3 +997,3 @@ );

order: PARSE_PRIORITY_HIGH,
parse (capture/*, parse, state*/) {
parse(capture /*, parse, state*/) {
return {

@@ -968,3 +1003,3 @@ completed: capture[1].toLowerCase() === 'x',

},
react (node, output, state) {
react(node, output, state) {
return (

@@ -984,3 +1019,3 @@ <input

order: PARSE_PRIORITY_HIGH,
parse (capture, parse, state) {
parse(capture, parse, state) {
return {

@@ -992,3 +1027,3 @@ content: parseInline(parse, capture[2], state),

},
react (node, output, state) {
react(node, output, state) {
const Tag = `h${node.level}`;

@@ -1006,3 +1041,3 @@ return (

order: PARSE_PRIORITY_MAX,
parse (capture, parse, state) {
parse(capture, parse, state) {
return {

@@ -1022,7 +1057,11 @@ content: parseInline(parse, capture[1], state),

order: PARSE_PRIORITY_HIGH,
parse (capture, parse, state) {
const parseFunc = (
capture[3].match(HTML_BLOCK_ELEMENT_R) || DETECT_BLOCK_SYNTAX.test(capture[3])
) ? parseBlock : parseInline;
parse(capture, parse, state) {
const trimmed = capture[3].replace(TRIM_HTML, '');
const parseFunc = DETECT_BLOCK_SYNTAX.test(trimmed)
? parseBlock
: parseInline;
const noInnerParse =
DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(capture[1]) !== -1;
return {

@@ -1034,13 +1073,17 @@ attrs: attrStringToMap(capture[2]),

*/
content: DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(capture[1]) !== -1
content: noInnerParse
? capture[3]
: parseFunc(parse, capture[3].replace(TRIM_HTML, ''), state),
: parseFunc(parse, trimmed, state),
noInnerParse,
tag: capture[1],
};
},
react (node, output, state) {
react(node, output, state) {
return (
<node.tag key={state.key} {...node.attrs}>
{DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(node.tag) !== -1 ? node.content : output(node.content, state)}
{node.noInnerParse
? node.content
: output(node.content, state)}
</node.tag>

@@ -1054,3 +1097,5 @@ );

order: PARSE_PRIORITY_HIGH,
parse () { return {}; },
parse() {
return {};
},
react: renderNothing,

@@ -1065,3 +1110,3 @@ },

order: PARSE_PRIORITY_HIGH,
parse (capture/*, parse, state*/) {
parse(capture /*, parse, state*/) {
return {

@@ -1072,9 +1117,4 @@ attrs: attrStringToMap(capture[2]),

},
react (node, output, state) {
return (
<node.tag
{...node.attrs}
key={state.key}
/>
);
react(node, output, state) {
return <node.tag {...node.attrs} key={state.key} />;
},

@@ -1086,3 +1126,3 @@ },

order: PARSE_PRIORITY_HIGH,
parse (capture/*, parse, state*/) {
parse(capture /*, parse, state*/) {
return {

@@ -1094,3 +1134,3 @@ alt: capture[1],

},
react (node, output, state) {
react(node, output, state) {
return (

@@ -1110,3 +1150,3 @@ <img

order: PARSE_PRIORITY_LOW,
parse (capture, parse, state) {
parse(capture, parse, state) {
return {

@@ -1118,3 +1158,3 @@ content: parseSimpleInline(parse, capture[1], state),

},
react (node, output, state) {
react(node, output, state) {
return (

@@ -1136,8 +1176,10 @@ <a

order: PARSE_PRIORITY_MAX,
parse (capture/*, parse, state*/) {
parse(capture /*, parse, state*/) {
return {
content: [{
content: capture[1],
type: 'text',
}],
content: [
{
content: capture[1],
type: 'text',
},
],
target: capture[1],

@@ -1152,8 +1194,10 @@ type: 'link',

order: PARSE_PRIORITY_MAX,
parse (capture/*, parse, state*/) {
parse(capture /*, parse, state*/) {
return {
content: [{
content: capture[1],
type: 'text',
}],
content: [
{
content: capture[1],
type: 'text',
},
],
target: capture[1],

@@ -1169,3 +1213,3 @@ title: undefined,

order: PARSE_PRIORITY_MAX,
parse (capture/*, parse, state*/) {
parse(capture /*, parse, state*/) {
let address = capture[1];

@@ -1180,6 +1224,8 @@ let target = capture[1];

return {
content: [{
content: address.replace('mailto:', ''),
type: 'text',
}],
content: [
{
content: address.replace('mailto:', ''),
type: 'text',
},
],
target: target,

@@ -1192,3 +1238,3 @@ type: 'link',

list: {
match (source, state, prevCapture) {
match(source, state, prevCapture) {
// We only want to break into a list if we are at the start of a

@@ -1214,3 +1260,3 @@ // line. This is to avoid parsing "hi * there" with "* there"

order: PARSE_PRIORITY_HIGH,
parse (capture, parse, state) {
parse(capture, parse, state) {
const bullet = capture[2];

@@ -1226,3 +1272,3 @@ const ordered = bullet.length > 1;

let lastItemWasAParagraph = false;
const itemContent = items.map(function (item, i) {
const itemContent = items.map(function(item, i) {
// We need to see how far indented the item is:

@@ -1249,3 +1295,3 @@ const space = LIST_ITEM_PREFIX_R.exec(item)[0].length;

// * as is this
const isLastItem = (i === items.length - 1);
const isLastItem = i === items.length - 1;
const containsBlocks = content.indexOf('\n\n') !== -1;

@@ -1259,4 +1305,4 @@

// from our previous element).
const thisItemIsAParagraph = containsBlocks ||
(isLastItem && lastItemWasAParagraph);
const thisItemIsAParagraph =
containsBlocks || (isLastItem && lastItemWasAParagraph);
lastItemWasAParagraph = thisItemIsAParagraph;

@@ -1276,3 +1322,6 @@

state.inline = false;
adjustedContent = content.replace(LIST_ITEM_END_R, '\n\n');
adjustedContent = content.replace(
LIST_ITEM_END_R,
'\n\n'
);
} else {

@@ -1298,3 +1347,3 @@ state.inline = true;

},
react (node, output, state) {
react(node, output, state) {
const Tag = node.ordered ? 'ol' : 'ul';

@@ -1304,8 +1353,4 @@

<Tag key={state.key} start={node.start}>
{node.items.map(function generateListItem (item, i) {
return (
<li key={i}>
{output(item, state)}
</li>
);
{node.items.map(function generateListItem(item, i) {
return <li key={i}>{output(item, state)}</li>;
})}

@@ -1321,3 +1366,5 @@ </Tag>

parse: captureNothing,
react (/*node, output, state*/) { return '\n'; },
react(/*node, output, state*/) {
return '\n';
},
},

@@ -1329,8 +1376,4 @@

parse: parseCaptureInline,
react (node, output, state) {
return (
<p key={state.key}>
{output(node.content, state)}
</p>
);
react(node, output, state) {
return <p key={state.key}>{output(node.content, state)}</p>;
},

@@ -1342,3 +1385,3 @@ },

order: PARSE_PRIORITY_MAX,
parse (capture/*, parse*/) {
parse(capture /*, parse*/) {
refs[capture[1]] = {

@@ -1357,3 +1400,3 @@ target: capture[2],

order: PARSE_PRIORITY_MAX,
parse (capture) {
parse(capture) {
return {

@@ -1364,3 +1407,3 @@ alt: capture[1] || undefined,

},
react (node, output, state) {
react(node, output, state) {
return (

@@ -1380,3 +1423,3 @@ <img

order: PARSE_PRIORITY_MAX,
parse (capture, parse, state) {
parse(capture, parse, state) {
return {

@@ -1387,3 +1430,3 @@ content: parse(capture[1], state),

},
react (node, output, state) {
react(node, output, state) {
return (

@@ -1405,3 +1448,3 @@ <a

parse: parseTable,
react (node, output, state) {
react(node, output, state) {
return (

@@ -1411,3 +1454,6 @@ <table key={state.key}>

<tr>
{node.header.map(function generateHeaderCell (content, i) {
{node.header.map(function generateHeaderCell(
content,
i
) {
return (

@@ -1427,8 +1473,17 @@ <th

<tbody>
{node.cells.map(function generateTableRow (row, i) {
{node.cells.map(function generateTableRow(row, i) {
return (
<tr key={i}>
{row.map(function generateTableCell (content, c) {
{row.map(function generateTableCell(
content,
c
) {
return (
<td key={c} style={getTableStyle(node, c)}>
<td
key={c}
style={getTableStyle(
node,
c
)}
>
{output(content, state)}

@@ -1454,3 +1509,3 @@ </td>

order: PARSE_PRIORITY_MIN,
parse (capture/*, parse, state*/) {
parse(capture /*, parse, state*/) {
return {

@@ -1460,3 +1515,3 @@ content: capture[0],

},
react (node/*, output, state*/) {
react(node /*, output, state*/) {
return node.content;

@@ -1470,3 +1525,3 @@ },

parse: parseCaptureInline,
react (node, output, state) {
react(node, output, state) {
return (

@@ -1483,3 +1538,3 @@ <strong key={state.key}>

order: PARSE_PRIORITY_LOW,
parse (capture, parse, state) {
parse(capture, parse, state) {
return {

@@ -1489,8 +1544,4 @@ content: parse(capture[2] || capture[1], state),

},
react (node, output, state) {
return (
<em key={state.key}>
{output(node.content, state)}
</em>
);
react(node, output, state) {
return <em key={state.key}>{output(node.content, state)}</em>;
},

@@ -1506,3 +1557,3 @@ },

order: PARSE_PRIORITY_HIGH,
parse (capture/*, parse, state*/) {
parse(capture /*, parse, state*/) {
return {

@@ -1519,8 +1570,4 @@ content: capture[1],

parse: parseCaptureInline,
react (node, output, state) {
return (
<del key={state.key}>
{output(node.content, state)}
</del>
);
react(node, output, state) {
return <del key={state.key}>{output(node.content, state)}</del>;
},

@@ -1547,6 +1594,7 @@ },

<footer>
{footnotes.map(function createFootnote (def) {
{footnotes.map(function createFootnote(def) {
return (
<div id={def.identifier} key={def.identifier}>
{def.identifier}{emitter(parser(def.footnote, { inline: true }))}
{def.identifier}
{emitter(parser(def.footnote, { inline: true }))}
</div>

@@ -1572,3 +1620,3 @@ );

export default function Markdown ({ children, options, ...props }) {
export default function Markdown({ children, options, ...props }) {
return React.cloneElement(compiler(children, options), props);

@@ -1575,0 +1623,0 @@ }

@@ -6,3 +6,3 @@ {

"license": "MIT",
"version": "6.6.5",
"version": "6.6.6",
"engines": {

@@ -48,2 +48,3 @@ "node": ">= 4"

"eslint": "^4.12.1",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-react": "^7.5.1",

@@ -50,0 +51,0 @@ "in-publish": "^2.0.0",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc