Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add title attribute to anchor tags
Sebastian Martinez committed 2 years ago
commit 0918d38be9e07ae204d02e9853a6bff2b8706994
parent 67eef6caa7181f74cb5facca483dfc6cd9240590
1 file changed +3 -3
modified src/lib/markdown.ts
@@ -135,16 +135,16 @@ export class Renderer extends BaseRenderer {
    return this.#stripEmphasizedStyling ? text : `<em>${text}</em>`;
  }

-
  link(href: string, _title: string, text: string): string {
+
  link(href: string, title: string | undefined | null, text: string): string {
    if (href.startsWith("#")) {
      // By lowercasing we avoid casing mismatches, between headings and links.
-
      return `<a href="${href.toLowerCase()}">${text}</a>`;
+
      return `<a ${title ? `title="${title}"` : ""} href="${href.toLowerCase()}">${text}</a>`;
    } else {
      href = URL.canParse(href, this.#baseUrl)
        ? new URL(href, this.#baseUrl).href
        : href;

-
      return `<a href="${href}">${text}</a>`;
+
      return `<a ${title ? `title="${title}"` : ""} href="${href}">${text}</a>`;
    }
  }
}