2.0.0-alpha.2 • Published 3 years ago

@yozora/html-link v2.0.0-alpha.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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