bug when no table pleasant

main
Lee Hanken 2022-01-30 21:05:14 +00:00
parent 15dae35b74
commit 0ab94c807e
1 changed files with 9 additions and 7 deletions

View File

@ -92,13 +92,15 @@ function read_url(url, res) {
function format_tables(html, replacements) { function format_tables(html, replacements) {
const tables = html.match(/(<table[^>]*>(?:.|\n)*?<\/table>)/gi); const tables = html.match(/(<table[^>]*>(?:.|\n)*?<\/table>)/gi);
for (let t=0;t<tables.length;t++) { if (tables) {
let table = tables[t]; for (let t=0;t<tables.length;t++) {
let markdown = table_to_markdown.convert(table); let table = tables[t];
let placeholder = "urltomarkdowntableplaceholder"+t+Math.random(); let markdown = table_to_markdown.convert(table);
replacements.placeholders[t] = placeholder; let placeholder = "urltomarkdowntableplaceholder"+t+Math.random();
replacements.tables[t] = markdown; replacements.placeholders[t] = placeholder;
html = html.replace(table, "<p>"+placeholder+"</p>"); replacements.tables[t] = markdown;
html = html.replace(table, "<p>"+placeholder+"</p>");
}
} }
return html; return html;
} }