Skip to content

Commit

Permalink
feat: keep tables as table in md
Browse files Browse the repository at this point in the history
  • Loading branch information
kptdobe committed Oct 29, 2021
1 parent 233744e commit f1c2e33
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/importer/PageImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { JSDOM, Document } from 'jsdom';
import path from 'path';
import unified from 'unified';
import parse from 'rehype-parse';
import toHtml from 'hast-util-to-html'
import rehype2remark from 'rehype-remark';
import stringify from 'remark-stringify';
import all from 'hast-util-to-mdast/lib/all';
Expand Down Expand Up @@ -98,6 +99,7 @@ export default abstract class PageImporter implements Importer {
handlers: {
hlxembed: (h, node) => h(node, 'hlxembed', node.children[0].value),
u: (h, node) => h(node, 'u', all(h, node)),
table: (h, node) => h(node, 'table', toHtml(node)),
},
})
.use(stringify, {
Expand All @@ -114,6 +116,11 @@ export default abstract class PageImporter implements Importer {
// we need the raw url
processor.Compiler.prototype.visitors.hlxembed = (node) => node.value;
})
.use(() => {
processor.Compiler.prototype.visitors.table = (node) => {
return node.value;
}
})
.use(() => {
processor.Compiler.prototype.visitors.u = (node) => {
// u handling: remove the u is the first element is a link
Expand Down

0 comments on commit f1c2e33

Please sign in to comment.