mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 02:00:31 +08:00
Add title attribute to anchor tags
This commit is contained in:
+3
-3
@@ -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>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user