@yozora/html-link
v2.0.0-alpha.2
Published
render Yozora Markdown AST node `ILink` into HTML string
Downloads
9
Readme
This component is for rendering the Yozora Markdown AST node ILink
produced by @yozora/tokenizer-link into HTML string.
This component has been built into [@yozora/html-markdown][], you can use it directly.
Install
npm
npm install --save @yozora/html-link
yarn
yarn add @yozora/html-link
Usage
Basic:
import type { ILink, IYastNode } from '@yozora/ast' import renderLink from '@yozora/html-link' // The implementation of the following function has been omitted. const renderChildren: (nodes: IYastNode[]) => string = function () {} const link = { "type": "link", "url": "https://github.com/guanghechen/yozora", "title": "yozora", "children": [ { "type": "text", "value": "yozora is cool!" } ] } renderLink(link as ILink, renderChildren) // => <a class="yozora-link" href="https://github.com/guanghechen/yozora" title="yozora" target="_blank" rel="noopener,noreferrer"><span class="yozora-text">yozora is cool!</span></a>