Having current code:
|
} else { |
|
// for now we assume that all previous ifs are mutually exclusive with this, may polish later |
|
if (i.type === "emphasis") { |
|
// this is the emphasis, add it in boldface and move on |
|
s += "*" + i.children[0].value + "*"; |
|
} else if (i.type === "link") { |
|
// something has gone terribly wrong. this book must be viewed and edited manually. |
|
entry.manualReviewRequired = true; |
|
break; |
|
} else { |
|
// hopefully this is the end of the note |
|
let rightParen = i.value.indexOf(")"); |
|
if (rightParen === -1) { |
|
// we have to go AGAIN |
|
s += i.value; |
|
} else { |
|
// finally, we have reached the end of the note |
|
entry.notes.push(stripParens(s + i.value.slice(0, rightParen + 1))); |
|
s = ""; |
|
// this is a copypaste of another block of code. probably not a good thing tbh. |
|
leftParen = i.value.indexOf("("); |
|
while (leftParen != -1) { |
|
rightParen = i.value.indexOf(")", leftParen); |
|
if (rightParen === -1) { |
|
// there must be some *emphasis* found |
|
s += i.value.slice(leftParen); |
|
break; |
|
} |
|
entry.notes.push(i.value.slice(leftParen + 1, rightParen)); |
|
leftParen = i.value.indexOf("(", rightParen); |
|
} |
|
} |
|
} |
If a bold format is found, the i.value is undefined and then the program crash. It should check if i.type == "strong" or have i.children.
Resources affected:
In general, we should extends the fix in depth to other inline formats like emphasis (already exists), bold, code, image...
Having current code:
free-programming-books-parser/index.js
Lines 140 to 172 in dc53b8c
If a bold format is found, the
i.valueis undefined and then the program crash. It should check ifi.type == "strong"or havei.children.Resources affected:
In general, we should extends the fix in depth to other inline formats like emphasis (already exists), bold, code, image...