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) {
const tables = html.match(/(<table[^>]*>(?:.|\n)*?<\/table>)/gi);
for (let t=0;t<tables.length;t++) {
let table = tables[t];
let markdown = table_to_markdown.convert(table);
let placeholder = "urltomarkdowntableplaceholder"+t+Math.random();
replacements.placeholders[t] = placeholder;
replacements.tables[t] = markdown;
html = html.replace(table, "<p>"+placeholder+"</p>");
if (tables) {
for (let t=0;t<tables.length;t++) {
let table = tables[t];
let markdown = table_to_markdown.convert(table);
let placeholder = "urltomarkdowntableplaceholder"+t+Math.random();
replacements.placeholders[t] = placeholder;
replacements.tables[t] = markdown;
html = html.replace(table, "<p>"+placeholder+"</p>");
}
}
return html;
}