mirror of
https://github.com/bendtherules/react-to-markdown.git
synced 2026-08-18 13:53:11 +00:00
renderer - Consume taghandler, process child accordingly
This commit is contained in:
+12
-2
@@ -11,6 +11,8 @@ import {
|
|||||||
ReactElementSubsetWithPrimitive,
|
ReactElementSubsetWithPrimitive,
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
|
|
||||||
|
import handleTag from './tagHandler';
|
||||||
|
|
||||||
function render(
|
function render(
|
||||||
node: ReactElementSubsetWithPrimitive,
|
node: ReactElementSubsetWithPrimitive,
|
||||||
parentASTNode?: MDASTParent
|
parentASTNode?: MDASTParent
|
||||||
@@ -35,6 +37,7 @@ function render(
|
|||||||
node.forEach(fragmentEle => render(fragmentEle, parentASTNodeMod));
|
node.forEach(fragmentEle => render(fragmentEle, parentASTNodeMod));
|
||||||
} else {
|
} else {
|
||||||
const { props, type: elementType } = node;
|
const { props, type: elementType } = node;
|
||||||
|
let processChildren = true;
|
||||||
|
|
||||||
// Handle nested function or class components
|
// Handle nested function or class components
|
||||||
{
|
{
|
||||||
@@ -62,10 +65,17 @@ function render(
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Handle intrinsic types of element like div, h1
|
// Handle intrinsic types of element like div, h1
|
||||||
|
const newParentASTNode = handleTag(node, parentASTNodeMod);
|
||||||
|
if (newParentASTNode === undefined) {
|
||||||
|
processChildren = false;
|
||||||
|
} else {
|
||||||
|
processChildren = true;
|
||||||
|
parentASTNodeMod = newParentASTNode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
// Handle children
|
||||||
// Handle children
|
if (processChildren) {
|
||||||
const { children } = props;
|
const { children } = props;
|
||||||
|
|
||||||
// Render processed array of children
|
// Render processed array of children
|
||||||
|
|||||||
Reference in New Issue
Block a user