Closed smuchow1962 closed 1 year ago
The sample code has a number of issues and there have been changes to unified I reworked the example a little to achieve a working result.
import fs from "node:fs/promises" import { fromMarkdown } from "mdast-util-from-markdown" import { toMarkdown } from "mdast-util-to-markdown" import { gridTables } from "@adobe/micromark-extension-gridtables" import {toHast} from 'mdast-util-to-hast' import { gridTablesToMarkdown, gridTablesFromMarkdown, mdast2hastGridTablesHandler, TYPE_TABLE, } from "@adobe/mdast-util-gridtables" // create a markdown file and load it here const doc = await fs.readFile("./src/example.md") // convert markdown to mdast const options = { extensions: [gridTables], mdastExtensions: [], } options.mdastExtensions.push(gridTablesToMarkdown(options)) const mdastTree = fromMarkdown(doc, options) console.log(`mdastTree`, mdastTree) console.log(`-------`) // convert mdast to md const outputMarkdown = toMarkdown(mdastTree, { extensions: [gridTablesToMarkdown()], }) console.log(`outputMarkdown result`, outputMarkdown) console.log(`-------`) // convert mdast to hast const hast = toHast(mdastTree, { handlers: { [TYPE_TABLE]: mdast2hastGridTablesHandler(), }, }) console.log(`hast output`,hast) console.log(`-------`)
thank you for reporting. I'll update the docs and add a working example
:tada: This issue has been resolved in version 1.0.7 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
The sample code has a number of issues and there have been changes to unified I reworked the example a little to achieve a working result.