Skip to content

Commit 47570bc

Browse files
committed
chore(test): update commonmark spec test cases
Signed-off-by: Jonas <jonas@freesources.org>
1 parent 5711ca8 commit 47570bc

4 files changed

Lines changed: 1578 additions & 1579 deletions

File tree

src/markdownit/wikiLinks.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import type MarkdownIt from 'markdown-it'
1414
*
1515
* A `data-wiki-image` or `data-wiki-link` attribute is set so the ProseMirror
1616
* serializer can round-trip the syntax back to the wiki style link/image syntax.
17+
*
18+
* @param md - The markdown-it instance to extend
1719
*/
1820
export default function wikiLinks(md: MarkdownIt): void {
1921
// Parse wiki image links `![[filename]]`
@@ -93,7 +95,7 @@ export default function wikiLinks(md: MarkdownIt): void {
9395

9496
// Reject targets containing characters that conflict with CommonMark inline syntax
9597
// ([, ], * are not valid in file names on most systems anyway)
96-
if (/[\[\]*]/.test(target)) return false
98+
if (/[[]*]/.test(target)) return false
9799

98100
if (silent) return true
99101

src/marks/Link.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,17 +259,15 @@ const Link = TipTapLink.extend<RelativePathLinkOptions>({
259259
index: number,
260260
) {
261261
if (!mark.attrs.isWikiLink) {
262-
return defaultMarkdownSerializer.marks.link.open(
263-
state,
264-
mark,
265-
parent,
266-
index,
267-
)
262+
const open = defaultMarkdownSerializer.marks.link.open
263+
return typeof open === 'function'
264+
? open(state, mark, parent, index)
265+
: open
268266
}
269267
const href = mark.attrs.href as string
270268
// Collect the display text of this mark's span to decide the form
271269
let innerText = ''
272-
parent.descendants((child, _pos) => {
270+
parent.descendants((child) => {
273271
if (!mark.isInSet(child.marks)) {
274272
return false
275273
}
@@ -286,12 +284,10 @@ const Link = TipTapLink.extend<RelativePathLinkOptions>({
286284
_index: number,
287285
) {
288286
if (!mark.attrs.isWikiLink) {
289-
return defaultMarkdownSerializer.marks.link.close(
290-
state,
291-
mark,
292-
_parent,
293-
_index,
294-
)
287+
const close = defaultMarkdownSerializer.marks.link.close
288+
return typeof close === 'function'
289+
? close(state, mark, _parent, _index)
290+
: close
295291
}
296292
return ']]'
297293
},

0 commit comments

Comments
 (0)