Page MenuHomePhabricator

Nested div tags prevent double-newlines from breaking paragraphs
Closed, InvalidPublic

Description

It seems that when using nested div's the parser becomes confused about the handling of double newlines and seemingly ignores them completely.

Minimal test case : https://en.wikisource.org/w/index.php?title=Wikisource:Sandbox&oldid=5200023
Real word example: https://en.wikisource.org/w/index.php?title=Page:The_origin_and_deeds_of_the_Goths_in_English_version.djvu/61&oldid=5200003

From MediaWiki-General - (IRC log (edited). )

Qcoder00 Anyone about who could explain why the parser isn't rendering this properly?
Qcoder00 https://en.wikisource.org/w/index.php?title=Page:The_origin_and_deeds_of_the_Goths_in_English_version.djvu/61&action=submit
Qcoder00 Whitespace or a carrige return is being ignored
Qcoder00 I'm getting slightly disapointed that something like this remains as an annoyance
Reedy Just file it in phabricator
Qcoder00 Reedy : I did that under bugzilla
Qcoder00 It was ignored
jackmcbarn Qcoder00: looking quickly, that seems to be the templates' fault
Qcoder00 It's a div
Qcoder00 It's coded they way all other templates of that type should be
Qcoder00 jackmcbarn: I can't see why it's ignoring the whitespace
Qcoder00 There is NOTHING in the template that should cause it
Qcoder00 given that I've seen other templates using a /s /e approach and the same glitch is not enocuntered
jackmcbarn why do you have unbalanced p tags now? they weren't there a minute ago
jackmcbarn Qcoder00: oh, it's not because of the templates in the body
jackmcbarn it's the ones in the header and footer
Qcoder00 Yes
Qcoder00 Which are written like other templates of the /s /e design
Qcoder00 I can put a template like {{Smaller block/s}} and {{smaller block/e}} in the heade and footer of a page without issue
Qcoder00 In fact over multi pages, I've been told by people to EXPLICITLY USE the approach I am using here
Qcoder00 Perhaps you can telol me in words that are actually understandable, what's wrong with the templates?
Qcoder00 because conceptually I can't see why the header and footer templates used are conceptually different from :- https://en.wikisource.org/w/index.php?title=Template:Smaller_block/s
Qcoder00 jackmcbarn: The divs being rendered aren't mismatched because the header has the /s and the footer the /e
Qcoder00 So I again ask, Why is the whitespace being ignored?
jackmcbarn looking now
jackmcbarn and i meant the p tags. not the div tags
Qcoder00 removed junk tags
Qcoder00 https://en.wikisource.org/w/index.php?title=Template:Sn-paragraph/dual/s&action=edit has NO <p> tags
Qcoder00 I've removed the <p> tags from the page that's actually in use
Qcoder00 So what the parser should be seeing is a blank line (which means new paragraph) but it's seemingly getting confused on something VERY simple
Qcoder00 The div sturcture generated in the header and footer should not be causing it to get confused like this...
Qcoder00 Right?
jackmcbarn i'm trying to find a minimal test case, hold on
Qcoder00 This isn't the first time I've encounterd this....
Qcoder00 I can't use <p> </p> elements in the header and footer to force it, because the sidenotes are DIV basded
Qcoder00 which is done because the other sidenote solution is a kludge anyway
Qcoder00 Hmm
Qcoder00 me has a thought...
jackmcbarn i think i know what's going on
jackmcbarn since the new paragraph starts with a div, mediawiki doesn't force a newline since a div starts one automatically
jackmcbarn but this div doesn't, since it's floated
jackmcbarn i think.
Qcoder00 Well can you figure out to get consistent bahviour?
Qcoder00 without major breakage?
jackmcbarn i'll try
jackmcbarn if you remember where your old bug report was, can you add https://en.wikisource.org/w/index.php?title=Wikisource:Sandbox&oldid=5200023 to it?
Qcoder00 I am not sure if I ever filed a previous bug report... I do recall reporting it in here though
Qcoder00 So it's the left and right floated div's that are casuing problems?
jackmcbarn actually...
jackmcbarn # XXX: use a stack for nestable elements like span, table and div
jackmcbarn that makes me think that it's failing to keep track of whether it's in a div or not
jackmcbarn yeah, that's it. you're opening two divs, then closing one, and the parser isn't smart enough to know there's still another open
jackmcbarn can you open a phabricator task, and include both that XXX line and the permalink in it?
Qcoder00 Will do
Qcoder00 What should i title it as?
Qcoder00 I can post the IRC log as well?
Qcoder00 That should help...
jackmcbarn yeah

Event Timeline

ShakespeareFan00 raised the priority of this task from to Medium.
ShakespeareFan00 updated the task description. (Show Details)
ShakespeareFan00 subscribed.

Umm.... you're interrupting a block element with other same-level block elements - causing the containing element to collapse.

Using inline elements (span) in the sandbox example preserves both the "double line" as well as the float:right s

<div>
<span style="float:right">137</span>zzz

<span style="float:right">138</span>www
</div>

Note: don't forget that the wiki mark up detects and assumes every new line is a paragraph start so in reality the above is really...

<div>
<p><span style="float:right">137</span>zzz</p>

<p><span style="float:right">138</span>www</p>
</div>

Hmm... My next question would be why is what is clearly a 'nested div' being "collapsed" as you phrase it?

The relevant templates :

https://en.wikisource.org/wiki/Template:Sn-note
https://en.wikisource.org/wiki/Template:Sn-paragraph/dual/s

were using 'block elements' namely div's so that the width's and margins could be set, also sidenotes as block elements means that unlike a span approach they don't overlap (which happens with the {{right sidenote}} and {{left sidenote}} style templates which I would assume are span based.

It seems another test case is needed, to test what exactly can be done with a span approach....

GOIII claimed this task.