@types/marked
- Version 4.0.8
- Published
- 25.6 kB
- No dependencies
- MIT license
Install
npm i @types/marked
yarn add @types/marked
pnpm add @types/marked
Overview
TypeScript definitions for Marked
Index
Functions
Classes
Namespaces
marked
- defaults
- getDefaults()
- lexer()
- Lexer
- MarkedExtension
- MarkedOptions
- options()
- parse()
- parseInline()
- parser()
- Parser
- Renderer
- RendererExtension
- RendererObject
- RendererThis
- Rules
- setOptions()
- Slugger
- SluggerOptions
- TextRenderer
- Token
- Tokenizer
- TokenizerAndRendererExtension
- TokenizerExtension
- TokenizerObject
- TokenizerThis
- TokensList
- use()
- walkTokens()
Functions
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 synchronously.
Parameter src
String of markdown source to be compiled
Parameter options
Optional hash of options String of compiled HTML
Compiles markdown to HTML asynchronously with a callback.
Parameter src
String of markdown source to be compiled
Parameter callback
Function called when the markdownString has been fully parsed when using async highlighting
Compiles markdown to HTML asynchronously with a callback.
Parameter src
String of markdown source to be compiled
Parameter options
Hash of options
Parameter callback
Function called when the markdownString has been fully parsed when using async highlighting
Classes
class Lexer
class Lexer extends marked.Lexer {}
class Parser
class Parser extends marked.Parser {}
class Renderer
class Renderer<T = never> extends marked.Renderer<T> {}
class Slugger
class Slugger extends marked.Slugger {}
class TextRenderer
class TextRenderer extends marked.TextRenderer {}
class Tokenizer
class Tokenizer<T = never> extends marked.Tokenizer<T> {}
Namespaces
namespace marked
namespace marked {}
variable defaults
const defaults: MarkedOptions;
function getDefaults
getDefaults: () => MarkedOptions;
Gets the original marked default options.
function lexer
lexer: (src: string, options?: MarkedOptions) => TokensList;
Parameter src
String of markdown source to be compiled
Parameter options
Hash of options
function options
options: (options: MarkedOptions) => typeof marked;
Sets the default options.
Parameter options
Hash of options
function parse
parse: { (src: string, callback: (error: any, parseResult: string) => void): void; (src: string, options: MarkedOptions & { async: true }): Promise<string>; (src: string, options?: MarkedOptions): string; ( src: string, options: MarkedOptions, callback: (error: any, parseResult: string) => void ): void;};
Compiles markdown to HTML.
Parameter src
String of markdown source to be compiled
Parameter callback
Function called when the markdownString has been fully parsed when using async highlighting String of compiled HTML
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 synchronously.
Parameter src
String of markdown source to be compiled
Parameter options
Optional hash of options String of compiled HTML
Compiles markdown to HTML synchronously.
Parameter src
String of markdown source to be compiled
Parameter options
Optional hash of options
Parameter callback
Function called when the markdownString has been fully parsed when using async highlighting String of compiled HTML
function parseInline
parseInline: (src: string, options?: MarkedOptions) => string;
Compiles markdown to HTML without enclosing
p
tag.Parameter src
String of markdown source to be compiled
Parameter options
Hash of options String of compiled HTML
function parser
parser: (src: Token[] | TokensList, options?: MarkedOptions) => string;
Parameter src
Tokenized source as array of tokens
Parameter options
Hash of options
function setOptions
setOptions: (options: MarkedOptions) => typeof marked;
Sets the default options.
Parameter options
Hash of options
function use
use: (...extensions: MarkedExtension[]) => void;
Use Extension
Parameter MarkedExtension
function walkTokens
walkTokens: ( tokens: Token[] | TokensList, callback: (token: Token) => void) => typeof marked;
class Lexer
class Lexer {}
constructor
constructor(options?: MarkedOptions);
property options
options: MarkedOptions;
property rules
static rules: Rules;
property rules
rules: Rules;
property state
state: { inLink: boolean; inRawBlock: boolean; top: boolean };
property tokens
tokens: Token[] & { links: { [key: string]: { href: string; title: string } } };
method blockTokens
blockTokens: { (src: string, tokens: Token[]): Token[]; (src: string, tokens: TokensList): TokensList;};
method inline
inline: (src: string, tokens?: Token[]) => Token[];
method inlineTokens
inlineTokens: (src: string, tokens?: Token[]) => Token[];
method lex
static lex: (src: string, options?: MarkedOptions) => TokensList;
method lexInline
static lexInline: (src: string, options?: MarkedOptions) => Token[];
class Parser
class Parser {}
constructor
constructor(options?: MarkedOptions);
property options
options: MarkedOptions;
property renderer
renderer: Renderer<never>;
property slugger
slugger: Slugger;
property textRenderer
textRenderer: TextRenderer;
property token
token: Token;
property tokens
tokens: TokensList | Token[];
method next
next: () => Token;
method parse
static parse: (src: Token[] | TokensList, options?: MarkedOptions) => string;
method parseInline
static parseInline: (src: Token[], options?: MarkedOptions) => string;
class Renderer
class Renderer<T = never> {}
constructor
constructor(options?: MarkedOptions);
property options
options: MarkedOptions;
method blockquote
blockquote: (this: Renderer | RendererThis, quote: string) => string | T;
method br
br: (this: Renderer | RendererThis) => string | T;
method checkbox
checkbox: (this: Renderer | RendererThis, checked: boolean) => string | T;
method code
code: ( this: Renderer | RendererThis, code: string, language: string | undefined, isEscaped: boolean) => string | T;
method codespan
codespan: (this: Renderer | RendererThis, code: string) => string | T;
method del
del: (this: Renderer | RendererThis, text: string) => string | T;
method em
em: (this: Renderer | RendererThis, text: string) => string | T;
method heading
heading: ( this: Renderer | RendererThis, text: string, level: 1 | 2 | 3 | 4 | 5 | 6, raw: string, slugger: Slugger) => string | T;
method hr
hr: (this: Renderer | RendererThis) => string | T;
method html
html: (this: Renderer | RendererThis, html: string) => string | T;
method image
image: ( this: Renderer | RendererThis, href: string | null, title: string | null, text: string) => string | T;
method link
link: ( this: Renderer | RendererThis, href: string | null, title: string | null, text: string) => string | T;
method list
list: ( this: Renderer | RendererThis, body: string, ordered: boolean, start: number) => string | T;
method listitem
listitem: ( this: Renderer | RendererThis, text: string, task: boolean, checked: boolean) => string | T;
method paragraph
paragraph: (this: Renderer | RendererThis, text: string) => string | T;
method strong
strong: (this: Renderer | RendererThis, text: string) => string | T;
method table
table: ( this: Renderer | RendererThis, header: string, body: string) => string | T;
method tablecell
tablecell: ( this: Renderer | RendererThis, content: string, flags: { header: boolean; align: 'center' | 'left' | 'right' | null }) => string | T;
method tablerow
tablerow: (this: Renderer | RendererThis, content: string) => string | T;
method text
text: (this: Renderer | RendererThis, text: string) => string | T;
class Slugger
class Slugger {}
class TextRenderer
class TextRenderer {}
method br
br: () => string;
method codespan
codespan: (text: string) => string;
method del
del: (text: string) => string;
method em
em: (text: string) => string;
method html
html: (text: string) => string;
method image
image: (href: string | null, title: string | null, text: string) => string;
method link
link: (href: string | null, title: string | null, text: string) => string;
method strong
strong: (text: string) => string;
method text
text: (text: string) => string;
class Tokenizer
class Tokenizer<T = never> {}
constructor
constructor(options?: MarkedOptions);
property options
options: MarkedOptions;
method autolink
autolink: ( this: Tokenizer & TokenizerThis, src: string, mangle: (cap: string) => string) => Tokens.Link | T;
method blockquote
blockquote: ( this: Tokenizer & TokenizerThis, src: string) => Tokens.Blockquote | T;
method br
br: (this: Tokenizer & TokenizerThis, src: string) => Tokens.Br | T;
method code
code: (this: Tokenizer & TokenizerThis, src: string) => Tokens.Code | T;
method codespan
codespan: (this: Tokenizer & TokenizerThis, src: string) => Tokens.Codespan | T;
method def
def: (this: Tokenizer & TokenizerThis, src: string) => Tokens.Def | T;
method del
del: (this: Tokenizer & TokenizerThis, src: string) => Tokens.Del | T;
method emStrong
emStrong: ( this: Tokenizer & TokenizerThis, src: string, maskedSrc: string, prevChar: string) => Tokens.Em | Tokens.Strong | T;
method escape
escape: (this: Tokenizer & TokenizerThis, src: string) => Tokens.Escape | T;
method fences
fences: (this: Tokenizer & TokenizerThis, src: string) => Tokens.Code | T;
method heading
heading: (this: Tokenizer & TokenizerThis, src: string) => Tokens.Heading | T;
method hr
hr: (this: Tokenizer & TokenizerThis, src: string) => Tokens.Hr | T;
method html
html: (this: Tokenizer & TokenizerThis, src: string) => Tokens.HTML | T;
method inlineText
inlineText: ( this: Tokenizer & TokenizerThis, src: string, smartypants: (cap: string) => string) => Tokens.Text | T;
method lheading
lheading: (this: Tokenizer & TokenizerThis, src: string) => Tokens.Heading | T;
method link
link: ( this: Tokenizer & TokenizerThis, src: string) => Tokens.Image | Tokens.Link | T;
method list
list: (this: Tokenizer & TokenizerThis, src: string) => Tokens.List | T;
method paragraph
paragraph: ( this: Tokenizer & TokenizerThis, src: string) => Tokens.Paragraph | T;
method reflink
reflink: ( this: Tokenizer & TokenizerThis, src: string, links: Tokens.Link[] | Tokens.Image[]) => Tokens.Link | Tokens.Image | Tokens.Text | T;
method space
space: (this: Tokenizer & TokenizerThis, src: string) => Tokens.Space | T;
method table
table: (this: Tokenizer & TokenizerThis, src: string) => Tokens.Table | T;
method tag
tag: (this: Tokenizer & TokenizerThis, src: string) => Tokens.Tag | T;
method text
text: (this: Tokenizer & TokenizerThis, src: string) => Tokens.Text | T;
method url
url: ( this: Tokenizer & TokenizerThis, src: string, mangle: (cap: string) => string) => Tokens.Link | T;
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 baseUrl
baseUrl?: string | undefined;
A prefix URL for any relative link.
property breaks
breaks?: boolean | undefined;
Enable GFM line breaks. This option requires the gfm option to be true.
property extensions
extensions?: TokenizerAndRendererExtension[] | undefined;
Add tokenizers and renderers to marked
property gfm
gfm?: boolean | undefined;
Enable GitHub flavored markdown.
property headerIds
headerIds?: boolean | undefined;
Include an id attribute when emitting headings.
property headerPrefix
headerPrefix?: string | undefined;
Set the prefix for header tag ids.
property langPrefix
langPrefix?: string | undefined;
Set the prefix for code block classes.
property mangle
mangle?: boolean | undefined;
Mangle autolinks (<email@domain.com>).
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?: Renderer | RendererObject | undefined;
Type: object Default: new Renderer()
An object containing functions to render tokens to HTML.
property sanitize
sanitize?: boolean | undefined;
Sanitize the output. Ignore any HTML that has been input.
property silent
silent?: boolean | undefined;
Shows an HTML error message when rendering fails.
property smartLists
smartLists?: boolean | undefined;
Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic.
property smartypants
smartypants?: boolean | undefined;
Use "smart" typograhic punctuation for things like quotes and dashes.
property tokenizer
tokenizer?: Tokenizer | TokenizerObject | undefined;
The tokenizer defines how to turn markdown text into tokens.
property walkTokens
walkTokens?: ((token: Token) => void) | undefined;
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.
property xhtml
xhtml?: boolean | undefined;
Generate closing slash for self-closing tags ( instead of )
method highlight
highlight: ( code: string, lang: string, callback?: (error: any, code?: string) => void) => string | void;
A function to highlight code blocks. The function can either be synchronous (returning a string) or asynchronous (callback invoked with an error if any occurred during highlighting and a string if highlighting was successful)
method sanitizer
sanitizer: (html: string) => string;
Optionally sanitize found HTML with a sanitizer function.
interface MarkedOptions
interface MarkedOptions extends Omit<MarkedExtension, 'extensions'> {}
interface RendererExtension
interface RendererExtension {}
interface RendererThis
interface RendererThis {}
property parser
parser: Parser;
interface Rules
interface Rules {}
index signature
[ruleName: string]: RegExp | Rules;
interface SluggerOptions
interface SluggerOptions {}
property dryrun
dryrun: boolean;
interface TokenizerExtension
interface TokenizerExtension {}
property childTokens
childTokens?: string[] | undefined;
property level
level: 'block' | 'inline';
property name
name: string;
property start
start?: ((this: TokenizerThis, src: string) => number | void) | undefined;
property tokenizer
tokenizer: ( this: TokenizerThis, src: string, tokens: Token[] | TokensList) => Tokens.Generic | void;
interface TokenizerThis
interface TokenizerThis {}
property lexer
lexer: Lexer;
type RendererObject
type RendererObject = Partial<Omit<Renderer<false>, 'constructor' | 'options'>>;
type Token
type Token = | 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 TokenizerAndRendererExtension
type TokenizerAndRendererExtension = | TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension);
type TokenizerObject
type TokenizerObject = Partial<Omit<Tokenizer<false>, 'constructor' | 'options'>>;
type TokensList
type TokensList = Token[] & { links: { [key: string]: { href: string | null; title: string | null }; };};
namespace marked.Tokens
namespace marked.Tokens {}
interface Blockquote
interface Blockquote {}
interface Code
interface Code {}
property codeBlockStyle
codeBlockStyle?: 'indented' | undefined;
property lang
lang?: string | undefined;
property raw
raw: string;
property text
text: string;
property type
type: '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 {}
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (0)
No dev dependencies.
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/@types/marked
.
- Markdown[](https://www.jsdocs.io/package/@types/marked)
- HTML<a href="https://www.jsdocs.io/package/@types/marked"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4945 ms. - Missing or incorrect documentation? Open an issue for this package.