Page MenuHomePhabricator

Incoherent styling of number on a list in bold when part of one item in the list is not bold
Closed, DeclinedPublic

Description

I was making a list where almost all of the content was bolded, and I ran into a strange bug. The following example results in incoherent styling of the numbers on the list:

<b>
# a b c
# d e f
# g </b>h<b> i
# j k l
# m n o
</b>

The numbers 1, 2, 4, and 5 are bolded. The number 3 is inexplicably not bolded. This problem also occurs when using tags such as <i> or <small>. The result was particularly severe when I tested the <tt> tag, the number 3 was thrown grossly out of vertical alignment.

Expected result: The numbers receive whatever styling is active where the # symbol appears.

Event Timeline

Alsee created this task.Sep 16 2018, 6:58 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 16 2018, 6:58 PM
Alsee updated the task description. (Show Details)Sep 16 2018, 7:15 PM
Aklapper renamed this task from Incoherent styling of numbers on a list to Incoherent styling of number on a list in bold when part of one item in the list is not bold.Sep 16 2018, 7:38 PM
Nirmos added a subscriber: Nirmos.Sep 16 2018, 7:51 PM

Produced HTML:

<p>
	<b>
	</b>
</p>
<b></b>
<ol>
	<b>
		<li>a b c</li>
		<li>d e f</li>
	</b>
	<li>
		<b>g </b>
		h
		<b> i</b>
	</li>
	<b>
		<li>j k l</li>
		<li>m n o</li>
	</b>
</ol>
<b></b>
<p>
	<b></b>
</p>

If I'm reading https://developer.mozilla.org/en-US/docs/Web/HTML/Element/b correctly, then the b tag only accepts phrasing content as content, and according to https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content neither ol nor li belongs to that category, so as I understand it, the input is invalid.

If you do want the numbers to be bolded, the proper solution is probably something like:

<div style="font-weight:bold;">
# a b c
# d e f
# g <span style="font-weight:normal;">h</span> i
# j k l
# m n o
</div>

If you don't want the numbers to be bolded, I suppose you would do it like this:

# <b>a b c</b>
# <b>d e f</b>
# <b>g</b> <span style="font-weight:normal;">h</span> <b>i</b>
# <b>j k l</b>
# <b>m n o</b>

Or a little bit shorter by nesting the span inside the b:

# <b>a b c</b>
# <b>d e f</b>
# <b>g <span style="font-weight:normal;">h</span> i</b>
# <b>j k l</b>
# <b>m n o</b>
Alsee added a comment.Sep 17 2018, 3:07 AM

the input is invalid.

We're a wiki. There is no such thing as invalid input.

The entire point of a wiki is that anyone can bang anything on the keyboard and, insofar as possible, wikitext works in a way that is intuitively understandable by someone without a programming degree. The intuitive meaning of <b> and </b> is that everything in between is bold. It would be sub-optimal, but at least comprehensible, if the numbers were immune to styling. However it is bizarre and incomprehensible that the 3 is styled differently from the other numbers.

If you shove junk into the parser, you should not be surprised if it spits junk back out. Regardless of any philosophy the parser may or may not aspire to about serving sane output for any random input string, there will always be inputs that the parser just completely fails at. In these cases, it is not enough to file a bug report (especially since the report may be closed as declined or even invalid); the correct response is to change the input so the parser behaves better. Or, if you prefer, if you do something and it hurts, don't do it.

Aklapper closed this task as Declined.Sep 17 2018, 9:01 AM

Declining as there are no plans to work around in the parser code such a broken mixture of both HTML and wikitext input.