improved code readability
This commit is contained in:
@ -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);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user