I don't know whether this is expected behaviour or not, but it's troublesome.
It occurs on the language Wikipedias, but it doesn't occur on Wikimedia Commons or Wiktionary, which seem to handle new lines differently.
Steps to reproduce:
- Have a template with TemplateData with a custom format that begins with "\n". I used a few sandbox templates with sandbox TemplateData in their /doc pages.
- Example:
- (the last "\n" doesn't cause this bug)
- Edit a page in VisualEditor on any of the language wikis (English and French tested) but not Wikimedia Commons or Wiktionary (no bug here).
- Find a paragraph of text, and add new lines to make space to add a template – but, make sure there is precisely 1 new line between the cursor and the next content above.
- Example:
- Insert the template.
- Switch to source mode, and locate where you inserted the template.
Actual result:
A "<br/>" tag is inserted on the line above the template.
Expected result:
No "<br/>" tag is inserted.
Notes:
It does not occur in TemplateWizard or the 2017 wikitext editor.
It also does not occur with 2 or more lines above (most of the time) or 0 lines above.
- Examples:
There were a few times it did occur with more than 2 lines above, but only when there were 0 lines below. This did not always happen when there were 0 lines below. I couldn't establish the rule.
- Example:
- (It created these new lines below. They were not there when inserting.)
It does not occur on Wiktionary or Wikimedia Commons, where you cannot insert templates with no blank wikitext lines between each other in VisualEditor. However, even when there is only 1 blank line above the template, the bug does not occur.
- Example:
- VisualEditor:
- Wikitext: