From 89ced4a2e6fbb616f06a87766259a038012b3264 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Fri, 13 Oct 2023 10:36:37 +0200 Subject: [PATCH] chore: update dependencies (#81) --- deps.ts | 6 ++++-- mod.ts | 10 +++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/deps.ts b/deps.ts index bbd4186..28b369c 100644 --- a/deps.ts +++ b/deps.ts @@ -7,9 +7,11 @@ export { emojify } from "https://deno.land/x/emoji@0.3.0/mod.ts"; -export * as Marked from "https://esm.sh/marked@5.1.0/"; +export * as Marked from "https://esm.sh/marked@9.1.1/"; -export { gfmHeadingId } from "https://esm.sh/marked-gfm-heading-id@3.0.4/"; +export { default as GitHubSlugger } from "https://esm.sh/github-slugger@2.0.0/"; + +export { gfmHeadingId } from "https://esm.sh/marked-gfm-heading-id@3.1.0/"; export { default as Prism } from "https://esm.sh/prismjs@1.29.0"; diff --git a/mod.ts b/mod.ts index 7b8fbe3..141cf84 100644 --- a/mod.ts +++ b/mod.ts @@ -1,6 +1,7 @@ import { emojify, gfmHeadingId, + GitHubSlugger, htmlEscape, katex, Marked, @@ -12,11 +13,15 @@ export { CSS, KATEX_CSS, Marked }; Marked.marked.use(gfmHeadingId()); +const slugger = new GitHubSlugger(); + export class Renderer extends Marked.Renderer { allowMath: boolean; + baseUrl: string | undefined; constructor(options: Marked.marked.MarkedOptions & RenderOptions = {}) { super(options); + this.baseUrl = options.baseUrl; this.allowMath = options.allowMath ?? false; } @@ -24,7 +29,6 @@ export class Renderer extends Marked.Renderer { text: string, level: 1 | 2 | 3 | 4 | 5 | 6, raw: string, - slugger: Marked.Slugger, ): string { const slug = slugger.slug(raw); return `${text}`; @@ -59,9 +63,9 @@ export class Renderer extends Marked.Renderer { if (href.startsWith("#")) { return `${text}`; } - if (this.options.baseUrl) { + if (this.baseUrl) { try { - href = new URL(href, this.options.baseUrl).href; + href = new URL(href, this.baseUrl).href; } catch (_) { // }