Skip to content

Commit

Permalink
Add italic support in echo.js
Browse files Browse the repository at this point in the history
Fixes: #1103
  • Loading branch information
TigorC committed Nov 8, 2016
1 parent 81fff69 commit 08df703
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion frontend_tests/node_tests/echo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 8 additions & 2 deletions static/js/echo.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,15 @@ $(function () {
disable_markdown_regex(marked.Lexer.rules.tables, 'heading');
disable_markdown_regex(marked.Lexer.rules.tables, 'lheading');

// Disable __strong__, all <em>
// Disable __strong__
marked.InlineLexer.rules.zulip.strong = /^\*\*([\s\S]+?)\*\*(?!\*)/;
disable_markdown_regex(marked.InlineLexer.rules.zulip, 'em');

// Disable _emphasis_
// Disable special characters for the emphasis syntax
// Inside ** allowed only: word characters/spaces/tabulate
// it need for things like "const char *x = (char *)y"
marked.InlineLexer.rules.zulip.em = /^\*((?:\*\*|[\w|\ |\t])+?)\*(?!\*)/;

disable_markdown_regex(marked.InlineLexer.rules.zulip, 'del');
// 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

0 comments on commit 08df703

Please sign in to comment.