forked from sendgrid/docs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0258e87
commit b5fa924
Showing
4 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const visit = require('unist-util-visit'); | ||
const cheerio = require('cheerio'); | ||
|
||
module.exports = ({ markdownAST }) => { | ||
visit(markdownAST, 'html', (node) => { | ||
const $ = cheerio.load(node.value); | ||
const table = $('table'); | ||
|
||
if (table.length) { | ||
const rawHTML = ` | ||
<div class="table-wrap"> | ||
${table} | ||
</div> | ||
`; | ||
|
||
node.data = { | ||
hChildren: [{ type: 'raw', value: rawHTML }], | ||
// Set type to unknown so mdast-util-to-hast will treat this node as a | ||
// div not an iframe — it gets quite confused otherwise. | ||
}; node.type = 'unknown'; | ||
|
||
// Also apparently, for html node types, you have to delete the value | ||
// in order for mdast-util-to-hast to use hChildren. If even if | ||
// you change the node type to unknown... | ||
delete node.value; | ||
} | ||
}); | ||
|
||
return markdownAST; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |