mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
Reworked markdown-it
This commit is contained in:
Vendored
+3
-1
@@ -4,7 +4,9 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { MarkdownIt, Core, Token } from 'markdown-it';
|
||||
import * as MarkdownIt from 'markdown-it';
|
||||
import * as Core from 'markdown-it/lib/parser_core';
|
||||
import * as Token from 'markdown-it/lib/token';
|
||||
|
||||
declare namespace anchor {
|
||||
interface AnchorInfo {
|
||||
|
||||
+3
-1
@@ -4,7 +4,9 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { MarkdownIt, Token, Renderer } from 'markdown-it';
|
||||
import * as MarkdownIt from 'markdown-it';
|
||||
import * as Renderer from 'markdown-it/lib/renderer';
|
||||
import * as Token from 'markdown-it/lib/token';
|
||||
|
||||
declare namespace markdownItContainer {
|
||||
interface ContainerOpts {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import * as MarkdownIt from "markdown-it";
|
||||
import * as Token from "markdown-it/lib/token";
|
||||
|
||||
import MarkdownItContainer = require("markdown-it-container");
|
||||
|
||||
const md = new MarkdownIt();
|
||||
|
||||
md.use(MarkdownItContainer, 'spoiler', {
|
||||
validate: (params: any) => params.trim().match(/^spoiler\s+(.*)$/),
|
||||
render: (tokens: MarkdownIt.Token[], index: number) => {
|
||||
render: (tokens: Token[], index: number) => {
|
||||
const match = tokens[index].info.trim().match(/^spoiler\s+(.*)$/);
|
||||
const onClick =
|
||||
"this.parentNode.classList.toggle('_expanded');" +
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { MarkdownIt } from 'markdown-it';
|
||||
import * as MarkdownIt from 'markdown-it';
|
||||
|
||||
declare function lazyheaders(md: MarkdownIt): void;
|
||||
|
||||
|
||||
Vendored
+1
-231
@@ -4,235 +4,5 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
interface MarkdownItStatic {
|
||||
new (): MarkdownIt.MarkdownIt;
|
||||
new (presetName: "commonmark" | "zero" | "default", options?: MarkdownIt.Options): MarkdownIt.MarkdownIt;
|
||||
new (options: MarkdownIt.Options): MarkdownIt.MarkdownIt;
|
||||
(): MarkdownIt.MarkdownIt;
|
||||
(presetName: "commonmark" | "zero" | "default", options ?: MarkdownIt.Options): MarkdownIt.MarkdownIt;
|
||||
(options: MarkdownIt.Options): MarkdownIt.MarkdownIt;
|
||||
}
|
||||
|
||||
declare var MarkdownIt: MarkdownItStatic;
|
||||
import * as MarkdownIt from "./lib";
|
||||
export = MarkdownIt;
|
||||
export as namespace markdownit;
|
||||
|
||||
declare module MarkdownIt {
|
||||
interface MarkdownIt {
|
||||
render(md: string, env?: any): string;
|
||||
renderInline(md: string, env?: any): string;
|
||||
parse(src: string, env: any): Token[];
|
||||
parseInline(src: string, env: any): Token[];
|
||||
|
||||
/*
|
||||
// The following only works in 3.0
|
||||
// Since it's still not allowed to target 3.0, i'll leave the code commented out
|
||||
|
||||
use<T extends Array<any> = any[]>(
|
||||
plugin: (md: MarkdownIt, ...params: T) => void,
|
||||
...params: T
|
||||
): MarkdownIt;
|
||||
*/
|
||||
|
||||
use(plugin: (md: MarkdownIt, ...params: any[]) => void, ...params: any[]): MarkdownIt;
|
||||
|
||||
utils: {
|
||||
assign(obj: any): any;
|
||||
isString(obj: any): boolean;
|
||||
has(object: any, key: string): boolean;
|
||||
unescapeMd(str: string): string;
|
||||
unescapeAll(str: string): string;
|
||||
isValidEntityCode(str: any): boolean;
|
||||
fromCodePoint(str: string): string;
|
||||
escapeHtml(str: string): string;
|
||||
arrayReplaceAt(src: any[], pos: number, newElements: any[]): any[]
|
||||
isSpace(str: any): boolean;
|
||||
isWhiteSpace(str: any): boolean
|
||||
isMdAsciiPunct(str: any): boolean;
|
||||
isPunctChar(str: any): boolean;
|
||||
escapeRE(str: string): string;
|
||||
normalizeReference(str: string): string;
|
||||
}
|
||||
|
||||
disable(rules: string[] | string, ignoreInvalid?: boolean): MarkdownIt;
|
||||
enable(rules: string[] | string, ignoreInvalid?: boolean): MarkdownIt;
|
||||
set(options: Options): MarkdownIt;
|
||||
normalizeLink(url: string): string;
|
||||
normalizeLinkText(url: string): string;
|
||||
validateLink(url: string): boolean;
|
||||
block: ParserBlock;
|
||||
core: Core;
|
||||
helpers: any;
|
||||
inline: ParserInline;
|
||||
linkify: LinkifyIt;
|
||||
renderer: Renderer;
|
||||
}
|
||||
interface Options {
|
||||
html?: boolean;
|
||||
xhtmlOut?: boolean;
|
||||
breaks?: boolean;
|
||||
langPrefix?: string;
|
||||
linkify?: boolean;
|
||||
typographer?: boolean;
|
||||
quotes?: string;
|
||||
highlight?: (str: string, lang: string) => void;
|
||||
}
|
||||
interface LinkifyIt {
|
||||
tlds(lang: string, linkified: boolean): void;
|
||||
}
|
||||
interface Renderer {
|
||||
rules: { [name: string]: TokenRender };
|
||||
render(tokens: Token[], options: any, env: any): string;
|
||||
renderAttrs(token: Token): string;
|
||||
renderInline(tokens: Token[], options: any, env: any): string;
|
||||
renderToken(tokens: Token[], idx: number, options: any): string;
|
||||
}
|
||||
interface Token {
|
||||
new (type: string, tag: string, nesting: number): Token;
|
||||
attrGet: (name: string) => string | null;
|
||||
attrIndex: (name: string) => number;
|
||||
attrJoin: (name: string, value: string) => void;
|
||||
attrPush: (attrData: string[]) => void;
|
||||
attrSet: (name: string, value: string) => void;
|
||||
attrs: string[][];
|
||||
block: boolean;
|
||||
children: Token[];
|
||||
content: string;
|
||||
hidden: boolean;
|
||||
info: string;
|
||||
level: number;
|
||||
map: number[];
|
||||
markup: string;
|
||||
meta: any;
|
||||
nesting: number;
|
||||
tag: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
type TokenRender = (tokens: Token[], index: number, options: any, env: any, self: Renderer) => void;
|
||||
|
||||
interface Rule<S extends State = State> {
|
||||
(state: S, silent?: boolean): boolean | void;
|
||||
}
|
||||
|
||||
interface RuleInline extends Rule<StateInline> {}
|
||||
interface RuleBlock extends Rule<StateBlock> {}
|
||||
|
||||
interface Ruler<S extends State = State> {
|
||||
after(afterName: string, ruleName: string, rule: Rule<S>, options?: any): void;
|
||||
at(name: string, rule: Rule<S>, options?: any): void;
|
||||
before(beforeName: string, ruleName: string, rule: Rule<S>, options?: any): void;
|
||||
disable(rules: string | string[], ignoreInvalid?: boolean): string[];
|
||||
enable(rules: string | string[], ignoreInvalid?: boolean): string[];
|
||||
enableOnly(rule: string, ignoreInvalid?: boolean): void;
|
||||
getRules(chain: string): Rule<S>[];
|
||||
push(ruleName: string, rule: Rule<S>, options?: any): void;
|
||||
}
|
||||
|
||||
interface RulerInline extends Ruler<StateInline> {}
|
||||
interface RulerBlock extends Ruler<StateBlock> {}
|
||||
|
||||
interface ParserBlock {
|
||||
parse(src: string, md: MarkdownIt, env: any, outTokens: Token[]): void;
|
||||
ruler: RulerBlock;
|
||||
}
|
||||
|
||||
interface Core {
|
||||
process(state: any): void;
|
||||
ruler: Ruler;
|
||||
}
|
||||
|
||||
interface ParserInline {
|
||||
parse(src: string, md: MarkdownIt, env: any, outTokens: Token[]): void;
|
||||
tokenize(state: State): void;
|
||||
skipToken(state: State): void;
|
||||
ruler: RulerInline;
|
||||
ruler2: RulerInline;
|
||||
}
|
||||
|
||||
interface Delimiter {
|
||||
close: boolean;
|
||||
end: number;
|
||||
jump: number;
|
||||
length: number;
|
||||
level: number;
|
||||
marker: number;
|
||||
open: boolean;
|
||||
token: number;
|
||||
}
|
||||
|
||||
interface State {
|
||||
env: any;
|
||||
level: number;
|
||||
|
||||
/** Link to parser instance */
|
||||
md: MarkdownIt;
|
||||
|
||||
/** The markdown source code that is being parsed. */
|
||||
src: string;
|
||||
|
||||
tokens: Token[];
|
||||
|
||||
/** Return any for a yet untyped property */
|
||||
[undocumented: string]: any;
|
||||
}
|
||||
|
||||
interface StateInline extends State {
|
||||
/**
|
||||
* Stores `{ start: end }` pairs. Useful for backtrack
|
||||
* optimization of pairs parse (emphasis, strikes).
|
||||
*/
|
||||
cache: { [start: number]: number };
|
||||
|
||||
/** Emphasis-like delimiters */
|
||||
delimiters: Delimiter[];
|
||||
|
||||
pending: string;
|
||||
pendingLevel: number;
|
||||
|
||||
/** Index of the first character of this token. */
|
||||
pos: number;
|
||||
|
||||
/** Index of the last character that can be used (for example the one before the end of this line). */
|
||||
posMax: number;
|
||||
|
||||
/**
|
||||
* Push new token to "stream".
|
||||
* If pending text exists, flush it as text token.
|
||||
*/
|
||||
push(type: string, tag: string, nesting: number): Token;
|
||||
|
||||
/** Flush pending text */
|
||||
pushPending(): Token;
|
||||
|
||||
/**
|
||||
* Scan a sequence of emphasis-like markers and determine whether
|
||||
* it can start an emphasis sequence or end an emphasis sequence.
|
||||
* @param start - position to scan from (it should point to a valid marker)
|
||||
* @param canSplitWord - determine if these markers can be found inside a word
|
||||
*/
|
||||
scanDelims(start: number, canSplitWord: boolean): {
|
||||
can_open: boolean,
|
||||
can_close: boolean,
|
||||
length: number
|
||||
};
|
||||
}
|
||||
|
||||
interface StateBlock extends State {
|
||||
/** Used in lists to determine if they interrupt a paragraph */
|
||||
parentType: 'blockquote' | 'list' | 'root' | 'paragraph' | 'reference';
|
||||
|
||||
eMarks: number[];
|
||||
bMarks: number[];
|
||||
bsCount: number[];
|
||||
sCount: number[];
|
||||
tShift: number[];
|
||||
|
||||
blkIndent: number;
|
||||
ddIndent: number;
|
||||
|
||||
line: number;
|
||||
lineMax: number;
|
||||
tight: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+113
@@ -0,0 +1,113 @@
|
||||
import { LinkifyIt } from 'linkify-it'
|
||||
|
||||
import * as State from './rules_core/state_core';
|
||||
import * as StateBlock from './rules_block/state_block';
|
||||
import * as StateInline from './rules_inline/state_inline';
|
||||
|
||||
import * as Core from './parser_core';
|
||||
import * as ParserBlock from './parser_block';
|
||||
import * as ParserInline from './parser_inline';
|
||||
|
||||
import * as Renderer from './renderer';
|
||||
import * as Ruler from './ruler';
|
||||
import * as Token from './token';
|
||||
|
||||
export = MarkdownIt;
|
||||
export as namespace markdownit;
|
||||
|
||||
declare const MarkdownIt: MarkdownItConstructor;
|
||||
|
||||
interface MarkdownItConstructor {
|
||||
new (): MarkdownIt;
|
||||
new (presetName: "commonmark" | "zero" | "default", options?: MarkdownIt.Options): MarkdownIt;
|
||||
new (options: MarkdownIt.Options): MarkdownIt;
|
||||
(): MarkdownIt;
|
||||
(presetName: "commonmark" | "zero" | "default", options ?: MarkdownIt.Options): MarkdownIt;
|
||||
(options: MarkdownIt.Options): MarkdownIt;
|
||||
}
|
||||
|
||||
interface MarkdownIt {
|
||||
render(md: string, env?: any): string;
|
||||
renderInline(md: string, env?: any): string;
|
||||
parse(src: string, env: any): Token[];
|
||||
parseInline(src: string, env: any): Token[];
|
||||
|
||||
/*
|
||||
// The following only works in 3.0
|
||||
// Since it's still not allowed to target 3.0, i'll leave the code commented out
|
||||
|
||||
use<T extends Array<any> = any[]>(
|
||||
plugin: (md: MarkdownIt, ...params: T) => void,
|
||||
...params: T
|
||||
): MarkdownIt;
|
||||
*/
|
||||
|
||||
use(plugin: (md: MarkdownIt, ...params: any[]) => void, ...params: any[]): MarkdownIt;
|
||||
|
||||
utils: {
|
||||
assign(obj: any): any;
|
||||
isString(obj: any): boolean;
|
||||
has(object: any, key: string): boolean;
|
||||
unescapeMd(str: string): string;
|
||||
unescapeAll(str: string): string;
|
||||
isValidEntityCode(str: any): boolean;
|
||||
fromCodePoint(str: string): string;
|
||||
escapeHtml(str: string): string;
|
||||
arrayReplaceAt(src: any[], pos: number, newElements: any[]): any[]
|
||||
isSpace(str: any): boolean;
|
||||
isWhiteSpace(str: any): boolean
|
||||
isMdAsciiPunct(str: any): boolean;
|
||||
isPunctChar(str: any): boolean;
|
||||
escapeRE(str: string): string;
|
||||
normalizeReference(str: string): string;
|
||||
}
|
||||
|
||||
disable(rules: string[] | string, ignoreInvalid?: boolean): MarkdownIt;
|
||||
enable(rules: string[] | string, ignoreInvalid?: boolean): MarkdownIt;
|
||||
set(options: MarkdownIt.Options): MarkdownIt;
|
||||
normalizeLink(url: string): string;
|
||||
normalizeLinkText(url: string): string;
|
||||
validateLink(url: string): boolean;
|
||||
block: ParserBlock;
|
||||
core: Core;
|
||||
helpers: any;
|
||||
inline: ParserInline;
|
||||
linkify: LinkifyIt;
|
||||
renderer: Renderer;
|
||||
}
|
||||
|
||||
declare module MarkdownIt {
|
||||
interface Options {
|
||||
html?: boolean;
|
||||
xhtmlOut?: boolean;
|
||||
breaks?: boolean;
|
||||
langPrefix?: string;
|
||||
linkify?: boolean;
|
||||
typographer?: boolean;
|
||||
quotes?: string;
|
||||
highlight?: (str: string, lang: string) => void;
|
||||
}
|
||||
|
||||
interface Rule<S extends State = State> {
|
||||
(state: S, silent?: boolean): boolean | void;
|
||||
}
|
||||
|
||||
interface RuleInline extends Rule<StateInline> {}
|
||||
interface RuleBlock extends Rule<StateBlock> {}
|
||||
|
||||
interface RulerInline extends Ruler<StateInline> {}
|
||||
interface RulerBlock extends Ruler<StateBlock> {}
|
||||
|
||||
type TokenRender = (tokens: Token[], index: number, options: any, env: any, self: Renderer) => void;
|
||||
|
||||
interface Delimiter {
|
||||
close: boolean;
|
||||
end: number;
|
||||
jump: number;
|
||||
length: number;
|
||||
level: number;
|
||||
marker: number;
|
||||
open: boolean;
|
||||
token: number;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import * as MarkdownIt from ".";
|
||||
import * as Token from "./token";
|
||||
|
||||
export = ParserBlock;
|
||||
|
||||
declare class ParserBlock {
|
||||
parse(src: string, md: MarkdownIt, env: any, outTokens: Token[]): void;
|
||||
ruler: MarkdownIt.RulerBlock;
|
||||
}
|
||||
|
||||
declare module ParserBlock {}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import * as MarkdownIt from ".";
|
||||
import * as Ruler from "./ruler";
|
||||
import * as Token from "./token";
|
||||
|
||||
export = ParserCore;
|
||||
|
||||
declare class ParserCore {
|
||||
process(state: any): void;
|
||||
ruler: Ruler;
|
||||
}
|
||||
|
||||
declare module ParserCore {}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import * as MarkdownIt from ".";
|
||||
import * as State from "./rules_core/state_core";
|
||||
import * as Token from "./token";
|
||||
|
||||
export = ParserInline;
|
||||
|
||||
declare class ParserInline {
|
||||
parse(src: string, md: MarkdownIt, env: any, outTokens: Token[]): void;
|
||||
tokenize(state: State): void;
|
||||
skipToken(state: State): void;
|
||||
ruler: MarkdownIt.RulerInline;
|
||||
ruler2: MarkdownIt.RulerInline;
|
||||
}
|
||||
|
||||
declare module ParserInline {}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
import * as MarkdownIt from ".";
|
||||
import * as Token from "./token";
|
||||
|
||||
export = Renderer;
|
||||
|
||||
declare class Renderer {
|
||||
rules: { [name: string]: MarkdownIt.TokenRender };
|
||||
render(tokens: Token[], options: any, env: any): string;
|
||||
renderAttrs(token: Token): string;
|
||||
renderInline(tokens: Token[], options: any, env: any): string;
|
||||
renderToken(tokens: Token[], idx: number, options: any): string;
|
||||
}
|
||||
|
||||
declare module Renderer {}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
import * as MarkdownIt from ".";
|
||||
import * as State from "./rules_core/state_core";
|
||||
|
||||
export = Ruler;
|
||||
|
||||
declare class Ruler<S extends State = State> {
|
||||
after(afterName: string, ruleName: string, rule: MarkdownIt.Rule<S>, options?: any): void;
|
||||
at(name: string, rule: MarkdownIt.Rule<S>, options?: any): void;
|
||||
before(beforeName: string, ruleName: string, rule: MarkdownIt.Rule<S>, options?: any): void;
|
||||
disable(rules: string | string[], ignoreInvalid?: boolean): string[];
|
||||
enable(rules: string | string[], ignoreInvalid?: boolean): string[];
|
||||
enableOnly(rule: string, ignoreInvalid?: boolean): void;
|
||||
getRules(chain: string): MarkdownIt.Rule<S>[];
|
||||
push(ruleName: string, rule: MarkdownIt.Rule<S>, options?: any): void;
|
||||
}
|
||||
|
||||
declare module Ruler {}
|
||||
@@ -0,0 +1,25 @@
|
||||
import * as MarkdownIt from "..";
|
||||
import * as State from "../rules_core/state_core";
|
||||
import * as Token from "../token";
|
||||
|
||||
export = StateBlock;
|
||||
|
||||
declare class StateBlock extends State {
|
||||
/** Used in lists to determine if they interrupt a paragraph */
|
||||
parentType: 'blockquote' | 'list' | 'root' | 'paragraph' | 'reference';
|
||||
|
||||
eMarks: number[];
|
||||
bMarks: number[];
|
||||
bsCount: number[];
|
||||
sCount: number[];
|
||||
tShift: number[];
|
||||
|
||||
blkIndent: number;
|
||||
ddIndent: number;
|
||||
|
||||
line: number;
|
||||
lineMax: number;
|
||||
tight: boolean;
|
||||
}
|
||||
|
||||
declare module StateBlock {}
|
||||
@@ -0,0 +1,22 @@
|
||||
import * as MarkdownIt from "..";
|
||||
import * as Token from "../token";
|
||||
|
||||
export = StateCore;
|
||||
|
||||
declare class StateCore {
|
||||
env: any;
|
||||
level: number;
|
||||
|
||||
/** Link to parser instance */
|
||||
md: MarkdownIt;
|
||||
|
||||
/** The markdown source code that is being parsed. */
|
||||
src: string;
|
||||
|
||||
tokens: Token[];
|
||||
|
||||
/** Return any for a yet untyped property */
|
||||
[undocumented: string]: any;
|
||||
}
|
||||
|
||||
declare module StateCore {}
|
||||
@@ -0,0 +1,48 @@
|
||||
import * as MarkdownIt from "..";
|
||||
import * as State from "../rules_core/state_core";
|
||||
import * as Token from "../token";
|
||||
|
||||
export = StateInline;
|
||||
|
||||
declare class StateInline extends State {
|
||||
/**
|
||||
* Stores `{ start: end }` pairs. Useful for backtrack
|
||||
* optimization of pairs parse (emphasis, strikes).
|
||||
*/
|
||||
cache: { [start: number]: number };
|
||||
|
||||
/** Emphasis-like delimiters */
|
||||
delimiters: MarkdownIt.Delimiter[];
|
||||
|
||||
pending: string;
|
||||
pendingLevel: number;
|
||||
|
||||
/** Index of the first character of this token. */
|
||||
pos: number;
|
||||
|
||||
/** Index of the last character that can be used (for example the one before the end of this line). */
|
||||
posMax: number;
|
||||
|
||||
/**
|
||||
* Push new token to "stream".
|
||||
* If pending text exists, flush it as text token.
|
||||
*/
|
||||
push(type: string, tag: string, nesting: number): Token;
|
||||
|
||||
/** Flush pending text */
|
||||
pushPending(): Token;
|
||||
|
||||
/**
|
||||
* Scan a sequence of emphasis-like markers and determine whether
|
||||
* it can start an emphasis sequence or end an emphasis sequence.
|
||||
* @param start - position to scan from (it should point to a valid marker)
|
||||
* @param canSplitWord - determine if these markers can be found inside a word
|
||||
*/
|
||||
scanDelims(start: number, canSplitWord: boolean): {
|
||||
can_open: boolean,
|
||||
can_close: boolean,
|
||||
length: number
|
||||
};
|
||||
}
|
||||
|
||||
declare module StateInline {}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
export = Token;
|
||||
|
||||
declare class Token {
|
||||
constructor(type: string, tag: string, nesting: number);
|
||||
attrGet: (name: string) => string | null;
|
||||
attrIndex: (name: string) => number;
|
||||
attrJoin: (name: string, value: string) => void;
|
||||
attrPush: (attrData: string[]) => void;
|
||||
attrSet: (name: string, value: string) => void;
|
||||
attrs: string[][];
|
||||
block: boolean;
|
||||
children: Token[];
|
||||
content: string;
|
||||
hidden: boolean;
|
||||
info: string;
|
||||
level: number;
|
||||
map: number[];
|
||||
markup: string;
|
||||
meta: any;
|
||||
nesting: number;
|
||||
tag: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
declare module Token {}
|
||||
@@ -1,4 +1,6 @@
|
||||
import * as MarkdownIt from "markdown-it";
|
||||
import * as Renderer from "markdown-it/lib/renderer";
|
||||
import * as Token from "markdown-it/lib/token";
|
||||
|
||||
{
|
||||
const md = new MarkdownIt();
|
||||
@@ -141,7 +143,7 @@ function myToken(tokens: any, idx: number, options: any, env: any, self: any) {
|
||||
return "";
|
||||
},
|
||||
});
|
||||
md.renderer.rules["image"] = (tokens: MarkdownIt.Token[], index: number, options: any, env: any, self: MarkdownIt.Renderer) => {
|
||||
md.renderer.rules["image"] = (tokens: Token[], index: number, options: any, env: any, self: Renderer) => {
|
||||
const token = tokens[index];
|
||||
const aIndex = token.attrIndex("src");
|
||||
token.attrs[aIndex][1];
|
||||
@@ -154,11 +156,11 @@ function myToken(tokens: any, idx: number, options: any, env: any, self: any) {
|
||||
if (md.renderer.rules["link_open"]) {
|
||||
defaultLinkRender = md.renderer.rules["link_open"];
|
||||
} else {
|
||||
defaultLinkRender = (tokens: MarkdownIt.Token[], index: number, options: any, env: any, self: MarkdownIt.Renderer) => {
|
||||
defaultLinkRender = (tokens: Token[], index: number, options: any, env: any, self: Renderer) => {
|
||||
return self.renderToken(tokens, index, options);
|
||||
};
|
||||
}
|
||||
md.renderer.rules["link_open"] = (tokens: MarkdownIt.Token[], index: number, options: any, env: any, self: MarkdownIt.Renderer) => {
|
||||
md.renderer.rules["link_open"] = (tokens: Token[], index: number, options: any, env: any, self: Renderer) => {
|
||||
tokens[index].attrPush(["target", "_blank"]);
|
||||
tokens[index].attrPush(["rel", "nofollow"]);
|
||||
return defaultLinkRender(tokens, index, options, env, self);
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { MarkdownIt } from 'markdown-it';
|
||||
import * as MarkdownIt from 'markdown-it';
|
||||
import { Node as ProsemirrorNode, Schema } from 'prosemirror-model';
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user