New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@yozora/react-code

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yozora/react-code

render markdown code in react

latest
Source
npmnpm
Version
3.0.0-alpha.21
Version published
Maintainers
1
Created
Source

@yozora/react-code


This component is for rendering the Code data produced by @yozora/tokenizer-indented-code and @yozora/tokenizer-fenced-code.
This component has been built into @yozora/react-markdown, you can use it directly.

Install

  • npm

    npm install --save @yozora/react-code
    
  • yarn

    yarn add @yozora/react-code
    

Usage

  • Basic:

    import React from 'react'
    import Code from '@yozora/react-code'
    
    const wrapper = (
      <Code
        lang="typescript"
        value="let a: number = 1 + 2;"
      />
    )
    

Props

NameTypeRequiredDefaultDescription
classNamestringfalse-Root css class
darkenbooleanfalse-Enable the darken mode
langstringfalse-Language of the source codes
metastringfalse-Meta data of the code block
showCodeLinenobooleanfalsetrueDisplay linenos in default
runnersCodeRunnerItem[]falseSee belowCode runners.
styleReact.CSSPropertiesfalse-Root css style
valuestringtrue-Literal source codes
  • runners:

    import JsxRenderer from '@yozora/react-code-renderer-jsx'
    
    const defaultRunners: CodeRunnerItem[] = [
      {
        title: 'jsx',
        pattern: /^jsx$/,
        runner: function JsxRunner(props: CodeRunnerProps): React.ReactElement {
          const { value, scope, onError } = props
          return (
            <JsxRenderer
              code={value}
              inline={true}
              scope={scope}
              onError={onError}
            />
          )
        },
      },
    ]
    
  • meta:

    import type { ICodeMetaData as IBaseCodeMetaData } from '@yozora/core-react-renderer'
    import type { ICodeRunnerItem, ICodeRunnerMetaData } from '@yozora/react-code-runners'
    
    /**
    * Meta data of the fenced-code.
    */
    export interface ICodeMetaData extends IBaseCodeMetaData, ICodeRunnerMetaData {
      /**
      * Rendering mode.
      */
      _yozoracodemode: 'live' | 'embed' | 'literal' | string
    }
    

Keywords

mdast node renderer

FAQs

Package last updated on 27 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts