Skip to content

Commit

Permalink
bugdown: Fixed emphasis regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
TigorC committed Nov 8, 2016
1 parent 5fd1c04 commit b88126e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions static/js/echo.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,9 @@ $(function () {
marked.InlineLexer.rules.zulip.del = /^(?!<\~)\~\~([^~]+)\~\~(?!\~)/;

// Disable _emphasis_
// Disable special characters for the emphasis syntax
// Inside ** allowed only: word characters/spaces/tabulate
// 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 = /^\*((?:\*\*|[\w|\ |\t])+?)\*(?!\*)/;
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');
Expand Down
2 changes: 1 addition & 1 deletion static/third/marked/lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,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;
}

Expand Down
5 changes: 2 additions & 3 deletions zerver/lib/bugdown/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,12 +1014,11 @@ def extendMarkdown(self, md, md_globals):
markdown.inlinepatterns.SimpleTagPattern(r'(?<!~)(\~\~)([^~{0}\n]+?)\2(?!~)', 'del'),
'>strong')

# Disable special characters for the emphasis syntax
# Inside ** allowed only: word characters/spaces/tabulate
# 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'(\*)([\w|\ |\t]+)\*', 'em'),
markdown.inlinepatterns.SimpleTagPattern(r'(\*)(?!\s+)([^\*^\n]+)(?<!\s)\*', 'em'),
'>strong')

for k in ('hashheader', 'setextheader', 'olist', 'ulist'):
Expand Down

0 comments on commit b88126e

Please sign in to comment.