markdown-to-jsx

  • Version 7.1.3
  • Published
  • 391 kB
  • No dependencies
  • MIT license

Install

npm i markdown-to-jsx
yarn add markdown-to-jsx
pnpm add markdown-to-jsx

Overview

Convert markdown to JSX with ease for React and React-like projects. Super lightweight and highly configurable.

Index

Variables

variable Markdown

const Markdown: any;
  • A simple HOC for easy React use. Feed the markdown content as a direct child and the rest is taken care of automatically.

Functions

function compiler

compiler: (markdown: string, options?: MarkdownToJSX.Options) => any;

    Namespaces

    namespace MarkdownToJSX

    namespace MarkdownToJSX {}

      type CreateElement

      type CreateElement = typeof React.createElement;

        type HTMLTags

        type HTMLTags = keyof JSX.IntrinsicElements;

          type NestedParser

          type NestedParser = (
          input: string,
          state?: MarkdownToJSX.State
          ) => MarkdownToJSX.ParserResult;

            type Options

            type Options = Partial<{
            /**
            * Ultimate control over the output of all rendered JSX.
            */
            createElement: (
            tag: Parameters<CreateElement>[0],
            props: React.Props<any>,
            ...children: React.ReactChild[]
            ) => JSX.Element;
            /**
            * Disable the compiler's best-effort transcription of provided raw HTML
            * into JSX-equivalent. This is the functionality that prevents the need to
            * use `dangerouslySetInnerHTML` in React.
            */
            disableParsingRawHTML: boolean;
            /**
            * Forces the compiler to always output content with a block-level wrapper
            * (`<p>` or any block-level syntax your markdown already contains.)
            */
            forceBlock: boolean;
            /**
            * Forces the compiler to always output content with an inline wrapper (`<span>`)
            */
            forceInline: boolean;
            /**
            * Supply additional HTML entity: unicode replacement mappings.
            *
            * Pass only the inner part of the entity as the key,
            * e.g. `&le;` -> `{ "le": "\u2264" }`
            *
            * By default
            * the following entites are replaced with their unicode equivalents:
            *
            * ```
            * &amp;
            * &apos;
            * &gt;
            * &lt;
            * &nbsp;
            * &quot;
            * ```
            */
            namedCodesToUnicode: {
            [key: string]: string;
            };
            /**
            * Selectively control the output of particular HTML tags as they would be
            * emitted by the compiler.
            */
            overrides: Overrides;
            /**
            * Declare the type of the wrapper to be used when there are multiple
            * children to render. Set to `null` to get an array of children back
            * without any wrapper, or use `React.Fragment` to get a React element
            * that won't show up in the DOM.
            */
            wrapper: React.ElementType | null;
            /**
            * Forces the compiler to wrap results, even if there is only a single
            * child or no children.
            */
            forceWrapper: boolean;
            /**
            * Override normalization of non-URI-safe characters for use in generating
            * HTML IDs for anchor linking purposes.
            */
            slugify: (source: string) => string;
            }>;

              type Override

              type Override =
              | RequireAtLeastOne<{
              component: React.ElementType;
              props: Object;
              }>
              | React.ElementType;

                type Overrides

                type Overrides = {
                [tag in HTMLTags]?: Override;
                } & {
                [customComponent: string]: Override;
                };

                  type Parser

                  type Parser<ParserOutput> = (
                  capture: RegExpMatchArray,
                  nestedParse: NestedParser,
                  state?: MarkdownToJSX.State
                  ) => ParserOutput;

                    type ParserResult

                    type ParserResult = {
                    [key: string]: any;
                    type?: string;
                    };

                      type Rule

                      type Rule<ParserOutput = MarkdownToJSX.ParserResult> = {
                      match: (
                      source: string,
                      state: MarkdownToJSX.State,
                      prevCapturedString?: string
                      ) => RegExpMatchArray;
                      order: Priority;
                      parse: MarkdownToJSX.Parser<ParserOutput>;
                      react?: (
                      node: ParserOutput,
                      output: RuleOutput,
                      state?: MarkdownToJSX.State
                      ) => React.ReactChild;
                      };

                        type RuleOutput

                        type RuleOutput = (
                        ast: MarkdownToJSX.ParserResult,
                        state: MarkdownToJSX.State
                        ) => JSX.Element;

                          type Rules

                          type Rules = {
                          [key: string]: Rule;
                          };

                            type State

                            type State = {
                            _list?: boolean;
                            inline?: boolean;
                            inTable?: boolean;
                            inAnchor?: boolean;
                            key?: React.Key;
                            simple?: boolean;
                            };

                              Package Files (1)

                              Dependencies (0)

                              No dependencies.

                              Dev Dependencies (34)

                              Peer Dependencies (1)

                              Badge

                              To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                              You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/markdown-to-jsx.

                              • Markdown
                                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/markdown-to-jsx)
                              • HTML
                                <a href="https://www.jsdocs.io/package/markdown-to-jsx"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>