react-showdown
Advanced tools
Comparing version
@@ -14,3 +14,3 @@ import { setFlavor, getFlavor, setOption, getOption, getOptions, resetOptions, getAllExtensions, removeExtension, resetExtensions, ShowdownExtension } from 'showdown'; | ||
resetOptions: typeof resetOptions; | ||
setExtension: (name: string, ext: ShowdownExtension | (() => ShowdownExtension | ShowdownExtension[]) | ShowdownExtension[]) => void; | ||
setExtension: (name: string, ext: (() => ShowdownExtension[] | ShowdownExtension) | ShowdownExtension[] | ShowdownExtension) => void; | ||
getExtension: (name: string) => ShowdownExtension[]; | ||
@@ -17,0 +17,0 @@ getAllExtensions: typeof getAllExtensions; |
@@ -51,3 +51,3 @@ 'use strict'; | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(n); | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
@@ -64,20 +64,25 @@ } | ||
function _createForOfIteratorHelperLoose(o) { | ||
var i = 0; | ||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { | ||
var it; | ||
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { | ||
if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}; | ||
} | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
i = o[Symbol.iterator](); | ||
return i.next.bind(i); | ||
it = o[Symbol.iterator](); | ||
return it.next.bind(it); | ||
} | ||
@@ -84,0 +89,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("showdown"),n=require("react"),r=(e=n)&&"object"==typeof e&&"default"in e?e.default:e,o=require("htmlparser2"),a=require("domhandler");function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function l(e){var t=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,t){if(e){if("string"==typeof e)return s(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,void 0):void 0}}(e)))return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}function u(e){var s=e.dangerouslySetInnerHTML,u=e.flavor,f=e.markdown,m=e.markup,v=e.options,y=e.extensions,g=e.components,x=e.sanitizeHtml,b=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}(e,["dangerouslySetInnerHTML","flavor","markdown","markup","options","extensions","components","sanitizeHtml"]),h=n.useMemo((function(){return function e(t,r){if("tag"===t.type&&t instanceof a.Element){var o=(null==g?void 0:g[t.name])||t.name,s=i({key:r},t.attribs);if(s.class&&!s.className&&(s.className=s.class,delete s.class),"string"==typeof s.style){var l={};s.style.split(";").forEach((function(e){if(-1!==e.indexOf(":")){var t=e.split(":"),n=t[0],r=t[1];n=n.trim().replace(/-([a-z])/g,(function(e){return e[1].toUpperCase()})),r=r.trim(),l[n]=r}})),s.style=l}var u=c.includes(t.name)?null:p.includes(t.name)?t.children.filter(d).map(e):t.children.map(e);return n.createElement(o,s,u)}if("text"===t.type&&t instanceof a.DataNode)return t.data;if("comment"===t.type)return null;if("style"===t.type&&t instanceof a.Element){var f=i({key:r},t.attribs),m=t.children.map(e);return n.createElement("style",f,m)}return console.warn('Warning: Could not map element with type "'+t.type+'".',t),null}}),[g]);s&&g&&console.warn("MarkdownView could not render custom components when dangerouslySetInnerHTML is enabled.");var E=new t.Converter;if(u&&E.setFlavor(u),v)for(var w in v){if("extensions"===w&&v.extensions)for(var O,k=l(v.extensions);!(O=k()).done;){var S=O.value;"string"==typeof S?E.useExtension(S):E.addExtension(S)}E.setOption(w,v[w])}y&&E.addExtension(y);var M=E.makeHtml(null!=f?f:m);if(x&&(M=x(M)),s)return r.createElement("div",{dangerouslySetInnerHTML:{__html:M}});var A=o.parseDOM(M,{lowerCaseTags:!1,lowerCaseAttributeNames:!1,decodeEntities:!0,recognizeSelfClosing:!0});return n.createElement("div",b,A.map(h))}var c=["area","br","col","embed","hr","img","input","keygen","param","source","track","wbr"],p=["table","thead","tbody","tr"];function d(e){return!("text"===e.type&&e instanceof a.DataNode)||e.data.trim().length>0}var f=u;exports.GlobalConfiguration={setFlavor:t.setFlavor,getFlavor:t.getFlavor,setOption:t.setOption,getOption:t.getOption,getOptions:t.getOptions,resetOptions:t.resetOptions,setExtension:t.extension,getExtension:t.extension,getAllExtensions:t.getAllExtensions,removeExtension:t.removeExtension,resetExtensions:t.resetExtensions},exports.Markdown=f,exports.default=u; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("showdown"),n=require("react"),r=(e=n)&&"object"==typeof e&&"default"in e?e.default:e,o=require("htmlparser2"),a=require("domhandler");function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function l(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return s(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function u(e){var s=e.dangerouslySetInnerHTML,u=e.flavor,f=e.markdown,m=e.markup,v=e.options,y=e.extensions,g=e.components,b=e.sanitizeHtml,x=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}(e,["dangerouslySetInnerHTML","flavor","markdown","markup","options","extensions","components","sanitizeHtml"]),h=n.useMemo((function(){return function e(t,r){if("tag"===t.type&&t instanceof a.Element){var o=(null==g?void 0:g[t.name])||t.name,s=i({key:r},t.attribs);if(s.class&&!s.className&&(s.className=s.class,delete s.class),"string"==typeof s.style){var l={};s.style.split(";").forEach((function(e){if(-1!==e.indexOf(":")){var t=e.split(":"),n=t[0],r=t[1];n=n.trim().replace(/-([a-z])/g,(function(e){return e[1].toUpperCase()})),r=r.trim(),l[n]=r}})),s.style=l}var u=c.includes(t.name)?null:p.includes(t.name)?t.children.filter(d).map(e):t.children.map(e);return n.createElement(o,s,u)}if("text"===t.type&&t instanceof a.DataNode)return t.data;if("comment"===t.type)return null;if("style"===t.type&&t instanceof a.Element){var f=i({key:r},t.attribs),m=t.children.map(e);return n.createElement("style",f,m)}return console.warn('Warning: Could not map element with type "'+t.type+'".',t),null}}),[g]);s&&g&&console.warn("MarkdownView could not render custom components when dangerouslySetInnerHTML is enabled.");var E=new t.Converter;if(u&&E.setFlavor(u),v)for(var w in v){if("extensions"===w&&v.extensions)for(var O,k=l(v.extensions);!(O=k()).done;){var S=O.value;"string"==typeof S?E.useExtension(S):E.addExtension(S)}E.setOption(w,v[w])}y&&E.addExtension(y);var M=E.makeHtml(null!=f?f:m);if(b&&(M=b(M)),s)return r.createElement("div",{dangerouslySetInnerHTML:{__html:M}});var A=o.parseDOM(M,{lowerCaseTags:!1,lowerCaseAttributeNames:!1,decodeEntities:!0,recognizeSelfClosing:!0});return n.createElement("div",x,A.map(h))}var c=["area","br","col","embed","hr","img","input","keygen","param","source","track","wbr"],p=["table","thead","tbody","tr"];function d(e){return!("text"===e.type&&e instanceof a.DataNode)||e.data.trim().length>0}var f=u;exports.GlobalConfiguration={setFlavor:t.setFlavor,getFlavor:t.getFlavor,setOption:t.setOption,getOption:t.getOption,getOptions:t.getOptions,resetOptions:t.resetOptions,setExtension:t.extension,getExtension:t.extension,getAllExtensions:t.getAllExtensions,removeExtension:t.removeExtension,resetExtensions:t.resetExtensions},exports.Markdown=f,exports.default=u; | ||
//# sourceMappingURL=react-showdown.cjs.production.min.js.map |
@@ -44,3 +44,3 @@ import { Converter, setFlavor, getFlavor, setOption, getOption, getOptions, resetOptions, getAllExtensions, removeExtension, resetExtensions, extension } from 'showdown'; | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(n); | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
@@ -57,20 +57,25 @@ } | ||
function _createForOfIteratorHelperLoose(o) { | ||
var i = 0; | ||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { | ||
var it; | ||
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { | ||
if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}; | ||
} | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
i = o[Symbol.iterator](); | ||
return i.next.bind(i); | ||
it = o[Symbol.iterator](); | ||
return it.next.bind(it); | ||
} | ||
@@ -77,0 +82,0 @@ |
{ | ||
"name": "react-showdown", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Render React components within markdown and markdown as React components!", | ||
@@ -64,5 +64,6 @@ "license": "MIT", | ||
"dependencies": { | ||
"htmlparser2": "^4.1.0", | ||
"htmlparser2": "^6.0.1", | ||
"domhandler": "^4.0.0", | ||
"showdown": "^1.9.1" | ||
} | ||
} |
@@ -18,3 +18,3 @@ # react-showdown [![Build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url] [![Dependency Status][dependency-image]][dependency-url] | ||
* New in 2.1: | ||
* Fixes [https://github.com/jerolimov/react-showdown/issues/54]: Missing content after a self-closing component. This was fixed by setting the default value of showdown config `recognizeSelfClosing` to `true`. Thanks [@n1ru4l](https://github.com/n1ru4l) | ||
* Fixes [#54](https://github.com/jerolimov/react-showdown/issues/54): Missing content after a self-closing component. This was fixed by setting the default value of showdown config `recognizeSelfClosing` to `true`. Thanks [@n1ru4l](https://github.com/n1ru4l) | ||
* New feature: add new optional `sanitizeHtml` prop for sanitizing html before it was rendered. Thanks [@n1ru4l](https://github.com/n1ru4l) aswell. | ||
@@ -21,0 +21,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
83743
0.57%1134
0.89%4
33.33%+ Added
+ Added
- Removed
- Removed
Updated