const table_to_markdown = require('./html_table_to_markdown.js');
const htmlEntities = require('html-entities');
module.exports = {
format_tables: function (html, replacements) {
const start = replacements.length;
const tables = html.match(/(
]*>(?:.|\n)*?<\/table>)/gi);
if (tables) {
for (let t=0;t"+placeholder+"");
}
}
return html;
},
format_codeblocks: function (html, replacements) {
const start = replacements.length;
const codeblocks = html.match(/(]*>(?:.|\n)*?<\/pre>)/gi);
if (codeblocks) {
for (let c=0;c]*>/g, "\n");
filtered = filtered.replace(//g, "\n");
filtered = filtered.replace(/<\/?[^>]+(>|$)/g, "");
filtered = htmlEntities.decode(filtered);
let markdown = "```\n"+filtered+"\n```\n";
let placeholder = "urltomarkdowncodeblockplaceholder"+c+Math.random();
replacements[start+c] = { placeholder: placeholder, replacement: markdown};
html = html.replace(codeblock, "
"+placeholder+"
");
}
}
return html;
}
}