ckeditor / github-writer

GitHub Writer - WYSIWYG Rich-Text Editor for GitHub, powered by CKEditor.
https://ckeditor.com/
Other
379 stars 61 forks source link

Typing second underscore in a paragraph makes italic from the first one #34

Closed vokiel closed 4 years ago

vokiel commented 4 years ago

TC

  1. Start typing in a paragraph with some underscore inside the text, like:

    Just a test variable: VARIABLE_NAME and another variable

  2. Continue typing something with _ inside.

Expected: nothing changes.
Current: the whole part from the first _ get italic until the second one, the underscore disappears:

image

fredck commented 4 years ago

That's certainly and issue with the auto-formatting feature and we must report it at CKEditor 5.

One could say that auto-formatting should be triggered only if the opening marker(_) is in a word boundary. It would not solve all cases, but it would help.

Auto-formatting can be undone, by pressing ctrl/cmd+z right after the formatting happens. It has its learnability issue, but it's hard to say if this will be seen as a bug or an enhancement.

vokiel commented 4 years ago

I would rather use the _ as an opening/closing for the auto-formatting only on the beginning/end of the word respectively. Underscore inside a word should be treated as a regular character.

This case is especially visible here on GH in inline code as it is not possible to format only a part of the code.

Reinmar commented 4 years ago

Yup, upstream issue. Similar to https://github.com/ckeditor/ckeditor5/issues/5862. And perhaps exactly this: https://github.com/ckeditor/ckeditor5/issues/1239.

Reinmar commented 4 years ago

The minimum thing to do would be to disable all automatic things happening inside code blocks and inline code. An even better solution would be to make the opening _ work only when used at the beginning of some word and closing _ only at the end of a word, but that's more tricky.

fredck commented 4 years ago

and closing _ only at the end of a word

I think we're able to check only the start, because the end _, which triggers auto-formatting, happens when the user is typing and we don't know what will be typed next.

fredck commented 4 years ago

I'm considering disabling auto-formatting for italics when typing underscore, for the time being. It is a character used way too often and having such feature seems to cause more harm that good.

WDYGT?

fredck commented 4 years ago

I'm considering disabling auto-formatting for italics when typing underscore, for the time being. It is a character used way too often and having such feature seems to cause more harm that good.

I've decided to go a longer way and reviewed the auto-formatting totally. For more information, check out #105.