improved code readability

This commit is contained in:
Jori Lallo
2017-10-22 11:22:25 -07:00
parent 3652b19e99
commit 6959cec1bf

View File

@ -78,13 +78,16 @@ export default function MarkdownShortcuts() {
const { text } = startBlock; const { text } = startBlock;
const start = i; const start = i;
const end = i + shortcut.length; const end = i + shortcut.length;
const beginningOfBlock = start === 0;
const endOfBlock = end === text.length;
const surroundedByWhitespaces = [
text.slice(start - 1, start),
text.slice(end, end + 1),
].includes(' ');
if ( if (
text.slice(start, end) === shortcut && text.slice(start, end) === shortcut &&
(start === 0 || (beginningOfBlock || endOfBlock || surroundedByWhitespaces)
end === text.length ||
[text.slice(start - 1, start), text.slice(end, end + 1)].includes(
' '
))
) )
inlineTags.push(i); inlineTags.push(i);
} }