remark-slate
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -269,3 +269,5 @@ 'use strict'; | ||
if (children !== BREAK_TAG && isLeafNode(chunk)) { | ||
if (chunk.bold && chunk.italic) { | ||
if (chunk.strikeThrough && chunk.bold && chunk.italic) { | ||
children = retainWhitespaceAndFormat(children, '~~***'); | ||
} else if (chunk.bold && chunk.italic) { | ||
children = retainWhitespaceAndFormat(children, '***'); | ||
@@ -280,6 +282,6 @@ } else { | ||
} | ||
} | ||
if (chunk.strikeThrough) { | ||
children = "~~" + children + "~~"; | ||
if (chunk.strikeThrough) { | ||
children = retainWhitespaceAndFormat(children, '~~'); | ||
} | ||
} | ||
@@ -353,4 +355,6 @@ } | ||
var children = frozenString; | ||
var fullFormat = "" + format + children + format; // This conditions accounts for no whitespace in our string | ||
var children = frozenString; // We reverse the right side formatting, to properly handle bold/italic and strikeThrough | ||
// formats, so we can create ~~***FooBar***~~ | ||
var fullFormat = "" + format + children + reverseStr(format); // This conditions accounts for no whitespace in our string | ||
// if we don't have any, we can return early. | ||
@@ -360,7 +364,8 @@ | ||
return fullFormat; | ||
} // if we do have whitespace, let's add our formatting | ||
// around our trimmed string | ||
} // if we do have whitespace, let's add our formatting around our trimmed string | ||
// We reverse the right side formatting, to properly handle bold/italic and strikeThrough | ||
// formats, so we can create ~~***FooBar***~~ | ||
var formattedString = format + children + format; // and replace the non-whitespace content of the string | ||
var formattedString = format + children + reverseStr(format); // and replace the non-whitespace content of the string | ||
@@ -370,2 +375,6 @@ return string.replace(frozenString, formattedString); | ||
var reverseStr = function reverseStr(string) { | ||
return string.split('').reverse().join(''); | ||
}; | ||
function plugin(opts) { | ||
@@ -372,0 +381,0 @@ var compiler = function compiler(node) { |
@@ -1,2 +0,2 @@ | ||
"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 n(){return(n=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e}).apply(this,arguments)}var t={paragraph:"paragraph",block_quote:"block_quote",code_block:"code_block",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 o,c,u;void 0===r&&(r={nodeTypes:{}});var d=n({},t,r.nodeTypes,{heading:n({},t.heading,null===(o=r)||void 0===o||null===(c=o.nodeTypes)||void 0===c?void 0:c.heading)}),s=[{text:""}];switch(e.children&&Array.isArray(e.children)&&e.children.length>0&&(s=e.children.map((function(t){return i(n({},t,{ordered:e.ordered||!1}),r)}))),e.type){case"heading":return{type:d.heading[e.depth||1],children:s};case"list":return{type:e.ordered?d.ol_list:d.ul_list,children:s};case"listItem":return{type:d.listItem,children:s};case"paragraph":return{type:d.paragraph,children:s};case"link":return{type:d.link,link:e.url,children:s};case"blockquote":return{type:d.block_quote,children:s};case"code":return{type:d.code_block,language:e.lang,children:[{text:e.value}]};case"html":var p;return(null===(u=e.value)||void 0===u?void 0:u.includes("<br>"))?{break:!0,type:d.paragraph,children:[{text:(null===(p=e.value)||void 0===p?void 0:p.replace(/<br>/g,""))||""}]}:{type:"parapgraph",children:[{text:""}]};case"emphasis":return n({italic:!0},a(s),l(s));case"strong":return n({bold:!0},a(s),l(s));case"delete":return n({strikeThrough:!0},a(s),l(s));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(n){"children"!==n&&"type"!==n&&"text"!==n&&(e[n]=r[n])})),e}),{})}var o=function(e){return"string"==typeof e.text};function c(e,r){var n=e.trim();return n.length===e.length?""+r+n+r:e.replace(n,r+n+r)}exports.default=function(e){this.Compiler=function(r){return r.children.map((function(r){return i(r,e)}))}},exports.defaultNodeTypes=t,exports.deserialize=i,exports.serialize=function e(i,a){void 0===a&&(a={nodeTypes:t});var l=a.nodeTypes,u=void 0===l?t:l,d=a.ignoreParagraphNewline,s=void 0!==d&&d,p=a.listDepth,h=void 0===p?0:p,g=i.text||"",y=i.type||"",f=n({},t,u,{heading:n({},t.heading,u.heading)}),v=[f.ul_list,f.ol_list],_=g;if(o(i)||(_=i.children.map((function(r){var t=!o(r)&&v.includes(r.type||""),a=v.includes(i.type||""),l=!1;return!o(i)&&Array.isArray(i.children)&&(l=i.children.some((function(e){return!o(e)&&e.type===f.link}))),e(n({},r,{parentType:y}),{nodeTypes:f,ignoreParagraphNewline:(s||t||a||l)&&!r.break,listDepth:v.includes(r.type||"")?h+1:h})})).join("")),s||""!==g&&"\n"!==g||i.parentType!==f.paragraph||(y=f.paragraph,_="<br>"),""!==_)switch("<br>"!==_&&o(i)&&(i.bold&&i.italic?_=c(_,"***"):(i.bold&&(_=c(_,"**")),i.italic&&(_=c(_,"_"))),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.code_block:return"```"+(i.language||"")+"\n"+_+"\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&&i.parentType===f.ol_list,k="",x=0;h>x;x++)k+=b?" ":" ";return k+(b?"1.":"-")+" "+_;case f.paragraph:return _+"\n";default:return r(_)}}; | ||
"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",code_block:"code_block",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 o,u,c;void 0===r&&(r={nodeTypes:{}});var d=t({},n,r.nodeTypes,{heading:t({},n.heading,null===(o=r)||void 0===o||null===(u=o.nodeTypes)||void 0===u?void 0:u.heading)}),s=[{text:""}];switch(e.children&&Array.isArray(e.children)&&e.children.length>0&&(s=e.children.map((function(n){return i(t({},n,{ordered:e.ordered||!1}),r)}))),e.type){case"heading":return{type:d.heading[e.depth||1],children:s};case"list":return{type:e.ordered?d.ol_list:d.ul_list,children:s};case"listItem":return{type:d.listItem,children:s};case"paragraph":return{type:d.paragraph,children:s};case"link":return{type:d.link,link:e.url,children:s};case"blockquote":return{type:d.block_quote,children:s};case"code":return{type:d.code_block,language:e.lang,children:[{text:e.value}]};case"html":var p;return(null===(c=e.value)||void 0===c?void 0:c.includes("<br>"))?{break:!0,type:d.paragraph,children:[{text:(null===(p=e.value)||void 0===p?void 0:p.replace(/<br>/g,""))||""}]}:{type:"parapgraph",children:[{text:""}]};case"emphasis":return t({italic:!0},a(s),l(s));case"strong":return t({bold:!0},a(s),l(s));case"delete":return t({strikeThrough:!0},a(s),l(s));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 o=function(e){return"string"==typeof e.text};function u(e,r){var t=e.trim(),n=t,i=""+r+n+c(r);if(n.length===e.length)return i;var a=r+n+c(r);return e.replace(t,a)}var c=function(e){return e.split("").reverse().join("")};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,c=void 0===l?n:l,d=a.ignoreParagraphNewline,s=void 0!==d&&d,p=a.listDepth,h=void 0===p?0:p,g=i.text||"",y=i.type||"",v=t({},n,c,{heading:t({},n.heading,c.heading)}),f=[v.ul_list,v.ol_list],_=g;if(o(i)||(_=i.children.map((function(r){var n=!o(r)&&f.includes(r.type||""),a=f.includes(i.type||""),l=!1;return!o(i)&&Array.isArray(i.children)&&(l=i.children.some((function(e){return!o(e)&&e.type===v.link}))),e(t({},r,{parentType:y}),{nodeTypes:v,ignoreParagraphNewline:(s||n||a||l)&&!r.break,listDepth:f.includes(r.type||"")?h+1:h})})).join("")),s||""!==g&&"\n"!==g||i.parentType!==v.paragraph||(y=v.paragraph,_="<br>"),""!==_)switch("<br>"!==_&&o(i)&&(i.strikeThrough&&i.bold&&i.italic?_=u(_,"~~***"):i.bold&&i.italic?_=u(_,"***"):(i.bold&&(_=u(_,"**")),i.italic&&(_=u(_,"_")),i.strikeThrough&&(_=u(_,"~~")))),y){case v.heading[1]:return"# "+_+"\n";case v.heading[2]:return"## "+_+"\n";case v.heading[3]:return"### "+_+"\n";case v.heading[4]:return"#### "+_+"\n";case v.heading[5]:return"##### "+_+"\n";case v.heading[6]:return"###### "+_+"\n";case v.block_quote:return"> "+_+"\n\n";case v.code_block:return"```"+(i.language||"")+"\n"+_+"\n```\n";case v.link:return"["+_+"]("+(i.link||"")+")";case v.ul_list:case v.ol_list:return"\n"+_+"\n";case v.listItem:for(var b=i&&i.parentType===v.ol_list,k="",x=0;h>x;x++)k+=b?" ":" ";return k+(b?"1.":"-")+" "+_;case v.paragraph:return _+"\n";default:return r(_)}}; | ||
//# sourceMappingURL=remark-slate.cjs.production.min.js.map |
@@ -263,3 +263,5 @@ import escapeHtml from 'escape-html'; | ||
if (children !== BREAK_TAG && isLeafNode(chunk)) { | ||
if (chunk.bold && chunk.italic) { | ||
if (chunk.strikeThrough && chunk.bold && chunk.italic) { | ||
children = retainWhitespaceAndFormat(children, '~~***'); | ||
} else if (chunk.bold && chunk.italic) { | ||
children = retainWhitespaceAndFormat(children, '***'); | ||
@@ -274,6 +276,6 @@ } else { | ||
} | ||
} | ||
if (chunk.strikeThrough) { | ||
children = "~~" + children + "~~"; | ||
if (chunk.strikeThrough) { | ||
children = retainWhitespaceAndFormat(children, '~~'); | ||
} | ||
} | ||
@@ -347,4 +349,6 @@ } | ||
var children = frozenString; | ||
var fullFormat = "" + format + children + format; // This conditions accounts for no whitespace in our string | ||
var children = frozenString; // We reverse the right side formatting, to properly handle bold/italic and strikeThrough | ||
// formats, so we can create ~~***FooBar***~~ | ||
var fullFormat = "" + format + children + reverseStr(format); // This conditions accounts for no whitespace in our string | ||
// if we don't have any, we can return early. | ||
@@ -354,7 +358,8 @@ | ||
return fullFormat; | ||
} // if we do have whitespace, let's add our formatting | ||
// around our trimmed string | ||
} // if we do have whitespace, let's add our formatting around our trimmed string | ||
// We reverse the right side formatting, to properly handle bold/italic and strikeThrough | ||
// formats, so we can create ~~***FooBar***~~ | ||
var formattedString = format + children + format; // and replace the non-whitespace content of the string | ||
var formattedString = format + children + reverseStr(format); // and replace the non-whitespace content of the string | ||
@@ -364,2 +369,6 @@ return string.replace(frozenString, formattedString); | ||
var reverseStr = function reverseStr(string) { | ||
return string.split('').reverse().join(''); | ||
}; | ||
function plugin(opts) { | ||
@@ -366,0 +375,0 @@ var compiler = function compiler(node) { |
{ | ||
"name": "remark-slate", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "remark plugin to compile Markdown to a slate compatible object", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -137,3 +137,5 @@ import escapeHtml from 'escape-html'; | ||
if (children !== BREAK_TAG && isLeafNode(chunk)) { | ||
if (chunk.bold && chunk.italic) { | ||
if (chunk.strikeThrough && chunk.bold && chunk.italic) { | ||
children = retainWhitespaceAndFormat(children, '~~***'); | ||
} else if (chunk.bold && chunk.italic) { | ||
children = retainWhitespaceAndFormat(children, '***'); | ||
@@ -148,6 +150,6 @@ } else { | ||
} | ||
} | ||
if (chunk.strikeThrough) { | ||
children = `~~${children}~~`; | ||
if (chunk.strikeThrough) { | ||
children = retainWhitespaceAndFormat(children, '~~'); | ||
} | ||
} | ||
@@ -221,3 +223,5 @@ } | ||
const fullFormat = `${format}${children}${format}`; | ||
// We reverse the right side formatting, to properly handle bold/italic and strikeThrough | ||
// formats, so we can create ~~***FooBar***~~ | ||
const fullFormat = `${format}${children}${reverseStr(format)}`; | ||
@@ -230,5 +234,6 @@ // This conditions accounts for no whitespace in our string | ||
// if we do have whitespace, let's add our formatting | ||
// around our trimmed string | ||
const formattedString = format + children + format; | ||
// if we do have whitespace, let's add our formatting around our trimmed string | ||
// We reverse the right side formatting, to properly handle bold/italic and strikeThrough | ||
// formats, so we can create ~~***FooBar***~~ | ||
const formattedString = format + children + reverseStr(format); | ||
@@ -238,1 +243,3 @@ // and replace the non-whitespace content of the string | ||
} | ||
const reverseStr = (string: string) => string.split('').reverse().join(''); |
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
109250
1191