Skip to content

Commit

Permalink
fix: underline(_) is not allowed inside words(fix #409)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sohee Lee authored and sohee-lee7 committed Mar 14, 2019
1 parent 12ab35f commit 00b75fa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/js/markdownCommands/italic.js
Expand Up @@ -87,7 +87,7 @@ const Italic = CommandManager.command('markdown', /** @lends Italic */{
* @returns {string} - italic text * @returns {string} - italic text
*/ */
append(text) { append(text) {
return `_${text}_`; return `*${text}*`;
}, },


/** /**
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/markdown/toolbar/italic.spec.js
Expand Up @@ -10,7 +10,7 @@ test('click italic button then type text', async t => {
.pressKey('e') .pressKey('e')
.pressKey('s') .pressKey('s')
.pressKey('t') .pressKey('t')
.expect(editor.markdown.lines.nth(0).textContent).eql('_test_') .expect(editor.markdown.lines.nth(0).textContent).eql('*test*')
.expect(editor.markdown.preview.innerHTML).contains('<em>'); .expect(editor.markdown.preview.innerHTML).contains('<em>');
}); });


Expand All @@ -24,6 +24,6 @@ test('type text, select the text then click italic button', async t => {
.pressKey('home') .pressKey('home')
.pressKey('shift+end') .pressKey('shift+end')
.click(editor.toolbar.italic) .click(editor.toolbar.italic)
.expect(editor.markdown.lines.nth(0).textContent).eql('_test_') .expect(editor.markdown.lines.nth(0).textContent).eql('*test*')
.expect(editor.markdown.preview.innerHTML).contains('<em>'); .expect(editor.markdown.preview.innerHTML).contains('<em>');
}); });
8 changes: 4 additions & 4 deletions test/unit/markdownCommands/italic.spec.js
Expand Up @@ -36,15 +36,15 @@ describe('Italic', () => {


Italic.exec(mde); Italic.exec(mde);


expect(cm.getValue()).toEqual(['mytext1', '', 'myt__ext2', 'mytext3'].join('\n')); expect(cm.getValue()).toEqual(['mytext1', '', 'myt**ext2', 'mytext3'].join('\n'));
}); });


it('in a blank line', () => { it('in a blank line', () => {
doc.setCursor(1, 3); doc.setCursor(1, 3);


Italic.exec(mde); Italic.exec(mde);


expect(cm.getValue()).toEqual(['mytext1', '__', 'mytext2', 'mytext3'].join('\n')); expect(cm.getValue()).toEqual(['mytext1', '**', 'mytext2', 'mytext3'].join('\n'));
}); });


it('around selected text', () => { it('around selected text', () => {
Expand All @@ -58,7 +58,7 @@ describe('Italic', () => {


Italic.exec(mde); Italic.exec(mde);


expect(cm.getValue()).toEqual(['_mytext1_', '', 'mytext2', 'mytext3'].join('\n')); expect(cm.getValue()).toEqual(['*mytext1*', '', 'mytext2', 'mytext3'].join('\n'));
}); });


it('should remove italic syntax in the middle of the given range', () => { it('should remove italic syntax in the middle of the given range', () => {
Expand All @@ -74,7 +74,7 @@ describe('Italic', () => {


Italic.exec(mde); Italic.exec(mde);


expect(cm.getValue()).toEqual('_my text 1_'); expect(cm.getValue()).toEqual('*my text 1*');
}); });
}); });
}); });

0 comments on commit 00b75fa

Please sign in to comment.