markdown-to-jsx
- Version 7.1.7
- Published
- 389 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: React.FC<{ [key: string]: any; children: string; options?: MarkdownToJSX.Options;}>;
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) => JSX.Element;
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": "\u2264" }` * * By default * the following entites are replaced with their unicode equivalents: * * ``` * & * ' * > * < * * " * ``` */ 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 = { _inAnchor?: boolean; _inline?: boolean; _inTable?: boolean; _key?: React.Key; _list?: boolean; _simple?: boolean;};
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (31)
- @babel/plugin-proposal-nullish-coalescing-operator
- @babel/plugin-proposal-object-rest-spread
- @babel/plugin-proposal-optional-chaining
- @babel/plugin-transform-typescript
- @size-limit/preset-small-lib
- @types/jest
- @types/node
- @types/react
- @types/styled-components
- benchtable
- cli-progress
- esm
- in-publish
- jest
- jest-serializer-html
- markdown-it
- microbundle
- microtime
- mkdirp
- polished
- preact
- prettier
- react
- react-dom
- rimraf
- simple-markdown
- size-limit
- styled-components
- theredoc
- ts-jest
- typescript
Peer Dependencies (1)
Badge
To add a badge like this oneto 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[](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>
- Updated .
Package analyzed in 896 ms. - Missing or incorrect documentation? Open an issue for this package.