Imagine following customized format: TemplateData specification:
"\n{{_\n| _ = _\n}}\n"
This is a typical block formatting as used for an info box with many parameters.
Expectations:
- The tranclusion code will begin on a new line. If inserted after line break, this is fine, else insert line break before.
- The terminating brackets will terminate the last tranclusion line. Wikitext will be continued on the next line.
This is taken from TemplateData Specification, section 3.7, which reads as:
- If StartFormat begins with a newline and template is already at the start of a line (the character preceding this template invocation is a newline or the template is at the start of the output), delete the initial newline from the output string.
- if EndFormat begins with a newline and the last character in the output string is a newline, then delete the last character in the output string. Append the EndFormat to the output string.
First strange thing is that on insertion at top of page an empty line is inserted by VisualEditor before transclusion. That is not what is intended by begin transclusion on a new line.
Second, the wikitext is expected like:
A sentence before. {{Infobox foo | title = ... | image = ... | location = ... }} A sentence following afterwards.
However, after manipulating such transclusion, it looks like
A sentence before. {{Infobox foo | title = ... | image = ... | location = ... }} A sentence following afterwards.
If transclusion is already beginning on a new line there is no need to insert an additional one, nor is it desired to insert an empty line when brackets already terminating the last line.
If heading and trailing \n are omitted in format: specification like
"{{_\n| _ = _\n}}"
insertion into the following text
A sentence before. A sentence following afterwards.
would result in:
A sentence before.{{Infobox foo | title = ... | image = ... | location = ... }} A sentence following afterwards.
All that does not hold the expectations from specification.
If there is already a whitespace-only line before or after or at top of page, those shall be shrinked and no additional newline shall be inserted.