tagHandler - Handle table - all tags + tests

This commit is contained in:
2019-12-26 11:44:03 +05:30
parent efb2c4af5c
commit 4a084a8f51
2 changed files with 86 additions and 4 deletions
+33 -3
View File
@@ -14,8 +14,11 @@ import {
separator,
strike,
strong,
table,
tableCell,
tableRow,
} from 'mdast-builder';
import {render as renderToHTML} from 'preact-render-to-string';
import { render as renderToHTML } from 'preact-render-to-string';
import {
AnchorHTMLAttributes,
Children as ReactChildren,
@@ -199,14 +202,41 @@ export default function handleTag(
}
break;
}
// END - Handle blockquote
// END - Handle pre.code
// START - Handle table - all tags
case 'table': {
// TODO: Handle align
newParentASTNode = childASTNode = table();
break;
}
// Passthrough thead and tbody
case 'thead':
case 'tbody': {
newParentASTNode = parentASTNode;
break;
}
// Handle table rows
case 'tr': {
newParentASTNode = childASTNode = tableRow();
break;
}
// Handle table values (th - for header, td - for body)
case 'th':
case 'td': {
newParentASTNode = childASTNode = tableCell();
break;
}
// END - Handle table - all tags
default:
isHandled = false;
break;
}
if (!isHandled) {
// Handle as html
let htmlText = '';