marked
- Version 15.0.0
- Published
- 961 kB
- No dependencies
- MIT license
Install
npm i marked
yarn add marked
pnpm add marked
Overview
A markdown parser built for speed
Index
Variables
Functions
Classes
Interfaces
Type Aliases
Namespaces
Variables
variable blockNormal
const blockNormal: { blockquote: RegExp; code: RegExp; def: RegExp; fences: RegExp; heading: RegExp; hr: RegExp; html: RegExp; lheading: RegExp; list: RegExp; newline: RegExp; paragraph: RegExp; table: RegExp; text: RegExp;};
variable defaults
let defaults: MarkedOptions;
variable inlineNormal
const inlineNormal: { _backpedal: RegExp; anyPunctuation: RegExp; autolink: RegExp; blockSkip: RegExp; br: RegExp; code: RegExp; del: RegExp; emStrongLDelim: RegExp; emStrongRDelimAst: RegExp; emStrongRDelimUnd: RegExp; escape: RegExp; link: RegExp; nolink: RegExp; punctuation: RegExp; reflink: RegExp; reflinkSearch: RegExp; tag: RegExp; text: RegExp; url: RegExp;};
variable lexer
const lexer: (src: string, options?: MarkedOptions) => TokensList;
variable other
const other: { codeRemoveIndent: RegExp; outputLinkReplace: RegExp; indentCodeCompensation: RegExp; beginningSpace: RegExp; endingHash: RegExp; startingSpaceChar: RegExp; endingSpaceChar: RegExp; nonSpaceChar: RegExp; newLineCharGlobal: RegExp; tabCharGlobal: RegExp; multipleSpaceGlobal: RegExp; blankLine: RegExp; doubleBlankLine: RegExp; blockquoteStart: RegExp; blockquoteSetextReplace: RegExp; blockquoteSetextReplace2: RegExp; listReplaceTabs: RegExp; listReplaceNesting: RegExp; listIsTask: RegExp; listReplaceTask: RegExp; anyLine: RegExp; hrefBrackets: RegExp; tableDelimiter: RegExp; tableAlignChars: RegExp; tableRowBlankLine: RegExp; tableAlignRight: RegExp; tableAlignCenter: RegExp; tableAlignLeft: RegExp; startATag: RegExp; endATag: RegExp; startPreScriptTag: RegExp; endPreScriptTag: RegExp; startAngleBracket: RegExp; endAngleBracket: RegExp; pedanticHrefTitle: RegExp; unicodeAlphaNumeric: RegExp; escapeTest: RegExp; escapeReplace: RegExp; escapeTestNoEncode: RegExp; escapeReplaceNoEncode: RegExp; unescapeTest: RegExp; caret: RegExp; percentDecode: RegExp; findPipe: RegExp; splitPipe: RegExp; slashPipe: RegExp; carriageReturn: RegExp; spaceLine: RegExp; notSpaceStart: RegExp; endingNewline: RegExp; listItemRegex: (bull: string) => RegExp; nextBulletRegex: (indent: number) => RegExp; hrRegex: (indent: number) => RegExp; fencesBeginRegex: (indent: number) => RegExp; headingBeginRegex: (indent: number) => RegExp; htmlBeginRegex: (indent: number) => RegExp;};
variable parse
const parse: typeof marked;
variable parseInline
const parseInline: { (src: string, options: MarkedOptions & { async: true }): Promise<string>; (src: string, options: MarkedOptions & { async: false }): string; (src: string, options?: MarkedOptions | undefined | null): | string | Promise<string>;};
variable parser
const parser: (tokens: Token[], options?: MarkedOptions) => string;
Functions
function getDefaults
getDefaults: () => MarkedOptions;
Gets the original marked default options.
function marked
marked: typeof marked;
Compiles markdown to HTML asynchronously.
Parameter src
String of markdown source to be compiled
Parameter options
Hash of options, having async: true Promise of string of compiled HTML
Compiles markdown to HTML.
Parameter src
String of markdown source to be compiled
Parameter options
Optional hash of options String of compiled HTML. Will be a Promise of string if async is set to true by any extensions.
function options
options: (options: MarkedOptions) => typeof marked;
function setOptions
setOptions: (options: MarkedOptions) => typeof marked;
function use
use: (...args: MarkedExtension[]) => typeof marked;
function walkTokens
walkTokens: ( tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
Classes
class Hooks
class _Hooks {}
constructor
constructor(options?: MarkedOptions);
property block
block: boolean;
property options
options: MarkedOptions;
property passThroughHooks
static passThroughHooks: Set<string>;
method postprocess
postprocess: (html: string) => string;
Process HTML after marked is finished
method preprocess
preprocess: (markdown: string) => string;
Process markdown before marked
method processAllTokens
processAllTokens: (tokens: Token[] | TokensList) => Token[] | TokensList;
Process all tokens before walk tokens
method provideLexer
provideLexer: () => typeof _Lexer.lexInline;
Provide function to tokenize markdown
method provideParser
provideParser: () => typeof _Parser.parse;
Provide function to parse tokens
class Lexer
class _Lexer {}
Block Lexer
constructor
constructor(options?: MarkedOptions);
property options
options: MarkedOptions;
property rules
static readonly rules: { block: { normal: { blockquote: RegExp; code: RegExp; def: RegExp; fences: RegExp; heading: RegExp; hr: RegExp; html: RegExp; lheading: RegExp; list: RegExp; newline: RegExp; paragraph: RegExp; table: RegExp; text: RegExp; }; gfm: Record< | 'code' | 'blockquote' | 'hr' | 'html' | 'table' | 'text' | 'heading' | 'list' | 'paragraph' | 'def' | 'fences' | 'lheading' | 'newline', RegExp >; pedantic: Record< | 'code' | 'blockquote' | 'hr' | 'html' | 'table' | 'text' | 'heading' | 'list' | 'paragraph' | 'def' | 'fences' | 'lheading' | 'newline', RegExp >; }; inline: { normal: { _backpedal: RegExp; anyPunctuation: RegExp; autolink: RegExp; blockSkip: RegExp; br: RegExp; code: RegExp; del: RegExp; emStrongLDelim: RegExp; emStrongRDelimAst: RegExp; emStrongRDelimUnd: RegExp; escape: RegExp; link: RegExp; nolink: RegExp; punctuation: RegExp; reflink: RegExp; reflinkSearch: RegExp; tag: RegExp; text: RegExp; url: RegExp; }; gfm: Record< | 'link' | 'code' | 'url' | 'br' | 'del' | 'text' | 'escape' | 'tag' | 'reflink' | 'nolink' | '_backpedal' | 'anyPunctuation' | 'autolink' | 'blockSkip' | 'emStrongLDelim' | 'emStrongRDelimAst' | 'emStrongRDelimUnd' | 'punctuation' | 'reflinkSearch', RegExp >; breaks: Record< | 'link' | 'code' | 'url' | 'br' | 'del' | 'text' | 'escape' | 'tag' | 'reflink' | 'nolink' | '_backpedal' | 'anyPunctuation' | 'autolink' | 'blockSkip' | 'emStrongLDelim' | 'emStrongRDelimAst' | 'emStrongRDelimUnd' | 'punctuation' | 'reflinkSearch', RegExp >; pedantic: Record< | 'link' | 'code' | 'url' | 'br' | 'del' | 'text' | 'escape' | 'tag' | 'reflink' | 'nolink' | '_backpedal' | 'anyPunctuation' | 'autolink' | 'blockSkip' | 'emStrongLDelim' | 'emStrongRDelimAst' | 'emStrongRDelimUnd' | 'punctuation' | 'reflinkSearch', RegExp >; };};
Expose Rules
property state
state: { inLink: boolean; inRawBlock: boolean; top: boolean };
property tokens
tokens: Token[] & { links: Links };
method blockTokens
blockTokens: { (src: string, tokens?: Token[], lastParagraphClipped?: boolean): Token[]; ( src: string, tokens?: TokensList, lastParagraphClipped?: boolean ): TokensList;};
Lexing
method inline
inline: (src: string, tokens?: Token[]) => Token[];
method inlineTokens
inlineTokens: (src: string, tokens?: Token[]) => Token[];
Lexing/Compiling
method lex
static lex: (src: string, options?: MarkedOptions) => TokensList;
Static Lex Method
Preprocessing
method lexInline
static lexInline: (src: string, options?: MarkedOptions) => Token[];
Static Lex Inline Method
class Marked
class Marked {}
constructor
constructor(...args: MarkedExtension[]);
property defaults
defaults: MarkedOptions;
property Hooks
Hooks: typeof _Hooks;
property Lexer
Lexer: typeof _Lexer;
property options
options: (opt: MarkedOptions) => this;
property parse
parse: { (src: string, options: MarkedOptions & { async: true }): Promise<string>; (src: string, options: MarkedOptions & { async: false }): string; (src: string, options?: MarkedOptions | undefined | null): | string | Promise<string>;};
property parseInline
parseInline: { (src: string, options: MarkedOptions & { async: true }): Promise<string>; (src: string, options: MarkedOptions & { async: false }): string; (src: string, options?: MarkedOptions | undefined | null): | string | Promise<string>;};
property Parser
Parser: typeof _Parser;
property Renderer
Renderer: typeof _Renderer;
property TextRenderer
TextRenderer: typeof _TextRenderer;
property Tokenizer
Tokenizer: typeof _Tokenizer;
method lexer
lexer: (src: string, options?: MarkedOptions) => TokensList;
method parser
parser: (tokens: Token[], options?: MarkedOptions) => string;
method setOptions
setOptions: (opt: MarkedOptions) => this;
method use
use: (...args: MarkedExtension[]) => this;
method walkTokens
walkTokens: ( tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
Run callback for every token
class Parser
class _Parser {}
Parsing & Compiling
constructor
constructor(options?: MarkedOptions);
property options
options: MarkedOptions;
property renderer
renderer: _Renderer;
property textRenderer
textRenderer: _TextRenderer;
method parse
static parse: (tokens: Token[], options?: MarkedOptions) => string;
Static Parse Method
Parse Loop
method parseInline
static parseInline: (tokens: Token[], options?: MarkedOptions) => string;
Static Parse Inline Method
Parse Inline Tokens
class Renderer
class _Renderer {}
Renderer
constructor
constructor(options?: MarkedOptions);
property options
options: MarkedOptions;
property parser
parser: _Parser;
method blockquote
blockquote: ({ tokens }: Tokens.Blockquote) => string;
method br
br: (token: Tokens.Br) => string;
method checkbox
checkbox: ({ checked }: Tokens.Checkbox) => string;
method code
code: ({ text, lang, escaped }: Tokens.Code) => string;
method codespan
codespan: ({ text }: Tokens.Codespan) => string;
method del
del: ({ tokens }: Tokens.Del) => string;
method em
em: ({ tokens }: Tokens.Em) => string;
method heading
heading: ({ tokens, depth }: Tokens.Heading) => string;
method hr
hr: (token: Tokens.Hr) => string;
method html
html: ({ text }: Tokens.HTML | Tokens.Tag) => string;
method image
image: ({ href, title, text }: Tokens.Image) => string;
method link
link: ({ href, title, tokens }: Tokens.Link) => string;
method list
list: (token: Tokens.List) => string;
method listitem
listitem: (item: Tokens.ListItem) => string;
method paragraph
paragraph: ({ tokens }: Tokens.Paragraph) => string;
method space
space: (token: Tokens.Space) => string;
method strong
strong: ({ tokens }: Tokens.Strong) => string;
span level renderer
method table
table: (token: Tokens.Table) => string;
method tablecell
tablecell: (token: Tokens.TableCell) => string;
method tablerow
tablerow: ({ text }: Tokens.TableRow) => string;
method text
text: (token: Tokens.Text | Tokens.Escape) => string;
class TextRenderer
class _TextRenderer {}
TextRenderer returns only the textual part of the token
method br
br: () => string;
method codespan
codespan: ({ text }: Tokens.Codespan) => string;
method del
del: ({ text }: Tokens.Del) => string;
method em
em: ({ text }: Tokens.Em) => string;
method html
html: ({ text }: Tokens.HTML | Tokens.Tag) => string;
method image
image: ({ text }: Tokens.Image) => string;
method link
link: ({ text }: Tokens.Link) => string;
method strong
strong: ({ text }: Tokens.Strong) => string;
method text
text: ({ text }: Tokens.Text | Tokens.Escape | Tokens.Tag) => string;
class Tokenizer
class _Tokenizer {}
Tokenizer
constructor
constructor(options?: MarkedOptions);
property lexer
lexer: _Lexer;
property options
options: MarkedOptions;
property rules
rules: Rules;
method autolink
autolink: (src: string) => Tokens.Link | undefined;
method blockquote
blockquote: (src: string) => Tokens.Blockquote | undefined;
method br
br: (src: string) => Tokens.Br | undefined;
method code
code: (src: string) => Tokens.Code | undefined;
method codespan
codespan: (src: string) => Tokens.Codespan | undefined;
method def
def: (src: string) => Tokens.Def | undefined;
method del
del: (src: string) => Tokens.Del | undefined;
method emStrong
emStrong: ( src: string, maskedSrc: string, prevChar?: string) => Tokens.Em | Tokens.Strong | undefined;
method escape
escape: (src: string) => Tokens.Escape | undefined;
method fences
fences: (src: string) => Tokens.Code | undefined;
method heading
heading: (src: string) => Tokens.Heading | undefined;
method hr
hr: (src: string) => Tokens.Hr | undefined;
method html
html: (src: string) => Tokens.HTML | undefined;
method inlineText
inlineText: (src: string) => Tokens.Text | undefined;
method lheading
lheading: (src: string) => Tokens.Heading | undefined;
method link
link: (src: string) => Tokens.Link | Tokens.Image | undefined;
method list
list: (src: string) => Tokens.List | undefined;
method paragraph
paragraph: (src: string) => Tokens.Paragraph | undefined;
method reflink
reflink: ( src: string, links: Links) => Tokens.Link | Tokens.Image | Tokens.Text | undefined;
method space
space: (src: string) => Tokens.Space | undefined;
method table
table: (src: string) => Tokens.Table | undefined;
method tag
tag: (src: string) => Tokens.Tag | undefined;
method text
text: (src: string) => Tokens.Text | undefined;
method url
url: (src: string) => Tokens.Link | undefined;
Interfaces
interface MarkedExtension
interface MarkedExtension {}
property async
async?: boolean;
True will tell marked to await any walkTokens functions before parsing the tokens and returning an HTML string.
property breaks
breaks?: boolean | undefined;
Enable GFM line breaks. This option requires the gfm option to be true.
property extensions
extensions?: TokenizerAndRendererExtension[] | undefined | null;
Add tokenizers and renderers to marked
property gfm
gfm?: boolean | undefined;
Enable GitHub flavored markdown.
property hooks
hooks?: HooksObject | undefined | null;
Hooks are methods that hook into some part of marked. preprocess is called to process markdown before sending it to marked. processAllTokens is called with the TokensList before walkTokens. postprocess is called to process html after marked has finished parsing. provideLexer is called to provide a function to tokenize markdown. provideParser is called to provide a function to parse tokens.
property pedantic
pedantic?: boolean | undefined;
Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
property renderer
renderer?: RendererObject | undefined | null;
Type: object Default: new Renderer()
An object containing functions to render tokens to HTML.
property silent
silent?: boolean | undefined;
Shows an HTML error message when rendering fails.
property tokenizer
tokenizer?: TokenizerObject | undefined | null;
The tokenizer defines how to turn markdown text into tokens.
property walkTokens
walkTokens?: ((token: Token) => void | Promise<void>) | undefined | null;
The walkTokens function gets called with every token. Child tokens are called before moving on to sibling tokens. Each token is passed by reference so updates are persisted when passed to the parser. The return value of the function is ignored.
interface MarkedOptions
interface MarkedOptions extends Omit< MarkedExtension, 'hooks' | 'renderer' | 'tokenizer' | 'extensions' | 'walkTokens' > {}
property extensions
extensions?: null | { renderers: { [name: string]: RendererExtensionFunction; }; childTokens: { [name: string]: string[]; }; inline?: TokenizerExtensionFunction[]; block?: TokenizerExtensionFunction[]; startInline?: TokenizerStartFunction[]; startBlock?: TokenizerStartFunction[];};
Custom extensions
property hooks
hooks?: _Hooks | undefined | null;
Hooks are methods that hook into some part of marked.
property renderer
renderer?: _Renderer | undefined | null;
Type: object Default: new Renderer()
An object containing functions to render tokens to HTML.
property tokenizer
tokenizer?: _Tokenizer | undefined | null;
The tokenizer defines how to turn markdown text into tokens.
property walkTokens
walkTokens?: | null | ((token: Token) => void | Promise<void> | (void | Promise<void>)[]);
walkTokens function returns array of values for Promise.all
interface RendererExtension
interface RendererExtension {}
interface RendererThis
interface RendererThis {}
property parser
parser: _Parser;
interface Rules
interface Rules {}
interface TokenizerExtension
interface TokenizerExtension {}
property childTokens
childTokens?: string[] | undefined;
property level
level: 'block' | 'inline';
property name
name: string;
property start
start?: TokenizerStartFunction | undefined;
property tokenizer
tokenizer: TokenizerExtensionFunction;
interface TokenizerThis
interface TokenizerThis {}
property lexer
lexer: _Lexer;
Type Aliases
type BlockKeys
type BlockKeys = keyof typeof blockNormal;
type HooksApi
type HooksApi = Omit<_Hooks, 'constructor' | 'options' | 'block'>;
type HooksObject
type HooksObject = { [K in keyof HooksApi]?: ( this: _Hooks, ...args: Parameters<HooksApi[K]> ) => ReturnType<HooksApi[K]> | Promise<ReturnType<HooksApi[K]>>;};
type InlineKeys
type InlineKeys = keyof typeof inlineNormal;
type Links
type Links = Record<string, Pick<Tokens.Link | Tokens.Image, 'href' | 'title'>>;
type MarkedToken
type MarkedToken = | Tokens.Space | Tokens.Code | Tokens.Heading | Tokens.Table | Tokens.Hr | Tokens.Blockquote | Tokens.List | Tokens.ListItem | Tokens.Paragraph | Tokens.HTML | Tokens.Text | Tokens.Def | Tokens.Escape | Tokens.Tag | Tokens.Image | Tokens.Link | Tokens.Strong | Tokens.Em | Tokens.Codespan | Tokens.Br | Tokens.Del;
type MaybePromise
type MaybePromise = void | Promise<void>;
type RendererApi
type RendererApi = Omit<_Renderer, 'constructor' | 'options' | 'parser'>;
type RendererExtensionFunction
type RendererExtensionFunction = ( this: RendererThis, token: Tokens.Generic) => string | false | undefined;
type RendererObject
type RendererObject = { [K in keyof RendererApi]?: ( this: _Renderer, ...args: Parameters<RendererApi[K]> ) => ReturnType<RendererApi[K]> | false;};
type Token
type Token = MarkedToken | Tokens.Generic;
type TokenizerAndRendererExtension
type TokenizerAndRendererExtension = | TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension);
type TokenizerApi
type TokenizerApi = Omit<_Tokenizer, 'constructor' | 'options' | 'rules' | 'lexer'>;
type TokenizerExtensionFunction
type TokenizerExtensionFunction = ( this: TokenizerThis, src: string, tokens: Token[] | TokensList) => Tokens.Generic | undefined;
type TokenizerObject
type TokenizerObject = { [K in keyof TokenizerApi]?: ( this: _Tokenizer, ...args: Parameters<TokenizerApi[K]> ) => ReturnType<TokenizerApi[K]> | false;};
type TokenizerStartFunction
type TokenizerStartFunction = (this: TokenizerThis, src: string) => number | void;
type TokensList
type TokensList = Token[] & { links: Links;};
Namespaces
namespace marked
namespace marked {}
variable defaults
var defaults: MarkedOptions;
variable getDefaults
var getDefaults: () => MarkedOptions;
variable Hooks
var Hooks: typeof _Hooks;
variable lexer
var lexer: (src: string, options?: MarkedOptions) => TokensList;
variable Lexer
var Lexer: typeof _Lexer;
variable parse
var parse: typeof marked;
variable parseInline
var parseInline: { (src: string, options: MarkedOptions & { async: true }): Promise<string>; (src: string, options: MarkedOptions & { async: false }): string; (src: string, options?: MarkedOptions | undefined | null): | string | Promise<string>;};
variable parser
var parser: (tokens: Token[], options?: MarkedOptions) => string;
variable Parser
var Parser: typeof _Parser;
variable Renderer
var Renderer: typeof _Renderer;
variable TextRenderer
var TextRenderer: typeof _TextRenderer;
variable Tokenizer
var Tokenizer: typeof _Tokenizer;
function options
options: (options: MarkedOptions) => typeof marked;
function setOptions
setOptions: (options: MarkedOptions) => typeof marked;
function use
use: (...args: MarkedExtension[]) => typeof marked;
function walkTokens
walkTokens: ( tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
namespace Tokens
namespace Tokens {}
interface Blockquote
interface Blockquote {}
interface Code
interface Code {}
interface Codespan
interface Codespan {}
interface Def
interface Def {}
interface Del
interface Del {}
interface Em
interface Em {}
interface Escape
interface Escape {}
interface Generic
interface Generic {}
property raw
raw: string;
property tokens
tokens?: Token[] | undefined;
property type
type: string;
index signature
[index: string]: any;
interface Heading
interface Heading {}
interface HTML
interface HTML {}
interface Image
interface Image {}
interface Link
interface Link {}
interface List
interface List {}
interface ListItem
interface ListItem {}
interface Paragraph
interface Paragraph {}
interface Strong
interface Strong {}
interface Table
interface Table {}
interface TableCell
interface TableCell {}
interface Tag
interface Tag {}
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (27)
- @arethetypeswrong/cli
- @markedjs/eslint-config
- @markedjs/testutils
- @rollup/plugin-terser
- @rollup/plugin-typescript
- @semantic-release/commit-analyzer
- @semantic-release/git
- @semantic-release/github
- @semantic-release/npm
- @semantic-release/release-notes-generator
- cheerio
- commonmark
- cross-env
- dts-bundle-generator
- eslint
- highlight.js
- markdown-it
- marked-highlight
- marked-man
- node-fetch
- recheck
- rollup
- semantic-release
- titleize
- ts-expect
- tslib
- typescript
Peer Dependencies (0)
No peer dependencies.
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/marked
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/marked)
- HTML<a href="https://www.jsdocs.io/package/marked"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 6541 ms. - Missing or incorrect documentation? Open an issue for this package.