Skip to content

Commit

Permalink
Fix failing empty action
Browse files Browse the repository at this point in the history
  • Loading branch information
Weetbix committed Jul 28, 2023
1 parent 133472c commit 342c6d4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/readability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const removeUnwantedNodeTypes: Plugin = () => (tree) => {
];

visit(tree, nodeTypesToRemove, (_node, index, parent) => {
parent?.children.splice(index, 1);
parent?.children?.splice(index, 1);

// Do not traverse `node`, continue at the node *now* at `index`.
return [SKIP, index];
Expand All @@ -79,7 +79,7 @@ const replaceNodesWithTheirTextContent: Plugin = () => (tree) => {

visit(tree, nodeTypesToReplace, (node, index, parent) => {
// @ts-ignore
parent?.children.splice(index, 1, ...node.children);
parent?.children?.splice(index, 1, ...(node?.children ?? {}));
// Do not traverse `node`, continue at the node *now* at `index`.
return [SKIP, index];
});
Expand Down Expand Up @@ -171,7 +171,7 @@ const convertTableToText: Plugin = () => (tree) => {
// Remove any cells with < 4 words
visit(tree, 'tableCell', (tableCellNode) => {
// @ts-ignore
const text = tableCellNode.children.map(({value}) => value).join(' ');
const text = tableCellNode.children?.map(({value}) => value).join(' ');
if (text.split(' ').length < 4) {
// @ts-ignore
tableCellNode.children = [];
Expand Down

0 comments on commit 342c6d4

Please sign in to comment.