Skip to content

Commit

Permalink
fix(MediaWiki): file link
Browse files Browse the repository at this point in the history
  • Loading branch information
bhsd-harry committed May 18, 2024
1 parent db10b12 commit fac280f
Show file tree
Hide file tree
Showing 4 changed files with 753 additions and 754 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 2.13.0

*2024-05-12*
*2024-05-18*

**Added**

Expand All @@ -14,6 +14,7 @@
- Template argument names are now correctly highlighted in the MediaWiki mode
- `<` breaks the wikilink syntax in the MediaWiki mode
- Table cell attributes are now correctly highlighted and [autocompleted](./README.md#autocompletion) in the MediaWiki mode
- Page name of a file link now contains the namespace in the MediaWiki mode

**Changed**

Expand Down
2 changes: 1 addition & 1 deletion dist/main.min.js

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions src/mediawiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ export class MediaWiki {
if (redirect || /[^[\]|]/u.test(stream.peek() || '')) {
state.nLink++;
state.lbrack = undefined;
chain(state, this.inLink(!redirect && Boolean(stream.match(this.fileRegex))));
chain(state, this.inLink(!redirect && Boolean(stream.match(this.fileRegex, false))));
return this.makeLocalTagStyle('linkBracket', state);
}
} else {
Expand Down Expand Up @@ -835,9 +835,7 @@ export class MediaWiki {
inLinkText(file: boolean): Tokenizer {
const linkState = {bold: false, italic: false},
regex = file
? new RegExp(`^(?:[^'\\]{&<~|[]|'(?!')|\\](?!\\])|\\{(?!\\{)|<(?![!/a-z])|~~?(?!~)|\\[(?!${
this.config.urlProtocols
}|\\[))+`, 'iu')
? /^(?:[^'\]{&<[~|]|'(?!')|\](?!\])|\{(?!\{)|<(?![!/a-z])|~~?(?!~))+/iu
: /^(?:[^'\]{&<[]|'(?!')|\](?!\])|\{(?!\{)|<(?![!/a-z])|\[(?!\[))+/iu;
return (stream, state) => {
const tmpstyle = `${tokens.linkText} ${linkState.bold ? tokens.strong : ''} ${
Expand Down
Loading

0 comments on commit fac280f

Please sign in to comment.