From b1a772cadb06967529b92476dda71044a220089b Mon Sep 17 00:00:00 2001 From: kumemoto Date: Fri, 29 Mar 2019 11:09:42 +0900 Subject: [PATCH 1/4] add InlineLexer class --- types/marked/index.d.ts | 10 ++++++++++ types/marked/marked-tests.ts | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/types/marked/index.d.ts b/types/marked/index.d.ts index 74dfec5317..f2bbadb6cb 100644 --- a/types/marked/index.d.ts +++ b/types/marked/index.d.ts @@ -77,6 +77,16 @@ declare namespace marked { */ function setOptions(options: MarkedOptions): typeof marked; + class InlineLexer { + constructor(links: string[] , options?: MarkedOptions); + rules: Rules; + output(src: string): string; + 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; diff --git a/types/marked/marked-tests.ts b/types/marked/marked-tests.ts index 2af775e397..4aae014b85 100644 --- a/types/marked/marked-tests.ts +++ b/types/marked/marked-tests.ts @@ -56,3 +56,8 @@ 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(inlineLexer.rules); From 2c3833e3742a99ddbc736e0397b8dd1365cba62d Mon Sep 17 00:00:00 2001 From: kumemoto Date: Fri, 29 Mar 2019 11:26:05 +0900 Subject: [PATCH 2/4] delete white space --- types/marked/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/marked/index.d.ts b/types/marked/index.d.ts index f2bbadb6cb..599e40922e 100644 --- a/types/marked/index.d.ts +++ b/types/marked/index.d.ts @@ -78,7 +78,7 @@ declare namespace marked { function setOptions(options: MarkedOptions): typeof marked; class InlineLexer { - constructor(links: string[] , options?: MarkedOptions); + constructor(links: string[], options?: MarkedOptions); rules: Rules; output(src: string): string; escapes(text: string): string; From 17f380ffdccbe47ed117195d9e93e2f6405d76bc Mon Sep 17 00:00:00 2001 From: kumemoto Date: Fri, 29 Mar 2019 17:19:14 +0900 Subject: [PATCH 3/4] fix static property --- types/marked/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/marked/index.d.ts b/types/marked/index.d.ts index 599e40922e..ad12e6d35e 100644 --- a/types/marked/index.d.ts +++ b/types/marked/index.d.ts @@ -79,9 +79,10 @@ declare namespace marked { class InlineLexer { constructor(links: string[], options?: MarkedOptions); - rules: Rules; + static rules: Rules; + static output(src: string, links: string[], options?: MarkedOptions): string; output(src: string): string; - escapes(text: string): string; + static escapes(text: string): string; outputLink(cap: string[], link: string): string; smartypants(text: string): string; mangle(text: string): string; From 60305bc5a64f8c627be77c927a4fbbc60ca55e89 Mon Sep 17 00:00:00 2001 From: kumemoto Date: Fri, 29 Mar 2019 17:19:35 +0900 Subject: [PATCH 4/4] fix test --- types/marked/marked-tests.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/marked/marked-tests.ts b/types/marked/marked-tests.ts index 4aae014b85..65cd72ee73 100644 --- a/types/marked/marked-tests.ts +++ b/types/marked/marked-tests.ts @@ -60,4 +60,5 @@ console.log(parser.parse(parseTestTokens)); const links = ['http', 'image']; const inlineLexer = new marked.InlineLexer(links); console.log(inlineLexer.output("http://")); -console.log(inlineLexer.rules); +console.log(marked.InlineLexer.output("http://", links)); +console.log(marked.InlineLexer.rules);