Merge pull request #34314 from htkzhtm/add-marked-type

[marked] Add InlineLexer Type
This commit is contained in:
Benjamin Lichtman 2019-04-01 12:23:37 -07:00 committed by GitHub
commit effa252dd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -77,6 +77,17 @@ declare namespace marked {
*/
function setOptions(options: MarkedOptions): typeof marked;
class InlineLexer {
constructor(links: string[], options?: MarkedOptions);
static rules: Rules;
static output(src: string, links: string[], options?: MarkedOptions): string;
output(src: string): string;
static escapes(text: string): string;
outputLink(cap: string[], link: string): string;
smartypants(text: string): string;
mangle(text: string): string;
}
class Renderer {
constructor(options?: MarkedOptions);
code(code: string, language: string, isEscaped: boolean): string;

View File

@ -56,3 +56,9 @@ const parseTestText = "- list1\n - list1.1\n\n listend";
const parseTestTokens: marked.TokensList = marked.lexer(parseTestText, options);
const parser = new marked.Parser();
console.log(parser.parse(parseTestTokens));
const links = ['http', 'image'];
const inlineLexer = new marked.InlineLexer(links);
console.log(inlineLexer.output("http://"));
console.log(marked.InlineLexer.output("http://", links));
console.log(marked.InlineLexer.rules);