fix: use rollup to output js files (#2916)
This commit is contained in:
parent
9c5721ecd0
commit
610bc45d96
4
.github/workflows/tests.yml
vendored
4
.github/workflows/tests.yml
vendored
@ -29,6 +29,10 @@ jobs:
|
||||
run: npm run test:unit
|
||||
- name: Run Spec Tests 👩🏽💻
|
||||
run: npm run test:specs
|
||||
- name: Run UMD Tests 👩🏽💻
|
||||
run: npm run test:umd
|
||||
- name: Run Types Tests 👩🏽💻
|
||||
run: npm run test:types
|
||||
|
||||
Lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
1609
lib/marked.cjs
generated
1609
lib/marked.cjs
generated
File diff suppressed because it is too large
Load Diff
2
lib/marked.cjs.map
generated
2
lib/marked.cjs.map
generated
File diff suppressed because one or more lines are too long
658
lib/marked.d.ts
generated
vendored
658
lib/marked.d.ts
generated
vendored
@ -1,8 +1,9 @@
|
||||
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) & {
|
||||
declare module "Tokens" {
|
||||
export 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) & {
|
||||
loose?: boolean;
|
||||
tokens?: Token[];
|
||||
};
|
||||
declare namespace Tokens {
|
||||
};
|
||||
export namespace Tokens {
|
||||
interface Space {
|
||||
type: 'space';
|
||||
raw: string;
|
||||
@ -148,112 +149,20 @@ declare namespace Tokens {
|
||||
raw: string;
|
||||
tokens?: Token[] | undefined;
|
||||
}
|
||||
}
|
||||
type Links = Record<string, Pick<Tokens.Link | Tokens.Image, 'href' | 'title'>>;
|
||||
type TokensList = Token[] & {
|
||||
}
|
||||
export type Links = Record<string, Pick<Tokens.Link | Tokens.Image, 'href' | 'title'>>;
|
||||
export type TokensList = Token[] & {
|
||||
links: Links;
|
||||
};
|
||||
|
||||
/**
|
||||
* Renderer
|
||||
*/
|
||||
declare class _Renderer {
|
||||
options: MarkedOptions;
|
||||
constructor(options?: MarkedOptions);
|
||||
code(code: string, infostring: string | undefined, escaped: boolean): string;
|
||||
blockquote(quote: string): string;
|
||||
html(html: string, block?: boolean): string;
|
||||
heading(text: string, level: number, raw: string, slugger: _Slugger): string;
|
||||
hr(): string;
|
||||
list(body: string, ordered: boolean, start: number | ''): string;
|
||||
listitem(text: string, task: boolean, checked: boolean): string;
|
||||
checkbox(checked: boolean): string;
|
||||
paragraph(text: string): string;
|
||||
table(header: string, body: string): string;
|
||||
tablerow(content: string): string;
|
||||
tablecell(content: string, flags: {
|
||||
header: boolean;
|
||||
align: 'center' | 'left' | 'right' | null;
|
||||
}): string;
|
||||
/**
|
||||
* span level renderer
|
||||
*/
|
||||
strong(text: string): string;
|
||||
em(text: string): string;
|
||||
codespan(text: string): string;
|
||||
br(): string;
|
||||
del(text: string): string;
|
||||
link(href: string, title: string | null | undefined, text: string): string;
|
||||
image(href: string, title: string | null, text: string): string;
|
||||
text(text: string): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* TextRenderer
|
||||
* returns only the textual part of the token
|
||||
*/
|
||||
declare class _TextRenderer {
|
||||
strong(text: string): string;
|
||||
em(text: string): string;
|
||||
codespan(text: string): string;
|
||||
del(text: string): string;
|
||||
html(text: string): string;
|
||||
text(text: string): string;
|
||||
link(href: string, title: string | null | undefined, text: string): string;
|
||||
image(href: string, title: string | null, text: string): string;
|
||||
br(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Slugger generates header id
|
||||
*/
|
||||
declare class _Slugger {
|
||||
seen: {
|
||||
[slugValue: string]: number;
|
||||
};
|
||||
constructor();
|
||||
serialize(value: string): string;
|
||||
/**
|
||||
* Finds the next safe (unique) slug to use
|
||||
*/
|
||||
getNextSafeSlug(originalSlug: string, isDryRun: boolean | undefined): string;
|
||||
/**
|
||||
* Convert string to unique id
|
||||
*/
|
||||
slug(value: string, options?: SluggerOptions): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parsing & Compiling
|
||||
*/
|
||||
declare class _Parser {
|
||||
options: MarkedOptions;
|
||||
renderer: _Renderer;
|
||||
textRenderer: _TextRenderer;
|
||||
slugger: _Slugger;
|
||||
constructor(options?: MarkedOptions);
|
||||
declare module "Tokenizer" {
|
||||
import { _Lexer } from "Lexer";
|
||||
import type { Links, Tokens } from "Tokens";
|
||||
import type { MarkedOptions } from "MarkedOptions";
|
||||
/**
|
||||
* Static Parse Method
|
||||
*/
|
||||
static parse(tokens: Token[], options?: MarkedOptions): string;
|
||||
/**
|
||||
* Static Parse Inline Method
|
||||
*/
|
||||
static parseInline(tokens: Token[], options?: MarkedOptions): string;
|
||||
/**
|
||||
* Parse Loop
|
||||
*/
|
||||
parse(tokens: Token[], top?: boolean): string;
|
||||
/**
|
||||
* Parse Inline Tokens
|
||||
*/
|
||||
parseInline(tokens: Token[], renderer?: _Renderer | _TextRenderer): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tokenizer
|
||||
*/
|
||||
declare class _Tokenizer {
|
||||
export class _Tokenizer {
|
||||
options: MarkedOptions;
|
||||
rules: any;
|
||||
lexer: _Lexer;
|
||||
@ -282,39 +191,372 @@ declare class _Tokenizer {
|
||||
autolink(src: string, mangle: (cap: string) => string): Tokens.Link | undefined;
|
||||
url(src: string, mangle: (cap: string) => string): Tokens.Link | undefined;
|
||||
inlineText(src: string, smartypants: (cap: string) => string): Tokens.Text | undefined;
|
||||
}
|
||||
}
|
||||
|
||||
interface SluggerOptions {
|
||||
declare module "rules" {
|
||||
export type Rule = RegExp | string;
|
||||
export interface Rules {
|
||||
[ruleName: string]: Pick<RegExp, 'exec'> | Rule | Rules;
|
||||
}
|
||||
type BlockRuleNames = 'newline' | 'code' | 'fences' | 'hr' | 'heading' | 'blockquote' | 'list' | 'html' | 'def' | 'lheading' | '_paragraph' | 'text' | '_label' | '_title' | 'bullet' | 'listItemStart' | '_tag' | '_comment' | 'paragraph' | 'uote';
|
||||
type BlockSubRuleNames = 'normal' | 'gfm' | 'pedantic';
|
||||
type InlineRuleNames = 'escape' | 'autolink' | 'tag' | 'link' | 'reflink' | 'nolink' | 'reflinkSearch' | 'code' | 'br' | 'text' | '_punctuation' | 'punctuation' | 'blockSkip' | 'escapedEmSt' | '_comment' | '_escapes' | '_scheme' | '_email' | '_attribute' | '_label' | '_href' | '_title' | 'strong' | '_extended_email' | '_backpedal';
|
||||
type InlineSubRuleNames = 'gfm' | 'emStrong' | 'normal' | 'pedantic' | 'breaks';
|
||||
/**
|
||||
* Block-Level Grammar
|
||||
*/
|
||||
export const block: Record<BlockRuleNames, Rule> & Record<BlockSubRuleNames, Rules> & Rules;
|
||||
/**
|
||||
* Inline-Level Grammar
|
||||
*/
|
||||
export const inline: Record<InlineRuleNames, Rule> & Record<InlineSubRuleNames, Rules> & Rules;
|
||||
}
|
||||
declare module "Lexer" {
|
||||
import type { Token, TokensList } from "Tokens";
|
||||
import type { MarkedOptions } from "MarkedOptions";
|
||||
import type { Rules } from "rules";
|
||||
/**
|
||||
* Block Lexer
|
||||
*/
|
||||
export class _Lexer {
|
||||
tokens: TokensList;
|
||||
options: MarkedOptions;
|
||||
state: {
|
||||
inLink: boolean;
|
||||
inRawBlock: boolean;
|
||||
top: boolean;
|
||||
};
|
||||
private tokenizer;
|
||||
private inlineQueue;
|
||||
constructor(options?: MarkedOptions);
|
||||
/**
|
||||
* Expose Rules
|
||||
*/
|
||||
static get rules(): Rules;
|
||||
/**
|
||||
* Static Lex Method
|
||||
*/
|
||||
static lex(src: string, options?: MarkedOptions): TokensList;
|
||||
/**
|
||||
* Static Lex Inline Method
|
||||
*/
|
||||
static lexInline(src: string, options?: MarkedOptions): Token[];
|
||||
/**
|
||||
* Preprocessing
|
||||
*/
|
||||
lex(src: string): TokensList;
|
||||
/**
|
||||
* Lexing
|
||||
*/
|
||||
blockTokens(src: string, tokens?: Token[]): Token[];
|
||||
blockTokens(src: string, tokens?: TokensList): TokensList;
|
||||
inline(src: string, tokens?: Token[]): Token[];
|
||||
/**
|
||||
* Lexing/Compiling
|
||||
*/
|
||||
inlineTokens(src: string, tokens?: Token[]): Token[];
|
||||
}
|
||||
}
|
||||
declare module "TextRenderer" {
|
||||
/**
|
||||
* TextRenderer
|
||||
* returns only the textual part of the token
|
||||
*/
|
||||
export class _TextRenderer {
|
||||
strong(text: string): string;
|
||||
em(text: string): string;
|
||||
codespan(text: string): string;
|
||||
del(text: string): string;
|
||||
html(text: string): string;
|
||||
text(text: string): string;
|
||||
link(href: string, title: string | null | undefined, text: string): string;
|
||||
image(href: string, title: string | null, text: string): string;
|
||||
br(): string;
|
||||
}
|
||||
}
|
||||
declare module "Slugger" {
|
||||
import type { SluggerOptions } from "MarkedOptions";
|
||||
/**
|
||||
* Slugger generates header id
|
||||
*/
|
||||
export class _Slugger {
|
||||
seen: {
|
||||
[slugValue: string]: number;
|
||||
};
|
||||
constructor();
|
||||
serialize(value: string): string;
|
||||
/**
|
||||
* Finds the next safe (unique) slug to use
|
||||
*/
|
||||
getNextSafeSlug(originalSlug: string, isDryRun: boolean | undefined): string;
|
||||
/**
|
||||
* Convert string to unique id
|
||||
*/
|
||||
slug(value: string, options?: SluggerOptions): string;
|
||||
}
|
||||
}
|
||||
declare module "Instance" {
|
||||
import { _Lexer } from "Lexer";
|
||||
import { _Parser } from "Parser";
|
||||
import { _Hooks } from "Hooks";
|
||||
import { _Renderer } from "Renderer";
|
||||
import { _Tokenizer } from "Tokenizer";
|
||||
import { _TextRenderer } from "TextRenderer";
|
||||
import { _Slugger } from "Slugger";
|
||||
import type { MarkedExtension, MarkedOptions } from "MarkedOptions";
|
||||
import type { Token, TokensList } from "Tokens";
|
||||
export type ResultCallback = (error: Error | null, parseResult?: string) => undefined | void;
|
||||
export class Marked {
|
||||
#private;
|
||||
defaults: MarkedOptions;
|
||||
options: (opt: any) => this;
|
||||
parse: (src: string, optOrCallback?: MarkedOptions | ResultCallback | undefined | null, callback?: ResultCallback | undefined) => string | Promise<string | undefined> | undefined;
|
||||
parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback | undefined | null, callback?: ResultCallback | undefined) => string | Promise<string | undefined> | undefined;
|
||||
Parser: typeof _Parser;
|
||||
parser: typeof _Parser.parse;
|
||||
Renderer: typeof _Renderer;
|
||||
TextRenderer: typeof _TextRenderer;
|
||||
Lexer: typeof _Lexer;
|
||||
lexer: typeof _Lexer.lex;
|
||||
Tokenizer: typeof _Tokenizer;
|
||||
Slugger: typeof _Slugger;
|
||||
Hooks: typeof _Hooks;
|
||||
constructor(...args: MarkedExtension[]);
|
||||
/**
|
||||
* Run callback for every token
|
||||
*/
|
||||
walkTokens<T = void>(tokens: Token[] | TokensList, callback: (token: Token) => T | T[]): T[];
|
||||
use(...args: MarkedExtension[]): this;
|
||||
setOptions(opt: any): this;
|
||||
}
|
||||
}
|
||||
declare module "helpers" {
|
||||
import type { MarkedOptions } from "MarkedOptions";
|
||||
import type { ResultCallback } from "Instance";
|
||||
import type { Rule } from "rules";
|
||||
export function escape(html: string, encode?: boolean): string;
|
||||
export function unescape(html: string): string;
|
||||
export function edit(regex: Rule, opt?: string): {
|
||||
replace: (name: string | RegExp, val: string | RegExp) => any;
|
||||
getRegex: () => RegExp;
|
||||
};
|
||||
export function cleanUrl(sanitize: boolean | undefined, base: string | undefined | null, href: string): string | null;
|
||||
export function resolveUrl(base: string, href: string): string;
|
||||
export const noopTest: {
|
||||
exec: () => null;
|
||||
};
|
||||
export function splitCells(tableRow: string, count: number): string[];
|
||||
/**
|
||||
* Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
||||
* /c*$/ is vulnerable to REDOS.
|
||||
*
|
||||
* @param str
|
||||
* @param c
|
||||
* @param invert Remove suffix of non-c chars instead. Default falsey.
|
||||
*/
|
||||
export function rtrim(str: string, c: string, invert?: boolean): string;
|
||||
export function findClosingBracket(str: string, b: string): number;
|
||||
export function checkDeprecations(opt: MarkedOptions, callback?: ResultCallback): void;
|
||||
}
|
||||
declare module "marked" {
|
||||
import { _Lexer } from "Lexer";
|
||||
import { _Parser } from "Parser";
|
||||
import { _Tokenizer } from "Tokenizer";
|
||||
import { _Renderer } from "Renderer";
|
||||
import { _TextRenderer } from "TextRenderer";
|
||||
import { _Slugger } from "Slugger";
|
||||
import { _Hooks } from "Hooks";
|
||||
import { _getDefaults } from "defaults";
|
||||
import type { MarkedExtension, MarkedOptions } from "MarkedOptions";
|
||||
import type { Token, TokensList } from "Tokens";
|
||||
import type { ResultCallback } from "Instance";
|
||||
/**
|
||||
* Compiles markdown to HTML asynchronously.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Hash of options, having async: true
|
||||
* @return Promise of string of compiled HTML
|
||||
*/
|
||||
export function marked(src: string, options: MarkedOptions & {
|
||||
async: true;
|
||||
}): Promise<string>;
|
||||
/**
|
||||
* Compiles markdown to HTML synchronously.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Optional hash of options
|
||||
* @return String of compiled HTML
|
||||
*/
|
||||
export function marked(src: string, options?: MarkedOptions): string;
|
||||
/**
|
||||
* Compiles markdown to HTML asynchronously with a callback.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
|
||||
*/
|
||||
export function marked(src: string, callback: ResultCallback): void;
|
||||
/**
|
||||
* Compiles markdown to HTML asynchronously with a callback.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Hash of options
|
||||
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
|
||||
*/
|
||||
export function marked(src: string, options: MarkedOptions, callback: ResultCallback): void;
|
||||
/**
|
||||
* Compiles markdown to HTML asynchronously with a callback.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Hash of options
|
||||
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
|
||||
*/
|
||||
export namespace marked {
|
||||
var options: (options: MarkedOptions) => typeof marked;
|
||||
var setOptions: (options: MarkedOptions) => typeof marked;
|
||||
var getDefaults: typeof _getDefaults;
|
||||
var defaults: MarkedOptions;
|
||||
var use: (...args: MarkedExtension[]) => typeof marked;
|
||||
var walkTokens: <T = void>(tokens: Token[] | TokensList, callback: (token: Token) => T | T[]) => T[];
|
||||
var parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback | null | undefined, callback?: ResultCallback | undefined) => string | Promise<string | undefined> | undefined;
|
||||
var Parser: typeof _Parser;
|
||||
var parser: typeof _Parser.parse;
|
||||
var Renderer: typeof _Renderer;
|
||||
var TextRenderer: typeof _TextRenderer;
|
||||
var Lexer: typeof _Lexer;
|
||||
var lexer: typeof _Lexer.lex;
|
||||
var Tokenizer: typeof _Tokenizer;
|
||||
var Slugger: typeof _Slugger;
|
||||
var Hooks: typeof _Hooks;
|
||||
var parse: typeof marked;
|
||||
}
|
||||
export const options: (options: MarkedOptions) => typeof marked;
|
||||
export const setOptions: (options: MarkedOptions) => typeof marked;
|
||||
export const use: (...args: MarkedExtension[]) => typeof marked;
|
||||
export const walkTokens: <T = void>(tokens: Token[] | TokensList, callback: (token: Token) => T | T[]) => T[];
|
||||
export const parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback | null | undefined, callback?: ResultCallback | undefined) => string | Promise<string | undefined> | undefined;
|
||||
export const parse: typeof marked;
|
||||
export const parser: typeof _Parser.parse;
|
||||
export const lexer: typeof _Lexer.lex;
|
||||
export { _defaults as defaults, _getDefaults as getDefaults } from "defaults";
|
||||
export { _Lexer as Lexer } from "Lexer";
|
||||
export { _Parser as Parser } from "Parser";
|
||||
export { _Tokenizer as Tokenizer } from "Tokenizer";
|
||||
export { _Renderer as Renderer } from "Renderer";
|
||||
export { _TextRenderer as TextRenderer } from "TextRenderer";
|
||||
export { _Slugger as Slugger } from "Slugger";
|
||||
export { _Hooks as Hooks } from "Hooks";
|
||||
export { Marked } from "Instance";
|
||||
export type * from "MarkedOptions";
|
||||
export type * from "rules";
|
||||
export type * from "Tokens";
|
||||
}
|
||||
declare module "Renderer" {
|
||||
import type { MarkedOptions } from "MarkedOptions";
|
||||
import { Slugger } from "marked";
|
||||
/**
|
||||
* Renderer
|
||||
*/
|
||||
export class _Renderer {
|
||||
options: MarkedOptions;
|
||||
constructor(options?: MarkedOptions);
|
||||
code(code: string, infostring: string | undefined, escaped: boolean): string;
|
||||
blockquote(quote: string): string;
|
||||
html(html: string, block?: boolean): string;
|
||||
heading(text: string, level: number, raw: string, slugger: Slugger): string;
|
||||
hr(): string;
|
||||
list(body: string, ordered: boolean, start: number | ''): string;
|
||||
listitem(text: string, task: boolean, checked: boolean): string;
|
||||
checkbox(checked: boolean): string;
|
||||
paragraph(text: string): string;
|
||||
table(header: string, body: string): string;
|
||||
tablerow(content: string): string;
|
||||
tablecell(content: string, flags: {
|
||||
header: boolean;
|
||||
align: 'center' | 'left' | 'right' | null;
|
||||
}): string;
|
||||
/**
|
||||
* span level renderer
|
||||
*/
|
||||
strong(text: string): string;
|
||||
em(text: string): string;
|
||||
codespan(text: string): string;
|
||||
br(): string;
|
||||
del(text: string): string;
|
||||
link(href: string, title: string | null | undefined, text: string): string;
|
||||
image(href: string, title: string | null, text: string): string;
|
||||
text(text: string): string;
|
||||
}
|
||||
}
|
||||
declare module "Parser" {
|
||||
import { _Renderer } from "Renderer";
|
||||
import { _TextRenderer } from "TextRenderer";
|
||||
import { _Slugger } from "Slugger";
|
||||
import type { Token } from "Tokens";
|
||||
import type { MarkedOptions } from "MarkedOptions";
|
||||
/**
|
||||
* Parsing & Compiling
|
||||
*/
|
||||
export class _Parser {
|
||||
options: MarkedOptions;
|
||||
renderer: _Renderer;
|
||||
textRenderer: _TextRenderer;
|
||||
slugger: _Slugger;
|
||||
constructor(options?: MarkedOptions);
|
||||
/**
|
||||
* Static Parse Method
|
||||
*/
|
||||
static parse(tokens: Token[], options?: MarkedOptions): string;
|
||||
/**
|
||||
* Static Parse Inline Method
|
||||
*/
|
||||
static parseInline(tokens: Token[], options?: MarkedOptions): string;
|
||||
/**
|
||||
* Parse Loop
|
||||
*/
|
||||
parse(tokens: Token[], top?: boolean): string;
|
||||
/**
|
||||
* Parse Inline Tokens
|
||||
*/
|
||||
parseInline(tokens: Token[], renderer?: _Renderer | _TextRenderer): string;
|
||||
}
|
||||
}
|
||||
declare module "MarkedOptions" {
|
||||
import type { Token, Tokens, TokensList } from "Tokens";
|
||||
import { _Parser } from "Parser";
|
||||
import { _Lexer } from "Lexer";
|
||||
import { _Renderer } from "Renderer";
|
||||
import { _Tokenizer } from "Tokenizer";
|
||||
export interface SluggerOptions {
|
||||
/** Generates the next unique slug without updating the internal accumulator. */
|
||||
dryrun?: boolean;
|
||||
}
|
||||
interface TokenizerThis {
|
||||
}
|
||||
export interface TokenizerThis {
|
||||
lexer: _Lexer;
|
||||
}
|
||||
interface TokenizerExtension {
|
||||
}
|
||||
export interface TokenizerExtension {
|
||||
name: string;
|
||||
level: 'block' | 'inline';
|
||||
start?: ((this: TokenizerThis, src: string) => number | void) | undefined;
|
||||
tokenizer: (this: TokenizerThis, src: string, tokens: Token[] | TokensList) => Tokens.Generic | void;
|
||||
childTokens?: string[] | undefined;
|
||||
}
|
||||
interface RendererThis {
|
||||
}
|
||||
export interface RendererThis {
|
||||
parser: _Parser;
|
||||
}
|
||||
interface RendererExtension {
|
||||
}
|
||||
export interface RendererExtension {
|
||||
name: string;
|
||||
renderer: (this: RendererThis, token: Tokens.Generic) => string | false | undefined;
|
||||
}
|
||||
type TokenizerAndRendererExtension = TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension);
|
||||
type RendererApi = Omit<_Renderer, 'constructor' | 'options'>;
|
||||
type RendererObject = {
|
||||
}
|
||||
export type TokenizerAndRendererExtension = TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension);
|
||||
type RendererApi = Omit<_Renderer, 'constructor' | 'options'>;
|
||||
type RendererObject = {
|
||||
[K in keyof RendererApi]?: (...args: Parameters<RendererApi[K]>) => ReturnType<RendererApi[K]> | false;
|
||||
};
|
||||
type TokenizerApi = Omit<_Tokenizer, 'constructor' | 'options' | 'rules' | 'lexer'>;
|
||||
type TokenizerObject = {
|
||||
};
|
||||
type TokenizerApi = Omit<_Tokenizer, 'constructor' | 'options' | 'rules' | 'lexer'>;
|
||||
type TokenizerObject = {
|
||||
[K in keyof TokenizerApi]?: (...args: Parameters<TokenizerApi[K]>) => ReturnType<TokenizerApi[K]> | false;
|
||||
};
|
||||
interface MarkedExtension {
|
||||
};
|
||||
export interface MarkedExtension {
|
||||
/**
|
||||
* True will tell marked to await any walkTokens functions before parsing the tokens and returning an HTML string.
|
||||
*/
|
||||
@ -423,8 +665,8 @@ interface MarkedExtension {
|
||||
* @deprecated Deprecated in v5.0.0 use marked-xhtml to emit self-closing HTML tags for void elements (<br/>, <img/>, etc.) with a "/" as required by XHTML.
|
||||
*/
|
||||
xhtml?: boolean | undefined;
|
||||
}
|
||||
interface MarkedOptions extends Omit<MarkedExtension, 'extensions' | 'renderer' | 'tokenizer' | 'walkTokens'> {
|
||||
}
|
||||
export interface MarkedOptions extends Omit<MarkedExtension, 'extensions' | 'renderer' | 'tokenizer' | 'walkTokens'> {
|
||||
/**
|
||||
* Type: object Default: new Renderer()
|
||||
*
|
||||
@ -453,68 +695,20 @@ interface MarkedOptions extends Omit<MarkedExtension, 'extensions' | 'renderer'
|
||||
startBlock: Array<(this: TokenizerThis, src: string) => number | void>;
|
||||
startInline: Array<(this: TokenizerThis, src: string) => number | void>;
|
||||
}) | undefined | null;
|
||||
}
|
||||
}
|
||||
|
||||
type Rule = RegExp | string;
|
||||
interface Rules {
|
||||
[ruleName: string]: Pick<RegExp, 'exec'> | Rule | Rules;
|
||||
declare module "defaults" {
|
||||
import type { MarkedOptions } from "MarkedOptions";
|
||||
/**
|
||||
* Gets the original marked default options.
|
||||
*/
|
||||
export function _getDefaults(): MarkedOptions;
|
||||
export let _defaults: MarkedOptions;
|
||||
export function changeDefaults(newDefaults: MarkedOptions): void;
|
||||
}
|
||||
type BlockRuleNames = 'newline' | 'code' | 'fences' | 'hr' | 'heading' | 'blockquote' | 'list' | 'html' | 'def' | 'lheading' | '_paragraph' | 'text' | '_label' | '_title' | 'bullet' | 'listItemStart' | '_tag' | '_comment' | 'paragraph' | 'uote';
|
||||
type BlockSubRuleNames = 'normal' | 'gfm' | 'pedantic';
|
||||
type InlineRuleNames = 'escape' | 'autolink' | 'tag' | 'link' | 'reflink' | 'nolink' | 'reflinkSearch' | 'code' | 'br' | 'text' | '_punctuation' | 'punctuation' | 'blockSkip' | 'escapedEmSt' | '_comment' | '_escapes' | '_scheme' | '_email' | '_attribute' | '_label' | '_href' | '_title' | 'strong' | '_extended_email' | '_backpedal';
|
||||
type InlineSubRuleNames = 'gfm' | 'emStrong' | 'normal' | 'pedantic' | 'breaks';
|
||||
/**
|
||||
* Block-Level Grammar
|
||||
*/
|
||||
declare const block: Record<BlockRuleNames, Rule> & Record<BlockSubRuleNames, Rules> & Rules;
|
||||
/**
|
||||
* Inline-Level Grammar
|
||||
*/
|
||||
declare const inline: Record<InlineRuleNames, Rule> & Record<InlineSubRuleNames, Rules> & Rules;
|
||||
|
||||
/**
|
||||
* Block Lexer
|
||||
*/
|
||||
declare class _Lexer {
|
||||
tokens: TokensList;
|
||||
options: MarkedOptions;
|
||||
state: {
|
||||
inLink: boolean;
|
||||
inRawBlock: boolean;
|
||||
top: boolean;
|
||||
};
|
||||
private tokenizer;
|
||||
private inlineQueue;
|
||||
constructor(options?: MarkedOptions);
|
||||
/**
|
||||
* Expose Rules
|
||||
*/
|
||||
static get rules(): Rules;
|
||||
/**
|
||||
* Static Lex Method
|
||||
*/
|
||||
static lex(src: string, options?: MarkedOptions): TokensList;
|
||||
/**
|
||||
* Static Lex Inline Method
|
||||
*/
|
||||
static lexInline(src: string, options?: MarkedOptions): Token[];
|
||||
/**
|
||||
* Preprocessing
|
||||
*/
|
||||
lex(src: string): TokensList;
|
||||
/**
|
||||
* Lexing
|
||||
*/
|
||||
blockTokens(src: string, tokens?: Token[]): Token[];
|
||||
blockTokens(src: string, tokens?: TokensList): TokensList;
|
||||
inline(src: string, tokens?: Token[]): Token[];
|
||||
/**
|
||||
* Lexing/Compiling
|
||||
*/
|
||||
inlineTokens(src: string, tokens?: Token[]): Token[];
|
||||
}
|
||||
|
||||
declare class _Hooks {
|
||||
declare module "Hooks" {
|
||||
import type { MarkedOptions } from "MarkedOptions";
|
||||
export class _Hooks {
|
||||
options: MarkedOptions;
|
||||
constructor(options?: MarkedOptions);
|
||||
static passThroughHooks: Set<string>;
|
||||
@ -526,99 +720,5 @@ declare class _Hooks {
|
||||
* Process HTML after marked is finished
|
||||
*/
|
||||
postprocess(html: string | undefined): string | undefined;
|
||||
}
|
||||
}
|
||||
|
||||
type ResultCallback$1 = (error: Error | null, parseResult?: string) => undefined | void;
|
||||
declare class Marked {
|
||||
#private;
|
||||
defaults: MarkedOptions;
|
||||
options: (opt: any) => this;
|
||||
parse: (src: string, optOrCallback?: MarkedOptions | ResultCallback$1 | undefined | null, callback?: ResultCallback$1 | undefined) => string | Promise<string | undefined> | undefined;
|
||||
parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback$1 | undefined | null, callback?: ResultCallback$1 | undefined) => string | Promise<string | undefined> | undefined;
|
||||
Parser: typeof _Parser;
|
||||
parser: typeof _Parser.parse;
|
||||
Renderer: typeof _Renderer;
|
||||
TextRenderer: typeof _TextRenderer;
|
||||
Lexer: typeof _Lexer;
|
||||
lexer: typeof _Lexer.lex;
|
||||
Tokenizer: typeof _Tokenizer;
|
||||
Slugger: typeof _Slugger;
|
||||
Hooks: typeof _Hooks;
|
||||
constructor(...args: MarkedExtension[]);
|
||||
/**
|
||||
* Run callback for every token
|
||||
*/
|
||||
walkTokens<T = void>(tokens: Token[] | TokensList, callback: (token: Token) => T | T[]): T[];
|
||||
use(...args: MarkedExtension[]): this;
|
||||
setOptions(opt: any): this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the original marked default options.
|
||||
*/
|
||||
declare function _getDefaults(): MarkedOptions;
|
||||
declare let _defaults: MarkedOptions;
|
||||
|
||||
type ResultCallback = (error: Error | null, parseResult?: string) => undefined | void;
|
||||
/**
|
||||
* Compiles markdown to HTML asynchronously.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Hash of options, having async: true
|
||||
* @return Promise of string of compiled HTML
|
||||
*/
|
||||
declare function marked(src: string, options: MarkedOptions & {
|
||||
async: true;
|
||||
}): Promise<string>;
|
||||
/**
|
||||
* Compiles markdown to HTML synchronously.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Optional hash of options
|
||||
* @return String of compiled HTML
|
||||
*/
|
||||
declare function marked(src: string, options?: MarkedOptions): string;
|
||||
/**
|
||||
* Compiles markdown to HTML asynchronously with a callback.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
|
||||
*/
|
||||
declare function marked(src: string, callback: ResultCallback): void;
|
||||
/**
|
||||
* Compiles markdown to HTML asynchronously with a callback.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Hash of options
|
||||
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
|
||||
*/
|
||||
declare function marked(src: string, options: MarkedOptions, callback: ResultCallback): void;
|
||||
declare namespace marked {
|
||||
var options: (options: MarkedOptions) => typeof marked;
|
||||
var setOptions: (options: MarkedOptions) => typeof marked;
|
||||
var getDefaults: typeof _getDefaults;
|
||||
var defaults: MarkedOptions;
|
||||
var use: (...args: MarkedExtension[]) => typeof marked;
|
||||
var walkTokens: <T = void>(tokens: TokensList | Token[], callback: (token: Token) => T | T[]) => T[];
|
||||
var parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback$1 | null | undefined, callback?: ResultCallback$1 | undefined) => string | Promise<string | undefined> | undefined;
|
||||
var Parser: typeof _Parser;
|
||||
var parser: typeof _Parser.parse;
|
||||
var Renderer: typeof _Renderer;
|
||||
var TextRenderer: typeof _TextRenderer;
|
||||
var Lexer: typeof _Lexer;
|
||||
var lexer: typeof _Lexer.lex;
|
||||
var Tokenizer: typeof _Tokenizer;
|
||||
var Slugger: typeof _Slugger;
|
||||
var Hooks: typeof _Hooks;
|
||||
var parse: typeof marked;
|
||||
}
|
||||
declare const options: (options: MarkedOptions) => typeof marked;
|
||||
declare const setOptions: (options: MarkedOptions) => typeof marked;
|
||||
declare const use: (...args: MarkedExtension[]) => typeof marked;
|
||||
declare const walkTokens: <T = void>(tokens: Token[] | TokensList, callback: (token: Token) => T | T[]) => T[];
|
||||
declare const parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback$1 | null | undefined, callback?: ResultCallback$1 | undefined) => string | Promise<string | undefined> | undefined;
|
||||
declare const parse: typeof marked;
|
||||
declare const parser: typeof _Parser.parse;
|
||||
declare const lexer: typeof _Lexer.lex;
|
||||
|
||||
export { _Hooks as Hooks, _Lexer as Lexer, Links, Marked, MarkedExtension, MarkedOptions, _Parser as Parser, _Renderer as Renderer, RendererExtension, RendererThis, ResultCallback, Rule, Rules, _Slugger as Slugger, SluggerOptions, _TextRenderer as TextRenderer, Token, _Tokenizer as Tokenizer, TokenizerAndRendererExtension, TokenizerExtension, TokenizerThis, Tokens, TokensList, block, _defaults as defaults, _getDefaults as getDefaults, inline, lexer, marked, options, parse, parseInline, parser, setOptions, use, walkTokens };
|
||||
|
1544
lib/marked.esm.js
generated
1544
lib/marked.esm.js
generated
File diff suppressed because it is too large
Load Diff
2
lib/marked.esm.js.map
generated
2
lib/marked.esm.js.map
generated
File diff suppressed because one or more lines are too long
1595
lib/marked.umd.js
generated
1595
lib/marked.umd.js
generated
File diff suppressed because it is too large
Load Diff
2
lib/marked.umd.js.map
generated
2
lib/marked.umd.js.map
generated
File diff suppressed because one or more lines are too long
4
marked.min.js
generated
vendored
4
marked.min.js
generated
vendored
File diff suppressed because one or more lines are too long
10430
package-lock.json
generated
10430
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@ -46,6 +46,7 @@
|
||||
],
|
||||
"devDependencies": {
|
||||
"@markedjs/html-differ": "^4.0.2",
|
||||
"@rollup/plugin-typescript": "^11.1.2",
|
||||
"@semantic-release/commit-analyzer": "^10.0.1",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@semantic-release/github": "^9.0.4",
|
||||
@ -67,31 +68,32 @@
|
||||
"markdown-it": "13.0.1",
|
||||
"node-fetch": "^3.3.2",
|
||||
"recheck": "^4.4.5",
|
||||
"rollup": "^3.27.0",
|
||||
"semantic-release": "^21.0.7",
|
||||
"titleize": "^3.0.0",
|
||||
"ts-expect": "^1.3.0",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsup": "^7.1.0",
|
||||
"typescript": "5.1.6",
|
||||
"uglify-js": "^3.17.4",
|
||||
"vuln-regex-detector": "^1.3.0"
|
||||
"uglify-js": "^3.17.4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "cross-env NODE_OPTIONS=--loader=ts-node/esm jasmine --config=jasmine.json",
|
||||
"test:all": "npm test && npm run test:lint",
|
||||
"test:all": "npm test && npm run test:umd && npm run test:types && npm run test:lint",
|
||||
"test:unit": "npm test -- test/unit/**/*-spec.js",
|
||||
"test:specs": "npm test -- test/specs/**/*-spec.js",
|
||||
"test:lint": "eslint .",
|
||||
"test:redos": "node test/recheck.js > vuln.js",
|
||||
"test:types": "tsc --project tsconfig-type-test.json",
|
||||
"test:umd": "node test/umd-test.js",
|
||||
"test:update": "node test/update-specs.js",
|
||||
"rules": "node test/rules.js",
|
||||
"bench": "npm run build && node test/bench.js",
|
||||
"lint": "eslint --fix .",
|
||||
"type-check": "tsc",
|
||||
"build:reset": "git checkout upstream/master lib/marked.cjs lib/marked.umd.js lib/marked.esm.js marked.min.js",
|
||||
"build": "npm run type-check && tsup && npm run build:verify && npm run minify",
|
||||
"build": "npm run rollup && npm run minify",
|
||||
"build:docs": "node build-docs.js",
|
||||
"build:verify": "tsc --project tsconfig-type-test.json",
|
||||
"build:types": "tsc --project tsconfig-types.json",
|
||||
"rollup": "rollup -c rollup.config.js",
|
||||
"minify": "uglifyjs lib/marked.umd.js -cm --comments /Copyright/ -o marked.min.js"
|
||||
},
|
||||
"engines": {
|
||||
|
49
rollup.config.js
Normal file
49
rollup.config.js
Normal file
@ -0,0 +1,49 @@
|
||||
import typescript from '@rollup/plugin-typescript';
|
||||
import { defineConfig } from 'rollup';
|
||||
import fs from 'fs';
|
||||
|
||||
const pkg = JSON.parse(fs.readFileSync('./package.json'));
|
||||
const version = process.env.SEMANTIC_RELEASE_NEXT_VERSION || pkg.version;
|
||||
|
||||
console.log('building version:', version);
|
||||
|
||||
const banner = `/**
|
||||
* marked v${version} - a markdown parser
|
||||
* Copyright (c) 2011-${new Date().getFullYear()}, Christopher Jeffrey. (MIT Licensed)
|
||||
* https://github.com/markedjs/marked
|
||||
*/
|
||||
|
||||
/**
|
||||
* DO NOT EDIT THIS FILE
|
||||
* The code in this file is generated from files in ./src/
|
||||
*/
|
||||
`;
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
input: 'src/marked.ts',
|
||||
output: [{
|
||||
file: 'lib/marked.esm.js',
|
||||
format: 'esm',
|
||||
sourcemap: true,
|
||||
banner
|
||||
},
|
||||
{
|
||||
file: 'lib/marked.umd.js',
|
||||
format: 'umd',
|
||||
name: 'marked',
|
||||
sourcemap: true,
|
||||
banner
|
||||
},
|
||||
{
|
||||
file: 'lib/marked.cjs',
|
||||
format: 'cjs',
|
||||
name: 'marked',
|
||||
sourcemap: true,
|
||||
banner
|
||||
}],
|
||||
plugins: [
|
||||
typescript()
|
||||
]
|
||||
}
|
||||
]);
|
@ -1,5 +1,5 @@
|
||||
import type { MarkedOptions } from './MarkedOptions.ts';
|
||||
import type { ResultCallback } from './marked.ts';
|
||||
import type { ResultCallback } from './Instance.ts';
|
||||
import type { Rule } from './rules.ts';
|
||||
|
||||
/**
|
||||
|
@ -13,8 +13,7 @@ import {
|
||||
} from './defaults.ts';
|
||||
import type { MarkedExtension, MarkedOptions } from './MarkedOptions.ts';
|
||||
import type { Token, TokensList } from './Tokens.ts';
|
||||
|
||||
export type ResultCallback = (error: Error | null, parseResult?: string) => undefined | void;
|
||||
import type { ResultCallback } from './Instance.ts';
|
||||
|
||||
const markedInstance = new Marked();
|
||||
|
||||
|
6
test/umd-test.js
vendored
Normal file
6
test/umd-test.js
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
import '../lib/marked.umd.js';
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
if (!marked.parse('# test').includes('<h1')) {
|
||||
throw new Error('Invalid markdown');
|
||||
}
|
17
tsconfig-types.json
Normal file
17
tsconfig-types.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2022",
|
||||
"module": "NodeNext",
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"moduleResolution": "NodeNext",
|
||||
"noImplicitAny": false,
|
||||
"allowImportingTsExtensions": true,
|
||||
"outFile": "lib/marked.d.ts"
|
||||
},
|
||||
"include": [
|
||||
"src/*.ts"
|
||||
]
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2021",
|
||||
"target": "es2022",
|
||||
"module": "NodeNext",
|
||||
"isolatedModules": true,
|
||||
"strict": true,
|
||||
|
@ -1,47 +0,0 @@
|
||||
import { defineConfig } from 'tsup';
|
||||
import fs from 'fs';
|
||||
|
||||
const pkg = JSON.parse(String(fs.readFileSync('./package.json')));
|
||||
const version = process.env.SEMANTIC_RELEASE_NEXT_VERSION || pkg.version;
|
||||
|
||||
console.log('building version:', version);
|
||||
|
||||
const banner = `/**
|
||||
* marked v${version} - a markdown parser
|
||||
* Copyright (c) 2011-${new Date().getFullYear()}, Christopher Jeffrey. (MIT Licensed)
|
||||
* https://github.com/markedjs/marked
|
||||
*/
|
||||
|
||||
/**
|
||||
* DO NOT EDIT THIS FILE
|
||||
* The code in this file is generated from files in ./src/
|
||||
*/
|
||||
`;
|
||||
|
||||
export default defineConfig({
|
||||
entry: ['src/marked.ts'],
|
||||
splitting: false,
|
||||
sourcemap: true,
|
||||
clean: true,
|
||||
format: ['cjs', 'esm', 'iife'],
|
||||
globalName: 'marked',
|
||||
banner: {
|
||||
js: banner
|
||||
},
|
||||
outDir: 'lib',
|
||||
outExtension({ format }) {
|
||||
if (format === 'cjs') {
|
||||
return {
|
||||
js: '.cjs'
|
||||
};
|
||||
} else if (format === 'iife') {
|
||||
return {
|
||||
js: '.umd.js'
|
||||
};
|
||||
}
|
||||
return {
|
||||
js: `.${format}.js`
|
||||
};
|
||||
},
|
||||
dts: true
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user