2.0.0-alpha.2 • Published 2 years ago

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

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

This component is for rendering the Yozora Markdown AST node IEmphasis produced by @yozora/tokenizer-emphasis into HTML string.

This component has been built into @yozora/html-markdown, you can use it directly.

Install

  • npm

    npm install --save @yozora/html-emphasis
  • yarn

    yarn add @yozora/html-emphasis

Usage

  • Basic:

    import type { IEmphasis, IYastNode } from '@yozora/ast'
    import renderEmphasis from '@yozora/html-emphasis'
    
    // The implementation of the following function has been omitted.
    const renderChildren: (nodes: IYastNode[]) => string = function () {}
    
    const emphasis = {
      "type": "emphasis",
      "children": [
        {
          "type": "text",
          "value": "yozora is cool!"
        }
      ]
    }
    renderEmphasis(emphasis as IEmphasis, renderChildren)
    // => <em class="yozora-emphasis"><span class="yozora-text">yozora is cool!</span></em>

Related