Start rendering the Org Ast.

This commit is contained in:
Tom Alexander
2024-01-23 21:27:12 -05:00
parent c419a41998
commit 6901541fe4
6 changed files with 48 additions and 11 deletions

32
src/OrgAst.tsx Normal file
View File

@@ -0,0 +1,32 @@
import React, { ReactNode, useState } from "react";
import {
parse_org,
} from "../../organic/target/wasm32-unknown-unknown/js/wasm";
import styles from "./OrgAst.module.css";
const OrgAst = (props: {addHighlight: Function, value: string}) => {
console.log(styles);
const ast_tree = parse_org(props.value);
console.log(JSON.stringify(ast_tree));
if (ast_tree.status !== "success") {
return (
<div className={styles.OrgAst}>Error! {ast_tree.content}</div>
);
} else {
return (
<div className={styles.OrgAst}><OrgAstNode node={ast_tree.content}/></div>
);
}
}
const OrgAstNode = (props: {node: any}) => {
return (
<div className={styles.OrgAstNode}>
<div className={styles.OrgAstNodeType}>{props.node["ast-node"]}</div>
</div>
);
}
export default OrgAst;