remark-slate
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -5,2 +5,6 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var escapeHtml = _interopDefault(require('escape-html')); | ||
function _extends() { | ||
@@ -317,3 +321,3 @@ _extends = Object.assign || function (target) { | ||
default: | ||
return children; | ||
return escapeHtml(children); | ||
} | ||
@@ -320,0 +324,0 @@ } // This function handles the case of a string like this: " foo " |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(){return(e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0});var r={paragraph:"paragraph",block_quote:"block_quote",link:"link",ul_list:"ul_list",ol_list:"ol_list",listItem:"list_item",heading:{1:"heading_one",2:"heading_two",3:"heading_three",4:"heading_four",5:"heading_five",6:"heading_six"}};function t(a,l){var u,o;void 0===l&&(l={nodeTypes:{}});var s=e({},r,l.nodeTypes,{heading:e({},r.heading,null===(u=l)||void 0===u||null===(o=u.nodeTypes)||void 0===o?void 0:o.heading)}),c=[{text:""}];switch(a.children&&Array.isArray(a.children)&&a.children.length>0&&(c=a.children.map((function(r){return t(e({},r,{ordered:a.ordered||!1}),l)}))),a.type){case"heading":return{type:s.heading[a.depth||1],children:c};case"list":return{type:a.ordered?s.ol_list:s.ul_list,children:c};case"listItem":return{type:s.listItem,children:c};case"paragraph":return{type:s.paragraph,children:c};case"link":return{type:s.link,link:a.url,children:c};case"blockquote":return{type:s.block_quote,children:c};case"html":return"<br>"===a.value?{break:!0,type:s.paragraph,children:[{text:""}]}:{};case"emphasis":return e({italic:!0},n(c),i(c));case"strong":return e({bold:!0},n(c),i(c));case"delete":return e({strikeThrough:!0},n(c),i(c));case"text":default:return{text:a.value||""}}}var n=function(e){return{text:e.map((function(e){return null==e?void 0:e.text})).join("")}};function i(e){return e.reduce((function(e,r){return Object.keys(r).forEach((function(t){"children"!==t&&"type"!==t&&"text"!==t&&(e[t]=r[t])})),e}),{})}var a=function(e){return"string"==typeof e.text};function l(e,r){var t=e.trim();return t.length===e.length?""+r+t+r:e.replace(t,r+t+r)}exports.default=function(e){this.Compiler=function(r){return r.children.map((function(r){return t(r,e)}))}},exports.defaultNodeTypes=r,exports.deserialize=t,exports.serialize=function t(n,i){void 0===i&&(i={nodeTypes:r});var u=i.nodeTypes,o=void 0===u?r:u,s=i.ignoreParagraphNewline,c=void 0!==s&&s,d=i.listDepth,h=void 0===d?0:d,p=n.text||"",g=n.type||"",y=e({},r,o,{heading:e({},r.heading,o.heading)}),f=[y.ul_list,y.ol_list],v=p;if(a(n)||(v=n.children.map((function(r){var i=!a(r)&&f.includes(r.type||""),l=f.includes(n.type||""),u=!1;return!a(n)&&Array.isArray(n.children)&&(u=n.children.some((function(e){return!a(e)&&"link"===e.type}))),t(e({},r,{parentType:g}),{nodeTypes:y,ignoreParagraphNewline:(c||i||l||u)&&!r.break,listDepth:f.includes(r.type||"")?h+1:h})})).join("")),c||""!==p&&"\n"!==p||n.parentType!==y.paragraph||(g="paragraph",v="<br>"),""!==v)switch("<br>"!==v&&a(n)&&(n.bold&&n.italic?v=l(v,"***"):(n.bold&&(v=l(v,"**")),n.italic&&(v=l(v,"_"))),n.strikeThrough&&(v="~~"+v+"~~")),g){case y.heading[1]:return"# "+v+"\n";case y.heading[2]:return"## "+v+"\n";case y.heading[3]:return"### "+v+"\n";case y.heading[4]:return"#### "+v+"\n";case y.heading[5]:return"##### "+v+"\n";case y.heading[6]:return"###### "+v+"\n";case y.block_quote:return"> "+v+"\n\n";case y.link:return"["+v+"]("+(n.link||"")+")";case y.ul_list:case y.ol_list:return"\n"+v+"\n";case y.listItem:for(var _=n&&"ol_list"===n.parentType,k="",b=0;h>b;b++)k+=_?" ":" ";return k+(_?"1.":"-")+" "+v;case y.paragraph:return v+"\n";default:return v}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=(e=require("escape-html"))&&"object"==typeof e&&"default"in e?e.default:e;function t(){return(t=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var n={paragraph:"paragraph",block_quote:"block_quote",link:"link",ul_list:"ul_list",ol_list:"ol_list",listItem:"list_item",heading:{1:"heading_one",2:"heading_two",3:"heading_three",4:"heading_four",5:"heading_five",6:"heading_six"}};function i(e,r){var u,o;void 0===r&&(r={nodeTypes:{}});var s=t({},n,r.nodeTypes,{heading:t({},n.heading,null===(u=r)||void 0===u||null===(o=u.nodeTypes)||void 0===o?void 0:o.heading)}),c=[{text:""}];switch(e.children&&Array.isArray(e.children)&&e.children.length>0&&(c=e.children.map((function(n){return i(t({},n,{ordered:e.ordered||!1}),r)}))),e.type){case"heading":return{type:s.heading[e.depth||1],children:c};case"list":return{type:e.ordered?s.ol_list:s.ul_list,children:c};case"listItem":return{type:s.listItem,children:c};case"paragraph":return{type:s.paragraph,children:c};case"link":return{type:s.link,link:e.url,children:c};case"blockquote":return{type:s.block_quote,children:c};case"html":return"<br>"===e.value?{break:!0,type:s.paragraph,children:[{text:""}]}:{};case"emphasis":return t({italic:!0},a(c),l(c));case"strong":return t({bold:!0},a(c),l(c));case"delete":return t({strikeThrough:!0},a(c),l(c));case"text":default:return{text:e.value||""}}}var a=function(e){return{text:e.map((function(e){return null==e?void 0:e.text})).join("")}};function l(e){return e.reduce((function(e,r){return Object.keys(r).forEach((function(t){"children"!==t&&"type"!==t&&"text"!==t&&(e[t]=r[t])})),e}),{})}var u=function(e){return"string"==typeof e.text};function o(e,r){var t=e.trim();return t.length===e.length?""+r+t+r:e.replace(t,r+t+r)}exports.default=function(e){this.Compiler=function(r){return r.children.map((function(r){return i(r,e)}))}},exports.defaultNodeTypes=n,exports.deserialize=i,exports.serialize=function e(i,a){void 0===a&&(a={nodeTypes:n});var l=a.nodeTypes,s=void 0===l?n:l,c=a.ignoreParagraphNewline,d=void 0!==c&&c,p=a.listDepth,h=void 0===p?0:p,g=i.text||"",y=i.type||"",f=t({},n,s,{heading:t({},n.heading,s.heading)}),v=[f.ul_list,f.ol_list],_=g;if(u(i)||(_=i.children.map((function(r){var n=!u(r)&&v.includes(r.type||""),a=v.includes(i.type||""),l=!1;return!u(i)&&Array.isArray(i.children)&&(l=i.children.some((function(e){return!u(e)&&"link"===e.type}))),e(t({},r,{parentType:y}),{nodeTypes:f,ignoreParagraphNewline:(d||n||a||l)&&!r.break,listDepth:v.includes(r.type||"")?h+1:h})})).join("")),d||""!==g&&"\n"!==g||i.parentType!==f.paragraph||(y="paragraph",_="<br>"),""!==_)switch("<br>"!==_&&u(i)&&(i.bold&&i.italic?_=o(_,"***"):(i.bold&&(_=o(_,"**")),i.italic&&(_=o(_,"_"))),i.strikeThrough&&(_="~~"+_+"~~")),y){case f.heading[1]:return"# "+_+"\n";case f.heading[2]:return"## "+_+"\n";case f.heading[3]:return"### "+_+"\n";case f.heading[4]:return"#### "+_+"\n";case f.heading[5]:return"##### "+_+"\n";case f.heading[6]:return"###### "+_+"\n";case f.block_quote:return"> "+_+"\n\n";case f.link:return"["+_+"]("+(i.link||"")+")";case f.ul_list:case f.ol_list:return"\n"+_+"\n";case f.listItem:for(var b=i&&"ol_list"===i.parentType,k="",m=0;h>m;m++)k+=b?" ":" ";return k+(b?"1.":"-")+" "+_;case f.paragraph:return _+"\n";default:return r(_)}}; | ||
//# sourceMappingURL=remark-slate.cjs.production.min.js.map |
@@ -0,1 +1,3 @@ | ||
import escapeHtml from 'escape-html'; | ||
function _extends() { | ||
@@ -312,3 +314,3 @@ _extends = Object.assign || function (target) { | ||
default: | ||
return children; | ||
return escapeHtml(children); | ||
} | ||
@@ -315,0 +317,0 @@ } // This function handles the case of a string like this: " foo " |
{ | ||
"name": "remark-slate", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "remark plugin to compile Markdown to a slate compatible object", | ||
@@ -37,3 +37,6 @@ "license": "MIT", | ||
], | ||
"dependencies": {}, | ||
"dependencies": { | ||
"@types/escape-html": "^1.0.0", | ||
"escape-html": "^1.0.3" | ||
}, | ||
"devDependencies": { | ||
@@ -40,0 +43,0 @@ "eslint-plugin-prettier": "^3.1.3", |
@@ -0,1 +1,3 @@ | ||
import escapeHtml from 'escape-html'; | ||
import { defaultNodeTypes, NodeTypes } from './deserialize'; | ||
@@ -194,4 +196,5 @@ | ||
return `${children}\n`; | ||
default: | ||
return children; | ||
return escapeHtml(children); | ||
} | ||
@@ -198,0 +201,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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
99284
1105
2
2
+ Added@types/escape-html@^1.0.0
+ Addedescape-html@^1.0.3
+ Added@types/escape-html@1.0.4(transitive)
+ Addedescape-html@1.0.3(transitive)