(blog) fix wrong text-align on <th>

convert deprecated align attribute to inline css
modern markdown parsers appear to do this
This commit is contained in:
Valentyne Stigloher 2025-04-17 00:39:35 +02:00
parent 329440684d
commit 1d3689b7cf

View File

@ -111,6 +111,7 @@ export default async function parseMarkdown(markdown: string, translator: Transl
let content = `<div>${
markdown
.replace(/<table>(.+?)<\/table>/gs, '<div class="table-responsive"><table class="table table-striped small">$1</table></div>')
.replace(/align="([^"]+)"/g, 'style="text-align:$1"')
.replace(/<a (href="http[^>]+)>/g, (_match, attributes) => {
return `<a ${attributes.includes('target=') ? '' : 'target="_blank" '}${attributes.includes('rel=') ? '' : 'rel="noopener" '}${attributes}>`;
})