Skip to content

Commit

Permalink
fix(MagicLinkToken): ignore full-width punctuation in ext-link-url
Browse files Browse the repository at this point in the history
  • Loading branch information
bhsd-harry committed Jun 17, 2024
1 parent 5aac506 commit 613e1dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## v1.9.3

*2024-06-17*
*2024-06-18*

**Added**

Expand All @@ -10,6 +10,10 @@

- Fix event handling for [`DoubleUnderscoreToken`](https://github.com/bhsd-harry/wikiparser-node/wiki/DoubleUnderscoreToken)

**Changed**

- No longer report full-width punctuations in `ext-link-url` as an error in [`MagicLinkToken.prototype.lint`](https://github.com/bhsd-harry/wikiparser-node/wiki/MagicLinkToken#lint)

## v1.9.2

*2024-06-10*
Expand Down
8 changes: 4 additions & 4 deletions src/magicLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ export abstract class MagicLinkToken extends Token {
return errors;
}
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
/[,;。:!?()]+|\|+/gu;
const source = `[,;。:!?()]+${this.type === 'ext-link-url' ? String.raw`|\|+` : ''}`,
/[,;。:!?()]+/gu;
const pipe = this.type === 'ext-link-url',
source = pipe ? String.raw`\|+` : '[,;。:!?()]+',
regex = new RegExp(source, 'u'),
regexGlobal = new RegExp(source, 'gu');
for (const child of this.childNodes) {
Expand All @@ -169,8 +170,7 @@ export abstract class MagicLinkToken extends Token {
left = lines[top - 1]!.length,
startIndex = refError.startIndex + index,
startLine = refError.startLine + top - 1,
startCol = top === 1 ? refError.startCol + left : left,
pipe = s.startsWith('|');
startCol = top === 1 ? refError.startCol + left : left;
const e = {
...refError,
message: Parser.msg('$1 in URL', pipe ? '"|"' : 'full-width punctuation'),
Expand Down

0 comments on commit 613e1dd

Please sign in to comment.