refactor: class-methods-use-this
This commit is contained in:
parent
a42add7131
commit
af57cb5d71
12 changed files with 48 additions and 45 deletions
|
@ -15,11 +15,20 @@ class MarkdownProcessor extends StringProcessor {
|
|||
super(DwengoContentType.TEXT_MARKDOWN);
|
||||
}
|
||||
|
||||
static replaceLinks(html: string): string {
|
||||
const proc = new InlineImageProcessor();
|
||||
html = html.replace(
|
||||
/<img.*?src="(.*?)".*?(alt="(.*?)")?.*?(title="(.*?)")?.*?>/g,
|
||||
(_match: string, src: string, _alt: string, _altText: string, _title: string, _titleText: string) => proc.render(src)
|
||||
);
|
||||
return html;
|
||||
}
|
||||
|
||||
override renderFn(mdText: string): string {
|
||||
try {
|
||||
marked.use({ renderer: dwengoMarkedRenderer });
|
||||
const html = marked(mdText, { async: false });
|
||||
return this.replaceLinks(html); // Replace html image links path
|
||||
return MarkdownProcessor.replaceLinks(html); // Replace html image links path
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof YAMLException) {
|
||||
throw new ProcessingError(e.message);
|
||||
|
@ -28,15 +37,6 @@ class MarkdownProcessor extends StringProcessor {
|
|||
throw new ProcessingError('Unknown error while processing markdown: ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
replaceLinks(html: string): string {
|
||||
const proc = new InlineImageProcessor();
|
||||
html = html.replace(
|
||||
/<img.*?src="(.*?)".*?(alt="(.*?)")?.*?(title="(.*?)")?.*?>/g,
|
||||
(_match: string, src: string, _alt: string, _altText: string, _title: string, _titleText: string) => proc.render(src)
|
||||
);
|
||||
return html;
|
||||
}
|
||||
}
|
||||
|
||||
export { MarkdownProcessor };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue