Skip to content

Commit 5fee1e8

Browse files
committed
Allow links in image captions
1 parent a538d1c commit 5fee1e8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Changed output to no longer be prettified.
55
- Fixed spacing issues resulting from output prettification.
66
- Fixed a crash occurring when invalid dates are given to `#time`.
7+
- Fixed links in image captions breaking the output.
78
- Fixed underscores appearing in the default page title when present in the URL.
89
- Fixed links not being automatically capitalised.
910
- Fixed named references not working.

src/parse.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,18 @@ export function parse(data: string, config: Config = {}): Result {
143143
return content;
144144
})
145145

146-
// Internal links: [[Page]] and [[Page|Text]]
146+
// Internal links
147+
// [[Page]]
147148
.replace(re(r`\[\[ ([^\]|]+?) \]\]`), (_, link) => {
148149
if (_.includes('{{')) return _;
150+
if (/(?:File|Image):/.test(link)) return _;
149151
const content = `<a class="internal-link" title="${link}" href="./${toLinkText(link)}">${link}</a>`;
150152
return content;
151153
})
154+
// [[Page|Text]]
152155
.replace(re(r`\[\[ ([^\]|]+?) \| ([^\]]+?) \]\]`), (_, link, text) => {
153156
if (link.includes('{{')) return _;
157+
if (/(?:File|Image):/.test(link)) return _;
154158
const content = `<a class="internal-link" title="${link}" href="./${toLinkText(link)}">${text}</a>`;
155159
return content;
156160
})

0 commit comments

Comments
 (0)