Skip to content

Commit f98c0b6

Browse files
committed
fix(core): correctly handle empty markdown links
1 parent 04e779e commit f98c0b6

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

.changeset/petite-onions-ring.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'typedoc-plugin-markdown': patch
3+
---
4+
5+
- Correctly handle empty markdown links (#836).
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
/**
2-
* The link element
2+
* The link element
33
* @param label The text to display for the link
4-
* @param url The url to link to
4+
* @param url The URL to link to
5+
* @returns A Markdown link if URL is provided, otherwise plain text
56
*/
6-
export function link(label: string, url: string | null) {
7-
return `[${label.trim()}](${url || ''})`;
7+
export function link(label: string, url?: string): string {
8+
const parsedUrl = url?.trim() || '';
9+
const safeLabel = label.trim();
10+
return parsedUrl.length ? `[${safeLabel}](${parsedUrl})` : safeLabel;
811
}

packages/typedoc-plugin-markdown/test/__snapshots__/entryfiles/entryfiles.members.opts-2.entry-module-classes-ModuleClass.mdx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
***
44

5-
[@scope/entryfile]() / [entry-module](../../index.mdx) / ModuleClass
5+
@scope/entryfile / [entry-module](../../index.mdx) / ModuleClass
66

77
# Class: ModuleClass
88

packages/typedoc-plugin-markdown/test/__snapshots__/entryfiles/entryfiles.members.opts-2.index.mdx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
***
44

5-
[@scope/entryfile]() / entry-module
5+
@scope/entryfile / entry-module
66

77
# @scope/entryfile
88

0 commit comments

Comments
 (0)