填充段落不会破坏预期的行

时间:2011-01-20 15:46:58

标签: emacs fill paragraph

我有以下HTML代码(列表项)。内容并不重要 - 问题是第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>

已应用命令fill-paragraph(M-q)。我不能为我的生活弄清楚为什么在“读者”之后的第二行放置换行符,因为在该行上有更多可用空间来放置“但是”。我注意到的另一个奇怪的事情是当我删除然后重新应用第4行和第5行的制表符(分别以“have”和“of”开头)时,会自动插入两个空格字符,如下所示:

<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>

我不知道这是否是某种线索。任何其他行都不会发生这种情况。

这只是一个错误,还是有经验的Emacs人知道这里会发生什么?

谢谢

2 个答案:

答案 0 :(得分:3)

这是故意的。以XML或SGML标记开头的行是段落分隔符行。如果Emacs以这样的方式打破了段落,使得标记在行的开头结束,fill-paragraph的后续应用程序将停在那一行。这是为了确保,例如,

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

不会变成

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

出于同样的原因,除非在句点之后有两个或更多空格,否则Emacs不会在句点后断行,因为它使用双空格来区分结束句子的句点和结束缩写的句点并且在结束缩写的句号之后打破一行会产生模糊的情况。

答案 1 :(得分:1)

对我来说看起来像个错误。

我能够将你的例子减少到这样:

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

如果我从中删除单个字符的文字,fill-paragraph按预期工作。或者,如果我在两个相继的<b>元素之间添加一个字符。