Skip to content

Commit ea05e27

Browse files
kemsakuraiazu
authored andcommitted
fix(rule): Ignore empty paragraph (#1)
* Ignore empty Paragraph. Ex) '<p></p>' When applying `textlint-rule-prefer-tari-tari` to HTML, an error occurred. `` `console ✖ Stack trace TypeError: Can not read property 'children' of undefined at /usr/local/lib/node_modules/textlint-rule-prefer-tari-tari/lib/textlint- rule-prefer-tari-tari.js:56:44 at <anonymous> at process._ tickCallback (internal / process / next_tick.js: 188: 7) `` ` I checked the contents of the NODE where the error occurred. `` `console ### NODE {type: 'Paragraph', tagName: 'p', properties: {}, children: [], loc: {start: {line: 19, column: 12}, end: {line: 19, column: 19}}, range: [50138, 50145], raw: '<p> </ p>'} ### CST {type: 'RootNode', children: [], position: {}} ### CST.children [] `` ` Fixed the program to ignore empty Paragraph like `<p> </ p>`. * Merge upstream * Merge upstream * Merge upstream * Merge upstream * Update textlint-rule-prefer-tari-tari.js * Update textlint-rule-prefer-tari-tari.js
1 parent 2c7963f commit ea05e27

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/textlint-rule-prefer-tari-tari.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ const report = context => {
4141
const source = new StringSource(node);
4242
const text = source.toString();
4343
const CST = japaneseParser.parse(text);
44+
// Ignore empty Paragraph. Ex) '<p></p>'
45+
if (typeof CST.children === "undefined" || CST.children.length == 0) {
46+
return;
47+
}
4448
const sentences = CST.children[0].children;
4549
const isSameNode = (resultsA, resultsB) => {
4650
return resultsA.some(resultA => {

0 commit comments

Comments
 (0)