nast-util-to-html

Render NAST to HTML.
NAST is an universal data structure to represent almost any document. It is under active development so there's no released documentation, but TypeScript definitions can be found here.
This repo is part of notajs project.
A demo page built with nast-util-from-notionapi.
Documentation
Usage
npm i nast-util-to-html
require
this module,
const { renderToHTML } = require('nast-util-to-html')
Example
Download a Notion.so page and convert to HTML.
const fs = require('fs')
const NotionAgent = require('notionapi-agent')
const { getOnePageAsTree } = require('nast-util-from-notionapi')
const { renderToHTML } = require('nast-util-to-html')
const agentOpts = {
token: '',
suppressWarning: false,
verbose: true
}
const agent = new NotionAgent(options)
async function main() {
try {
let pageID = ''
let tree = await getOnePageAsTree(pageID, agent)
let html = renderToHTML(tree)
fs.writeFileSync(
'index.html',
html,
{ encoding: 'utf-8' }
)
} catch (error) {
console.error(error)
}
}
main()
API Reference
renderToHTML(data, options)
Render static HTML from NAST.
-
data
- (required) Nast.Block
Go to Definition | Notion.StyledString[]
Go to Definition
-
options
- (optional) RenderOptions
type RenderOptions = {
contentOnly: boolean
bypassPreRenderTransform: boolean
}
Returns :
A HTML string.
Notes
Supported Blocks (for Notion.so)
Fundamental
Basic Blocks
Inline
Database
Media
Advanced Blocks
Code Structure
Generated by dependency-cruiser
NPM package.
