Page MenuHomePhabricator

Lua: new line before infobox not suppressed
Closed, DuplicatePublic


(Discussed on English WP and on German WP).

I have recently converted the Infobox Chartplatzierungen on German WP to Lua, and its behaviour when used at the beginning of an article after a one-line HTML comment has apparently changed: previously the empty line (comment) was suppressed, while now the article will start with an empty line (eg see Mark Knopfler). Example of source:

<!-- comment -->
{{Infobox Chartplatzierungen

Obviously this can be fixed by changing the position of the comment (or at least of the closing tag), but I would expect the same behaviour for any infobox template, not depending on whether it is based on Lua or on wikitext / parser functions. Is it possible to fix this in order to have the empty line suppressed in all cases?

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 7 2018, 9:13 PM
Cirdan added a subscriber: Cirdan.Aug 8 2018, 5:13 AM

Sounds like T14974 due to the extra deep with line-start wikisyntax. I would say, this is not a lua problem.

It is not T25698, because that is not about templates.

You can try to wrap the module into a <div> in your main template or start with categories (invisible wikisyntax) and so "break" the parser at this position. The other solution is to remove the comments or the newline between comments and template.

XanonymusX added a comment.EditedAug 8 2018, 8:27 PM

I will look into this. But if it is not a Lua problem, what other change to the template could have been relevant for changing the behaviour? If you compare this article with the original template and the corresponding German article with the new Lua template, the difference is visible.

EDIT: Oh, well, apparently I found an easy fix: I wrapped the table (in the Lua module) into a <div>, so that the first line after the comment is no longer the {|, but the div tag. Not the behaviour that I expect, but if this is the solution, it wasn't too complex after all!

The change is a extra deep of {{

For the changes the {| was directly in the template, now one level deeper. This can also be tested with a normal template + subtemplate and in the subtemplate the {| for the wiki table.

Ah, I see. My earlier suggestion for a fix was indeed to leave the first line with the {| inside the template and create only the following parts through Lua. But apparently the <div>\n{| solves the problem! Thus I suppose that infoboxes should always be wrapped in a div to avoid such a behaviour.