mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 10:57:58 +00:00
markdown.js: Fix inconsistent user mention on new line.
The user mention regex was checking for multiple lines, so it broke when the user mention was on a new line. This changes the regex AND adds a couple tests to test inline markdown regexes.
This commit is contained in:
@@ -234,6 +234,12 @@ var bugdown_data = JSON.parse(fs.readFileSync(path.join(__dirname, '../../zerver
|
|||||||
expected: '<p>This is a <img alt="cordelia@zulip.com" class="message_body_gravatar" src="/avatar/cordelia@zulip.com?s=30" title="cordelia@zulip.com"> of Cordelia Lear</p>'},
|
expected: '<p>This is a <img alt="cordelia@zulip.com" class="message_body_gravatar" src="/avatar/cordelia@zulip.com?s=30" title="cordelia@zulip.com"> of Cordelia Lear</p>'},
|
||||||
{input: 'Test *italic*',
|
{input: 'Test *italic*',
|
||||||
expected: '<p>Test <em>italic</em></p>'},
|
expected: '<p>Test <em>italic</em></p>'},
|
||||||
|
{input: 'T\n#**Denmark**',
|
||||||
|
expected: '<p>T</p>\n<p><a class="stream" data-stream-id="1" href="http://zulip.zulipdev.com/#narrow/stream/Denmark">#Denmark</a></p>'},
|
||||||
|
{input: 'T\n@**Cordelia Lear**',
|
||||||
|
expected: '<p>T<br>\n<span class="user-mention" data-user-id="101">@Cordelia Lear</span></p>'},
|
||||||
|
{input: 'This is a realm filter `hello` with text after it',
|
||||||
|
expected: '<p>This is a realm filter <code>hello</code> with text after it</p>'},
|
||||||
];
|
];
|
||||||
|
|
||||||
// We remove one of the unicode emoji we put as input in one of the test
|
// We remove one of the unicode emoji we put as input in one of the test
|
||||||
|
|||||||
@@ -541,7 +541,7 @@ inline.zulip = merge({}, inline.breaks, {
|
|||||||
'\ud83d[\ude80-\udeff]|\ud83e[\udd00-\uddff]|' +
|
'\ud83d[\ude80-\udeff]|\ud83e[\udd00-\uddff]|' +
|
||||||
'[\u2000-\u206F]|[\u2300-\u27BF]|[\u2B00-\u2BFF]|' +
|
'[\u2000-\u206F]|[\u2300-\u27BF]|[\u2B00-\u2BFF]|' +
|
||||||
'[\u3000-\u303F]|[\u3200-\u32FF])'),
|
'[\u3000-\u303F]|[\u3200-\u32FF])'),
|
||||||
usermention: /^(@(?:\*\*([^\*]+)\*\*|(\w+)))/m, // Match multi-word string between @** ** or match any one-word
|
usermention: /^(@(?:\*\*([^\*]+)\*\*|(\w+)))/, // Match multi-word string between @** ** or match any one-word
|
||||||
stream: /^#\*\*([^\*]+)\*\*/m,
|
stream: /^#\*\*([^\*]+)\*\*/m,
|
||||||
avatar: /^!avatar\(([^)]+)\)/,
|
avatar: /^!avatar\(([^)]+)\)/,
|
||||||
gravatar: /^!gravatar\(([^)]+)\)/,
|
gravatar: /^!gravatar\(([^)]+)\)/,
|
||||||
|
|||||||
Reference in New Issue
Block a user