New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

remark-slate

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-slate - npm Package Compare versions

Comparing version 1.8.3 to 1.8.5

dist/ast-types.d.ts

79

dist/deserialize.d.ts

@@ -1,76 +0,5 @@

export interface NodeTypes {
paragraph: string;
block_quote: string;
code_block: string;
link: string;
image: string;
ul_list: string;
ol_list: string;
listItem: string;
heading: {
1: string;
2: string;
3: string;
4: string;
5: string;
6: string;
};
emphasis_mark: string;
strong_mark: string;
delete_mark: string;
inline_code_mark: string;
thematic_break: string;
}
declare type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>;
};
export interface OptionType {
nodeTypes?: RecursivePartial<NodeTypes>;
linkDestinationKey?: string;
imageSourceKey?: string;
imageCaptionKey?: string;
}
export interface MdastNode {
type?: string;
ordered?: boolean;
value?: string;
text?: string;
children?: Array<MdastNode>;
depth?: 1 | 2 | 3 | 4 | 5 | 6;
url?: string;
alt?: string;
lang?: string;
position?: any;
spread?: any;
checked?: any;
indent?: any;
}
export declare const defaultNodeTypes: NodeTypes;
export default function deserialize(node: MdastNode, opts?: OptionType): {
type: string;
children: {
text: string;
}[];
language?: undefined;
break?: undefined;
} | {
type: string;
language: string | undefined;
children: {
text: string | undefined;
}[];
break?: undefined;
} | {
break: boolean;
type: string;
children: {
text: string;
}[];
language?: undefined;
} | {
type?: string | undefined;
import { HeadingNode, InputNodeTypes, ItalicNode, MdastNode, OptionType } from './ast-types';
export default function deserialize<T extends InputNodeTypes>(node: MdastNode, opts?: OptionType<T>): HeadingNode<T> | ItalicNode<T> | {
ordered?: boolean | undefined;
value?: string | undefined;
text: string | undefined;
children?: MdastNode[] | undefined;
depth?: 1 | 2 | 3 | 4 | 5 | 6 | undefined;

@@ -84,5 +13,3 @@ url?: string | undefined;

indent?: any;
language?: undefined;
break?: undefined;
text: string | undefined;
};
export {};

@@ -1,5 +0,6 @@

import deserialize, { defaultNodeTypes } from './deserialize';
import deserialize from './deserialize';
import serialize from './serialize';
import plugin from './plugin';
export { deserialize, serialize, defaultNodeTypes };
export * from './ast-types';
export { deserialize, serialize };
export default plugin;

@@ -1,2 +0,2 @@

import { OptionType } from './deserialize';
import { OptionType } from './ast-types';
export default function plugin(opts?: OptionType): void;

@@ -50,2 +50,3 @@ 'use strict';

};
function deserialize(node, opts) {

@@ -64,6 +65,6 @@ var _opts$nodeTypes, _opts$linkDestination, _opts$imageSourceKey, _opts$imageCaptionKey, _ref, _ref2, _node$value, _extends2, _extends3, _extends4, _extends5;

}];
var nodeChildren = node.children;
if (node.children && Array.isArray(node.children) && node.children.length > 0) {
// @ts-ignore
children = node.children.flatMap(function (c) {
if (nodeChildren && Array.isArray(nodeChildren) && nodeChildren.length > 0) {
children = nodeChildren.flatMap(function (c) {
return deserialize(_extends({}, c, {

@@ -190,4 +191,3 @@ ordered: node.ordered || false

Object.keys(node).forEach(function (key) {
if (key === 'children' || key === 'type' || key === 'text') return; // @ts-ignore
if (key === 'children' || key === 'type' || key === 'text') return;
acc[key] = node[key];

@@ -194,0 +194,0 @@ });

@@ -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 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"},emphasis_mark:"italic",strong_mark:"bold",delete_mark:"strikeThrough",inline_code_mark:"code",thematic_break:"thematic_break",image:"image"};function i(e,r){var c,o,u,d,s,h,p,g,_,v,y,k=t({},n,null==r?void 0:r.nodeTypes,{heading:t({},n.heading,null==r||null===(c=r.nodeTypes)||void 0===c?void 0:c.heading)}),f=null!==(o=null==r?void 0:r.linkDestinationKey)&&void 0!==o?o:"link",m=null!==(u=null==r?void 0:r.imageSourceKey)&&void 0!==u?u:"link",b=null!==(d=null==r?void 0:r.imageCaptionKey)&&void 0!==d?d:"caption",x=[{text:""}];switch(e.children&&Array.isArray(e.children)&&e.children.length>0&&(x=e.children.flatMap((function(n){return i(t({},n,{ordered:e.ordered||!1}),r)}))),e.type){case"heading":return{type:k.heading[e.depth||1],children:x};case"list":return{type:e.ordered?k.ol_list:k.ul_list,children:x};case"listItem":return{type:k.listItem,children:x};case"paragraph":return{type:k.paragraph,children:x};case"link":return(s={type:k.link})[f]=e.url,s.children=x,s;case"image":return(h={type:k.image,children:[{text:""}]})[m]=e.url,h[b]=e.alt,h;case"blockquote":return{type:k.block_quote,children:x};case"code":return{type:k.code_block,language:e.lang,children:[{text:e.value}]};case"html":var T;return null!==(p=e.value)&&void 0!==p&&p.includes("<br>")?{break:!0,type:k.paragraph,children:[{text:(null===(T=e.value)||void 0===T?void 0:T.replace(/<br>/g,""))||""}]}:{type:"paragraph",children:[{text:e.value||""}]};case"emphasis":return t(((g={})[k.emphasis_mark]=!0,g),a(x),l(x));case"strong":return t(((_={})[k.strong_mark]=!0,_),a(x),l(x));case"delete":return t(((v={})[k.delete_mark]=!0,v),a(x),l(x));case"inlineCode":return t(((y={})[k.inline_code_mark]=!0,y.text=e.value,y),l(x));case"thematicBreak":return{type:k.thematic_break,children:[{text:""}]};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 c=function(e){return"string"==typeof e.text},o=["thematic_break","image"];function u(e,r){var t=e.trim(),n=t,i=""+r+n+d(r);if(n.length===e.length)return i;var a=r+n+d(r);return e.replace(t,a)}var d=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,d=void 0===l?n:l,s=a.ignoreParagraphNewline,h=void 0!==s&&s,p=a.listDepth,g=void 0===p?0:p,_=i.text||"",v=i.type||"",y=t({},n,d,{heading:t({},n.heading,d.heading)}),k=[y.ul_list,y.ol_list],f=_;if(c(i)||(f=i.children.map((function(r){var n=!c(r)&&k.includes(r.type||""),a=k.includes(i.type||""),l=!1;return!c(i)&&Array.isArray(i.children)&&(l=i.children.some((function(e){return!c(e)&&e.type===y.link}))),e(t({},r,{parentType:v}),{nodeTypes:y,ignoreParagraphNewline:(h||n||a||l)&&!r.break,listDepth:k.includes(r.type||"")?g+1:g})})).join("")),h||""!==_&&"\n"!==_||i.parentType!==y.paragraph||(v=y.paragraph,f="<br>"),""!==f||o.find((function(e){return y[e]===v})))switch("<br>"!==f&&c(i)&&(i.strikeThrough&&i.bold&&i.italic?f=u(f,"~~***"):i.bold&&i.italic?f=u(f,"***"):(i.bold&&(f=u(f,"**")),i.italic&&(f=u(f,"_")),i.strikeThrough&&(f=u(f,"~~")),i.code&&(f=u(f,"`")))),v){case y.heading[1]:return"# "+f+"\n";case y.heading[2]:return"## "+f+"\n";case y.heading[3]:return"### "+f+"\n";case y.heading[4]:return"#### "+f+"\n";case y.heading[5]:return"##### "+f+"\n";case y.heading[6]:return"###### "+f+"\n";case y.block_quote:return"> "+f+"\n\n";case y.code_block:return"```"+(i.language||"")+"\n"+f+"\n```\n";case y.link:return"["+f+"]("+(i.link||"")+")";case y.image:return"!["+i.caption+"]("+(i.link||"")+")";case y.ul_list:case y.ol_list:return"\n"+f+"\n";case y.listItem:for(var m=i&&i.parentType===y.ol_list,b="",x=0;g>x;x++)b+=m?" ":" ";return b+(m?"1.":"-")+" "+f;case y.paragraph:return f+"\n";case y.thematic_break:return"---\n";default:return r(f)}};
"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"},emphasis_mark:"italic",strong_mark:"bold",delete_mark:"strikeThrough",inline_code_mark:"code",thematic_break:"thematic_break",image:"image"};function a(e,r){var o,u,c,d,s,p,h,g,_,v,y,k=t({},n,null==r?void 0:r.nodeTypes,{heading:t({},n.heading,null==r||null===(o=r.nodeTypes)||void 0===o?void 0:o.heading)}),f=null!==(u=null==r?void 0:r.linkDestinationKey)&&void 0!==u?u:"link",m=null!==(c=null==r?void 0:r.imageSourceKey)&&void 0!==c?c:"link",b=null!==(d=null==r?void 0:r.imageCaptionKey)&&void 0!==d?d:"caption",x=[{text:""}],T=e.children;switch(T&&Array.isArray(T)&&T.length>0&&(x=T.flatMap((function(n){return a(t({},n,{ordered:e.ordered||!1}),r)}))),e.type){case"heading":return{type:k.heading[e.depth||1],children:x};case"list":return{type:e.ordered?k.ol_list:k.ul_list,children:x};case"listItem":return{type:k.listItem,children:x};case"paragraph":return{type:k.paragraph,children:x};case"link":return(s={type:k.link})[f]=e.url,s.children=x,s;case"image":return(p={type:k.image,children:[{text:""}]})[m]=e.url,p[b]=e.alt,p;case"blockquote":return{type:k.block_quote,children:x};case"code":return{type:k.code_block,language:e.lang,children:[{text:e.value}]};case"html":var j;return null!==(h=e.value)&&void 0!==h&&h.includes("<br>")?{break:!0,type:k.paragraph,children:[{text:(null===(j=e.value)||void 0===j?void 0:j.replace(/<br>/g,""))||""}]}:{type:"paragraph",children:[{text:e.value||""}]};case"emphasis":return t(((g={})[k.emphasis_mark]=!0,g),i(x),l(x));case"strong":return t(((_={})[k.strong_mark]=!0,_),i(x),l(x));case"delete":return t(((v={})[k.delete_mark]=!0,v),i(x),l(x));case"inlineCode":return t(((y={})[k.inline_code_mark]=!0,y.text=e.value,y),l(x));case"thematicBreak":return{type:k.thematic_break,children:[{text:""}]};case"text":default:return{text:e.value||""}}}var i=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},u=["thematic_break","image"];function c(e,r){var t=e.trim(),n=t,a=""+r+n+d(r);if(n.length===e.length)return a;var i=r+n+d(r);return e.replace(t,i)}var d=function(e){return e.split("").reverse().join("")};exports.default=function(e){this.Compiler=function(r){return r.children.map((function(r){return a(r,e)}))}},exports.defaultNodeTypes=n,exports.deserialize=a,exports.serialize=function e(a,i){void 0===i&&(i={nodeTypes:n});var l=i.nodeTypes,d=void 0===l?n:l,s=i.ignoreParagraphNewline,p=void 0!==s&&s,h=i.listDepth,g=void 0===h?0:h,_=a.text||"",v=a.type||"",y=t({},n,d,{heading:t({},n.heading,d.heading)}),k=[y.ul_list,y.ol_list],f=_;if(o(a)||(f=a.children.map((function(r){var n=!o(r)&&k.includes(r.type||""),i=k.includes(a.type||""),l=!1;return!o(a)&&Array.isArray(a.children)&&(l=a.children.some((function(e){return!o(e)&&e.type===y.link}))),e(t({},r,{parentType:v}),{nodeTypes:y,ignoreParagraphNewline:(p||n||i||l)&&!r.break,listDepth:k.includes(r.type||"")?g+1:g})})).join("")),p||""!==_&&"\n"!==_||a.parentType!==y.paragraph||(v=y.paragraph,f="<br>"),""!==f||u.find((function(e){return y[e]===v})))switch("<br>"!==f&&o(a)&&(a.strikeThrough&&a.bold&&a.italic?f=c(f,"~~***"):a.bold&&a.italic?f=c(f,"***"):(a.bold&&(f=c(f,"**")),a.italic&&(f=c(f,"_")),a.strikeThrough&&(f=c(f,"~~")),a.code&&(f=c(f,"`")))),v){case y.heading[1]:return"# "+f+"\n";case y.heading[2]:return"## "+f+"\n";case y.heading[3]:return"### "+f+"\n";case y.heading[4]:return"#### "+f+"\n";case y.heading[5]:return"##### "+f+"\n";case y.heading[6]:return"###### "+f+"\n";case y.block_quote:return"> "+f+"\n\n";case y.code_block:return"```"+(a.language||"")+"\n"+f+"\n```\n";case y.link:return"["+f+"]("+(a.link||"")+")";case y.image:return"!["+a.caption+"]("+(a.link||"")+")";case y.ul_list:case y.ol_list:return"\n"+f+"\n";case y.listItem:for(var m=a&&a.parentType===y.ol_list,b="",x=0;g>x;x++)b+=m?" ":" ";return b+(m?"1.":"-")+" "+f;case y.paragraph:return f+"\n";case y.thematic_break:return"---\n";default:return r(f)}};
//# sourceMappingURL=remark-slate.cjs.production.min.js.map

@@ -44,2 +44,3 @@ import escapeHtml from 'escape-html';

};
function deserialize(node, opts) {

@@ -58,6 +59,6 @@ var _opts$nodeTypes, _opts$linkDestination, _opts$imageSourceKey, _opts$imageCaptionKey, _ref, _ref2, _node$value, _extends2, _extends3, _extends4, _extends5;

}];
var nodeChildren = node.children;
if (node.children && Array.isArray(node.children) && node.children.length > 0) {
// @ts-ignore
children = node.children.flatMap(function (c) {
if (nodeChildren && Array.isArray(nodeChildren) && nodeChildren.length > 0) {
children = nodeChildren.flatMap(function (c) {
return deserialize(_extends({}, c, {

@@ -184,4 +185,3 @@ ordered: node.ordered || false

Object.keys(node).forEach(function (key) {
if (key === 'children' || key === 'type' || key === 'text') return; // @ts-ignore
if (key === 'children' || key === 'type' || key === 'text') return;
acc[key] = node[key];

@@ -188,0 +188,0 @@ });

@@ -1,19 +0,2 @@

import { NodeTypes } from './deserialize';
export interface LeafType {
text: string;
strikeThrough?: boolean;
bold?: boolean;
italic?: boolean;
code?: boolean;
parentType?: string;
}
export interface BlockType {
type: string;
parentType?: string;
link?: string;
caption?: string;
language?: string;
break?: boolean;
children: Array<BlockType | LeafType>;
}
import { BlockType, LeafType, NodeTypes } from './ast-types';
interface Options {

@@ -20,0 +3,0 @@ nodeTypes: NodeTypes;

{
"name": "remark-slate",
"version": "1.8.3",
"version": "1.8.5",
"description": "remark plugin to compile Markdown to a slate compatible object",

@@ -24,3 +24,4 @@ "license": "MIT",

"RTE",
"text editor"
"text editor",
"slate markdown"
],

@@ -27,0 +28,0 @@ "repository": "hanford/remark-slate",

@@ -107,3 +107,3 @@ # remark-slate

<details><summary>Click me reveal!</summary>
<details><summary>Reveal</summary>

@@ -110,0 +110,0 @@ ```json

@@ -1,78 +0,24 @@

export interface NodeTypes {
paragraph: string;
block_quote: string;
code_block: string;
link: string;
image: string;
ul_list: string;
ol_list: string;
listItem: string;
heading: {
1: string;
2: string;
3: string;
4: string;
5: string;
6: string;
};
emphasis_mark: string;
strong_mark: string;
delete_mark: string;
inline_code_mark: string;
thematic_break: string;
}
import {
BlockQuoteNode,
CodeBlockNode,
defaultNodeTypes,
DeserializedNode,
HeadingNode,
ImageNode,
InputNodeTypes,
ItalicNode,
LinkNode,
ListItemNode,
ListNode,
MdastNode,
OptionType,
ParagraphNode,
TextNode,
ThematicBreakNode,
} from './ast-types';
type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>;
};
export interface OptionType {
nodeTypes?: RecursivePartial<NodeTypes>;
linkDestinationKey?: string;
imageSourceKey?: string;
imageCaptionKey?: string;
}
export interface MdastNode {
type?: string;
ordered?: boolean;
value?: string;
text?: string;
children?: Array<MdastNode>;
depth?: 1 | 2 | 3 | 4 | 5 | 6;
url?: string;
alt?: string;
lang?: string;
// mdast metadata
position?: any;
spread?: any;
checked?: any;
indent?: any;
}
export const defaultNodeTypes: NodeTypes = {
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',
},
emphasis_mark: 'italic',
strong_mark: 'bold',
delete_mark: 'strikeThrough',
inline_code_mark: 'code',
thematic_break: 'thematic_break',
image: 'image',
};
export default function deserialize(node: MdastNode, opts?: OptionType) {
export default function deserialize<T extends InputNodeTypes>(
node: MdastNode,
opts?: OptionType<T>
) {
const types = {

@@ -91,11 +37,7 @@ ...defaultNodeTypes,

let children = [{ text: '' }];
let children: Array<DeserializedNode<T>> = [{ text: '' }];
if (
node.children &&
Array.isArray(node.children) &&
node.children.length > 0
) {
// @ts-ignore
children = node.children.flatMap((c: MdastNode) =>
const nodeChildren = node.children;
if (nodeChildren && Array.isArray(nodeChildren) && nodeChildren.length > 0) {
children = nodeChildren.flatMap((c: MdastNode) =>
deserialize(

@@ -113,11 +55,21 @@ {

case 'heading':
return { type: types.heading[node.depth || 1], children };
return {
type: types.heading[node.depth || 1],
children,
} as HeadingNode<T>;
case 'list':
return { type: node.ordered ? types.ol_list : types.ul_list, children };
return {
type: node.ordered ? types.ol_list : types.ul_list,
children,
} as ListNode<T>;
case 'listItem':
return { type: types.listItem, children };
return { type: types.listItem, children } as ListItemNode<T>;
case 'paragraph':
return { type: types.paragraph, children };
return { type: types.paragraph, children } as ParagraphNode<T>;
case 'link':
return { type: types.link, [linkDestinationKey]: node.url, children };
return {
type: types.link,
[linkDestinationKey]: node.url,
children,
} as LinkNode<T>;
case 'image':

@@ -129,5 +81,5 @@ return {

[imageCaptionKey]: node.alt,
};
} as ImageNode<T>;
case 'blockquote':
return { type: types.block_quote, children };
return { type: types.block_quote, children } as BlockQuoteNode<T>;
case 'code':

@@ -138,3 +90,3 @@ return {

children: [{ text: node.value }],
};
} as CodeBlockNode<T>;

@@ -147,3 +99,3 @@ case 'html':

children: [{ text: node.value?.replace(/<br>/g, '') || '' }],
};
} as ParagraphNode<T>;
}

@@ -154,23 +106,23 @@ return { type: 'paragraph', children: [{ text: node.value || '' }] };

return {
[types.emphasis_mark]: true,
...forceLeafNode(children),
...persistLeafFormats(children),
};
[types.emphasis_mark as string]: true,
...forceLeafNode(children as Array<TextNode>),
...persistLeafFormats(children as Array<MdastNode>),
} as unknown as ItalicNode<T>;
case 'strong':
return {
[types.strong_mark]: true,
...forceLeafNode(children),
...persistLeafFormats(children),
[types.strong_mark as string]: true,
...forceLeafNode(children as Array<TextNode>),
...persistLeafFormats(children as Array<MdastNode>),
};
case 'delete':
return {
[types.delete_mark]: true,
...forceLeafNode(children),
...persistLeafFormats(children),
[types.delete_mark as string]: true,
...forceLeafNode(children as Array<TextNode>),
...persistLeafFormats(children as Array<MdastNode>),
};
case 'inlineCode':
return {
[types.inline_code_mark]: true,
[types.inline_code_mark as string]: true,
text: node.value,
...persistLeafFormats(children),
...persistLeafFormats(children as Array<MdastNode>),
};

@@ -181,3 +133,3 @@ case 'thematicBreak':

children: [{ text: '' }],
};
} as ThematicBreakNode<T>;

@@ -190,3 +142,3 @@ case 'text':

const forceLeafNode = (children: Array<{ text?: string }>) => ({
const forceLeafNode = (children: Array<TextNode>) => ({
text: children.map((k) => k?.text).join(''),

@@ -198,8 +150,9 @@ });

// for example, bold and italic on the same node
function persistLeafFormats(children: Array<MdastNode>) {
function persistLeafFormats(
children: Array<MdastNode>
): Omit<MdastNode, 'children' | 'type' | 'text'> {
return children.reduce((acc, node) => {
Object.keys(node).forEach(function (key) {
(Object.keys(node) as Array<keyof MdastNode>).forEach(function (key) {
if (key === 'children' || key === 'type' || key === 'text') return;
// @ts-ignore
acc[key] = node[key];

@@ -206,0 +159,0 @@ });

@@ -1,7 +0,9 @@

import deserialize, { defaultNodeTypes } from './deserialize';
import deserialize from './deserialize';
import serialize from './serialize';
import plugin from './plugin';
export { deserialize, serialize, defaultNodeTypes };
export * from './ast-types';
export { deserialize, serialize };
export default plugin;

@@ -1,2 +0,3 @@

import transform, { OptionType, MdastNode } from './deserialize';
import { MdastNode, OptionType } from './ast-types';
import transform from './deserialize';

@@ -3,0 +4,0 @@ export default function plugin(opts?: OptionType) {

@@ -0,24 +1,4 @@

import { BlockType, defaultNodeTypes, LeafType, NodeTypes } from './ast-types';
import escapeHtml from 'escape-html';
import { defaultNodeTypes, NodeTypes } from './deserialize';
export interface LeafType {
text: string;
strikeThrough?: boolean;
bold?: boolean;
italic?: boolean;
code?: boolean;
parentType?: string;
}
export interface BlockType {
type: string;
parentType?: string;
link?: string;
caption?: string;
language?: string;
break?: boolean;
children: Array<BlockType | LeafType>;
}
interface Options {

@@ -68,6 +48,6 @@ nodeTypes: NodeTypes;

const isList = !isLeafNode(c)
? LIST_TYPES.includes(c.type || '')
? (LIST_TYPES as string[]).includes(c.type || '')
: false;
const selfIsList = LIST_TYPES.includes(chunk.type || '');
const selfIsList = (LIST_TYPES as string[]).includes(chunk.type || '');

@@ -113,3 +93,5 @@ // Links can have the following shape

// track depth of nested lists so we can add proper spacing
listDepth: LIST_TYPES.includes((c as BlockType).type || '')
listDepth: (LIST_TYPES as string[]).includes(
(c as BlockType).type || ''
)
? listDepth + 1

@@ -116,0 +98,0 @@ : listDepth,

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

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