Skip to content

Commit 8b2f032

Browse files
committed
[fix] markdown rendering of tables
Tables needed bootstrap specific classes to be set in order to be rendered as before.
1 parent 19811e2 commit 8b2f032

File tree

1 file changed

+18
-1
lines changed
  • src/main/xar-resources/resources/scripts

1 file changed

+18
-1
lines changed

src/main/xar-resources/resources/scripts/query.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
$(document).on("ready", function() {
2+
const markedOptions = { "gfm": true }
23
const loginDialog = $("#loginDialog");
34
let timeout = 0;
45

@@ -91,8 +92,24 @@ $(document).on("ready", function() {
9192

9293
// replace markdown element content with rendered HTML
9394
const mdContentElement = document.querySelector(".markdown")
95+
9496
if (mdContentElement) {
95-
const markdown = marked(mdContentElement.textContent)
97+
const renderer = {
98+
table(header, body) {
99+
if (body) body = `<tbody>${body}</tbody>`
100+
return `<table class="table table-bordered">
101+
<thead>
102+
${header}
103+
</thead>
104+
${body}
105+
</table>
106+
`;
107+
}
108+
};
109+
110+
marked.use({ renderer });
111+
112+
const markdown = marked(mdContentElement.textContent, markedOptions)
96113
mdContentElement.innerHTML = markdown
97114
}
98115
});

0 commit comments

Comments
 (0)