@yozora/html-link
TypeScript icon, indicating that this package has built-in type declarations

2.0.0-alpha.2 • Public • Published

@yozora/html-link


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>

Related

Package Sidebar

Install

npm i @yozora/html-link

Weekly Downloads

2

Version

2.0.0-alpha.2

License

MIT

Unpacked Size

7.01 kB

Total Files

6

Last publish

Collaborators

  • lemonclown