Page MenuHomePhabricator

Find a way to support newlines in details attribute with VE
Open, Needs TriagePublic

Description

Story

As editor using details to add additional details to a reference I want to be able to use newlines in Wikitext.

Background

Currently a newline in the attribute content in Wikitext is not supported in VE and will be removed when loading the content there. A literal newline character in the ref details attribute can't be supported, but it could be rendered as break tag <br />.

Steps to reproduce
  • Start with a page and the following Wikitext
<ref details="Line1 

Line2" name="book">Miller</ref>
  • Load VE and edit the details content
  • The newlines are not loaded into the editor

Event Timeline

awight changed the subtype of this task from "Spike" to "Task".

The project tag has been archived, please add an active project tag so this open task can be found. Thanks!

WMDE-Fisch renamed this task from Newline in details attribute can be converted to <br /> to Find a way to support newlines in details attribute with VE.Jun 16 2025, 11:32 AM
WMDE-Fisch updated the task description. (Show Details)

Adding some more information about the current behavior:

  • It's trivial to add a newline in VE at the moment, we do not prevent it in the dialog. Steps to reproduce are simply to edit details and add one or two newlines, which results in a diff like this one:

image.png (173×1 px, 19 KB)

  • Surprisingly, both the legacy and new parsers accept the input and render the newline as a regular space character, despite the newlines appearing in wikitext. This behavior is the same when editing the main reference body! Did Cite ever allow vertical space?
  • Also surprisingly, comparing against the HTML spec it seems that an attribute value can contain any text, even newline. This is clear reading the quoted attribute syntax vs. the unquoted syntax: the latter will stop parsing the value after seeing a newline.

So the only consequence seems to be weird UI glitches where the newlines are eaten or turned into special characters, +1 that it can wait until after MVP. Here's an image of what happens when loading a page with newlines in both the main and details:

image.png (241×583 px, 11 KB)