Highlightr-Plugin icon indicating copy to clipboard operation
Highlightr-Plugin copied to clipboard

Highlightr adds additional space after </mark>

Open witchka opened this issue 2 years ago • 5 comments

Hi, thanks for the plugin!

One small issue I've noticed is that whenever I highlight text it adds an additional space after the closing mark tag. I don't mean the padding some of the styles have, but an actual literal space. I think this would be an error?

witchka avatar Mar 28 '22 00:03 witchka

The same issue, but not sure if it is a deliberate design or a bug. My workaround is to replace all the </mark> with </mark> before finishing editing a MD file, but this works well for Asian languages which do not use a space to separate words. As for English or other similar languages, you have to use RegEx to make a more accurate replacement.

XMB-7 avatar Apr 15 '22 01:04 XMB-7

I assumed it was a feature to allow you to keep typing

j-r-e-i-d avatar May 14 '22 03:05 j-r-e-i-d

As it happens even when highlighting text in the middle of a paragraph you've already written it kind of just introduces a lot of spaces you have to be careful to edit out.

witchka avatar May 17 '22 11:05 witchka

this is true, it would be better not to do this.

j-r-e-i-d avatar May 23 '22 00:05 j-r-e-i-d

It would be a typo or bug. Go into the highlightr-plugin folder and open main.js. Search for selectedText && sufFirst and replace the following:

                (selectedText && sufFirst === " ") ||
                    (!selectedText && sufFirst === " ")
                    ? editor.replaceSelection(`${prefix}${selectedText}${suffix}`)
                    : selectedText && sufFirst !== " "
                        ? editor.replaceSelection(`${prefix}${selectedText}${suffix} `)
                        : editor.replaceSelection(`${prefix}${selectedText}${suffix} `);

with

                (selectedText && sufFirst === " ") ||
                    (!selectedText && sufFirst === " ")
                    ? editor.replaceSelection(`${prefix}${selectedText}${suffix}`)
                    : selectedText && sufFirst !== " "
                        ? editor.replaceSelection(`${prefix}${selectedText}${suffix}`)
                        : editor.replaceSelection(`${prefix}${selectedText}${suffix} `);

xuexuemiao avatar Aug 22 '22 10:08 xuexuemiao