Page MenuHomePhabricator

Control whitespace in injected wikitext for multi-line comments
Open, MediumPublic

Description

Our current approach for saving wikitext replies via Parsoid is:

  1. Add new list at required depth for reply, to Parsoid DOM
  2. For each line of the reply, add a list item
  3. In each list item, add a <span typeof="mw:Transclusion" data-mw="{parts:{wt:WIKITEXT_LINE}}"></span>

This results in a space between the list markup and the wikitext line: ::: WIKITEXT_LINE which is usually fine, except when the user tried to add a list, then you get ::: * LIST which doesn't render correctly.

Our current workaround is to add data-parsoid="" to the list item which tricks Parsoid into not rendering whitespace, but is very hacky and fragile.

In the long term this would be fixed by multi-line list syntax, but we may want something more stable in the medium-term.

Event Timeline

Esanders created this task.Nov 13 2019, 2:55 PM
Restricted Application added subscribers: Liuxinyu970226, Aklapper. · View Herald TranscriptNov 13 2019, 2:55 PM
Esanders renamed this task from Control whitespace for multi-line comments to Control whitespace in injected wikitext for multi-line comments.Nov 13 2019, 2:55 PM

One quick obvious thought. Maybe a "data-ve-multiline-reply-hack" attribute to the list-item span which is similar to your data-parsoid="": hack, but something which is less-hacky (since we don't want editors dealing with data-parsoid). We can remove support for this attribute once the multi-line list syntax lands. The "-hack" serves as a reminder to us all not to keep it around.

Jc86035 added a subscriber: Jc86035.EditedNov 24 2019, 12:14 PM

Why is it preferable to save raw HTML? Wouldn't it be better, from the perspective that wikitext should be as readable and compact as possible, to, say, use a parser function or extension tag (e.g. at start and end, or within the signature) that results in the same HTML being inserted into the page? Doing so would also allow for the parser function/extension tag to be modified without changes to the wikitext (making comments from v1 and v2 of DiscussionTools forward-compatible), and could potentially allow for substituted (i.e. fake) comments to be distinguishable from real comments in some way.

(For this reply I'm assuming that the <span ...>...</span> is being saved directly into the wikitext, since this seems to be implied.)

TheDJ added a subscriber: TheDJ.Nov 27 2019, 1:01 PM

Was it considered to serialise additional information inside HTML comments ? Those wouldn't interfere with the render output.

LGoto moved this task from Needs Triage to Backlog on the Parsoid board.Feb 15 2020, 12:05 AM
LGoto triaged this task as Medium priority.Feb 21 2020, 5:20 PM
LGoto moved this task from Backlog to Future Ideas on the Parsoid board.

(For this reply I'm assuming that the <span ...>...</span> is being saved directly into the wikitext, since this seems to be implied.)

No HTML tags are saved in the wikitext, it gets converted to the expected wikitext as stated in the description after point 3.