mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
@@ -151,7 +151,9 @@ var bugdown_data = JSON.parse(fs.readFileSync(path.join(__dirname, '../../zerver
|
||||
{input: 'This is an !avatar(cordelia@zulip.com) of Cordelia Lear',
|
||||
expected: '<p>This is an <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: 'This is a !gravatar(cordelia@zulip.com) of Cordelia Lear',
|
||||
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*',
|
||||
expected: '<p>Test <em>italic</em></p>'}
|
||||
];
|
||||
|
||||
test_cases.forEach(function (test_case) {
|
||||
|
||||
@@ -451,11 +451,17 @@ $(function () {
|
||||
disable_markdown_regex(marked.Lexer.rules.tables, 'heading');
|
||||
disable_markdown_regex(marked.Lexer.rules.tables, 'lheading');
|
||||
|
||||
// Disable __strong__, all <em>
|
||||
// Disable __strong__ (keeping **strong**)
|
||||
marked.InlineLexer.rules.zulip.strong = /^\*\*([\s\S]+?)\*\*(?!\*)/;
|
||||
disable_markdown_regex(marked.InlineLexer.rules.zulip, 'em');
|
||||
|
||||
// Make sure <del> syntax matches the backend processor
|
||||
marked.InlineLexer.rules.zulip.del = /^(?!<\~)\~\~([^~]+)\~\~(?!\~)/;
|
||||
|
||||
// Disable _emphasis_ (keeping *emphasis*)
|
||||
// Text inside ** must start and end with a word character
|
||||
// it need for things like "const char *x = (char *)y"
|
||||
marked.InlineLexer.rules.zulip.em = /^\*(?!\s+)((?:\*\*|[\s\S])+?)((?:[\S]))\*(?!\*)/;
|
||||
|
||||
// Disable autolink as (a) it is not used in our backend and (b) it interferes with @mentions
|
||||
disable_markdown_regex(marked.InlineLexer.rules.zulip, 'autolink');
|
||||
|
||||
|
||||
@@ -742,7 +742,7 @@ InlineLexer.prototype.output = function(src) {
|
||||
// em
|
||||
if (cap = this.rules.em.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
out += this.renderer.em(this.output(cap[2] || cap[1]));
|
||||
out += this.renderer.em(cap[1] + cap[2]);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,9 +121,21 @@
|
||||
"bugdown_matches_marked": true
|
||||
},
|
||||
{
|
||||
"name": "star_disabled",
|
||||
"name": "emphasis_text",
|
||||
"input": "*foo*",
|
||||
"expected_output": "<p>*foo*</p>",
|
||||
"expected_output": "<p><em>foo</em></p>",
|
||||
"bugdown_matches_marked": true
|
||||
},
|
||||
{
|
||||
"name": "emphasis_code",
|
||||
"input": "const char *x = (char *)y",
|
||||
"expected_output": "<p>const char *x = (char *)y</p>",
|
||||
"bugdown_matches_marked": true
|
||||
},
|
||||
{
|
||||
"name": "emphasis_with_space",
|
||||
"input": "A *foo bar* is a *baz quux*",
|
||||
"expected_output": "<p>A <em>foo bar</em> is a <em>baz quux</em></p>",
|
||||
"bugdown_matches_marked": true
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1014,6 +1014,13 @@ class Bugdown(markdown.Extension):
|
||||
markdown.inlinepatterns.SimpleTagPattern(r'(?<!~)(\~\~)([^~{0}\n]+?)\2(?!~)', 'del'),
|
||||
'>strong')
|
||||
|
||||
# Text inside ** must start and end with a word character
|
||||
# it need for things like "const char *x = (char *)y"
|
||||
md.inlinePatterns.add(
|
||||
'emphasis',
|
||||
markdown.inlinepatterns.SimpleTagPattern(r'(\*)(?!\s+)([^\*^\n]+)(?<!\s)\*', 'em'),
|
||||
'>strong')
|
||||
|
||||
for k in ('hashheader', 'setextheader', 'olist', 'ulist'):
|
||||
del md.parser.blockprocessors[k]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user