Emacs fill-paragraph does not break lines where expected

I have the following HTML (list item). The content is not important - the problem is at 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 fill-paragraph (Mq) command applies. I can’t understand for life why the line break is on the second line after the “reader”, because there is more space on this line to put “however”. Another strange thing I noticed is that when I delete and then re-apply the tabs in lines 4 and 5 (starting with "have" and "from" respectively), two spaces are automatically added, for example:

 <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 do not know if this is some kind of key or not. This does not happen on any of the other lines.

Is this just a mistake, or does any experienced Emacs person know what could happen here?

thanks

+4
source share
2 answers

This is intentional. Lines starting with an XML or SGML tag are paragraph separators. If Emacs violated the paragraph in such a way that the tag appeared at the beginning of the line, subsequent fill-paragraph applications would stop at that line. This is done so that, for example,

 <p>a paragraph</p> <!-- no blank line --> <p>another paragraph</p> 

doesn't turn into

 <p>a paragraph</p> <!-- no blank line --> <p>another paragraph</p> 

For the same reason, Emacs will not interrupt a line after a period unless there are two or more spaces after a period because it uses double space to distinguish between a period ending with a sentence and a period ending with an abbreviation and a line break after a period that ends with an abbreviation, will create an ambiguous situation.

+3
source

Looks like a mistake.

I managed to trim your example like this:

 <li>blabla blabla <b>some_long_text_here</b> <b>more_long_text_here</b> 

If I remove one character of text from it, fill-paragraph works as expected. Or if I add chacter between the two concise <b> elements.

+1
source

Source: https://habr.com/ru/post/1336336/


All Articles