Reputation: 571
I have the following HTML code (a list item). The content isn't important--the problem is the end of line 2.
<li>Yes, you can learn how to play piano without becoming a
great notation reader,
however, <strong class="warning">you <em class="emphatic">will</em>
have to acquire a <em class="emphatic">very</em>basic amount
of notation reading skill</strong>. But the extremely
difficult task of honing your note reading skills that
classical students are required to endure for years and years
is <em class="emphatic">totally non-existant</em>as a
requirement for playing non-classical piano.</li>
The command fill-paragraph (M-q) has been applied. I can't for the life of me figure out why a line break is being placed on the second line after "reader," since there's more space available on that line to put "however,". Another weird thing I've noticed is that when I delete and then reapply the tab characters on lines 4 and 5 (starting with "have" and "of" respectively), two space characters are automatically inserted as well, like so:
<li>Yes, you can learn how to play piano without becoming a
great notation reader,
however, <strong class="warning">you <em class="emphatic">will</em>
have to acquire a <em class="emphatic">very</em>basic amount
of notation reading skill</strong>. But the extremely
difficult task of honing your note reading skills that
classical students are required to endure for years and years
is <em class="emphatic">totally non-existant</em>as a
requirement for playing non-classical piano.</li>
I don't know if this is some kind of clue or not. This doesn't happen with any of the other lines.
Is this just a bug, or does any experienced Emacs person know what might be going on here?
Thank you
Upvotes: 4
Views: 525
Reputation: 330
This is intentional. Lines that start with an XML or SGML tag are paragraph separator lines. If Emacs broke the paragraph in such a way that the tag ended up at the start of a line, subsequent applications of fill-paragraph
would stop at that line. This is to ensure that, for instance,
<p>a paragraph</p>
<!-- no blank line -->
<p>another paragraph</p>
does not turn into
<p>a paragraph</p> <!-- no blank line --> <p>another paragraph</p>
For the same reason, Emacs will not break a line after a period unless there are two or more spaces after the period, because it uses a double space to distinguish between a period that ends a sentence and a period that ends an abbreviation, and breaking a line after the period that ends an abbreviation would create an ambiguous situation.
Upvotes: 3
Reputation: 13917
Looks like a bug to me.
I was able to trim down your example to something like this:
<li>blabla
blabla <b>some_long_text_here</b> <b>more_long_text_here</b>
If I remove a single character of text from it, fill-paragraph
works as expected. Or if I add a chacter between the two consequtive <b>
elements.
Upvotes: 1