换行符在块引号中表现得很奇怪

时间:2012-12-30 作者:TRiG

我正在使用一个普通的最新WordPress安装。我注意到,即使在文本模式下,可视化编辑器也不会显示<p><br> 标记,如果插入它们,则会将其剥离并替换为实际的换行符,但渲染效果似乎仍然正常。我假设标签在那里,但是文本模式编辑器没有显示它们。大概这就是为什么它被称为“文本模式”,而不是“HTML模式”。

然而,在blockquotes中,事情的表现略有不同(在视觉模式和文本模式下)。以下是我的内容(从文本模式复制和粘贴):

<blockquote>C.S. Lewis mistakenly wrote that Susan had turned her back on Narnia, but what it really seems is that Lewis had turned his back on Susan.
<em>Fred Clark (Slacktivist), "<a href="http://www.patheos.com/blogs/slacktivist/2012/08/13/redeeming-susan-pevensie/">Redeeming Susan Pevensie</a>”</em>

One queen said ‘I am not a toy’, and she never returned.
<em>Senan Mcuire, "<a href="http://seananmcguire.com/songbook.php?id=238">Wicked Girls Saving Themselves</a>”</em>

A god who would punish me for liking nylons and parties by making me walk through that school dining room, with the flies, to identify Ed, well . . . he\'s enjoying himself a bit too much, isn\'t he? Like a cat, getting the last ounce of enjoyment out of a mouse.
<em>Neil Gaiman, "The Problem of Susan"</em>
<small><em>I can\'t find this one online legally. If you can (and I know some of Neil Gaiman\'s stuff is legally available online, so it\'s possible), please let me know in the comments.</em></small>

Susan is committing Lewis\'s cardinal sin: getting confused about what is real and what not.
<em>Andrew Rilstone, "<a href="http://www.andrewrilstone.com/2005/11/lipstick-on-my-scholar.html">Lipstick on my Scholar</a>”</em>

[<em>The Last Battle</em> is] definitely the weakest of all the books from a story perspective, because Lewis seems to have abandoned entirely such minor issues as characterization, world-building, plot, and the rest, all to hammer home a series of doctrinal points.
...
[Lewis is] eager to punish his characters and interested in how to do it.
<em>hapax and Kit Whitfield, "<a href="http://slacktivist.typepad.com/slacktivist/2012/07/the-question-of-susan.html">The Question of Susan</a>”</em>

Perhaps a very great problem with Susan is that the man who wrote her and other men who write about her consider her a vapid, egotistical, un-gentle person and assert that she is so without ever feeling the need to justify this characterization on the page, with in-character actions.
...
Denying Narnia can be a method of self-defense against being continually walled off from the outside world of which one may want desperately to be a part.
Narnia, as a place, is deeply hostile to the idea of consent.
<em>Ana Mardoll, "<a href="http://www.anamardoll.com/2012/05/narnia-susan-problems-of.html">Narnia: Susan, Problems of</a>”</em>
<small><em>(See also <a title="Narnia: The Narnia Deconstruction Index Post " href="http://www.anamardoll.com/2011/02/narnia-narnia-deconstruction-index-post.html">Ana Mardoll\'s full Narnia deconstruction index</a>.)</em></small>

He shows beautifully. His telling—when it works it works, but in some cases, you get this weird tug-of-war where Lewis-the-writer shows you a thing and Lewis-the-narrator tells you how to feel about it, and <em>Lewis-the-narrator is flat-out wrong.</em>
<em>Ursula Vernon, "<a href="http://www.redwombatstudio.com/blog/?p=5237">Narnian Apocalyptica</a>”</em>

This time an entire country doesn’t have to suffer for years upon years just to act as a backdrop to some British children’s magic adventure time.
<em>yubishines (repent, harlequin), <a href="http://yubishines.tumblr.com/post/31568643523">Narnia Deconstruction discussion</a></em>

You cannot keep the death-vigil for a god and go unchanged.
<em>Ursula Vernon, "<a href="http://www.redwombatstudio.com/blog/?p=5239">Elegant and Fine</a>”</em>

Susan let her tears fall freely when she and Peter heard the news.
<em>pukingtoreador, "<a href="http://www.fanfiction.net/s/2831948/1/The-Real-Reason">The Real Reason</a>”</em></blockquote>

And, because not everything is necessarily Narnia (or, at least, not directly),

<blockquote>It reminded her of Porphylia and everything she wanted to forget.
<em>Jo Walton, "<a href="http://www.strangehorizons.com/2000/20001023/relentlessly_mundane.shtml">Relentlessly Mundane</a>”</em>

You saved our kingdom and found your self-confidence.
<em>Randall Munroe (xkcd), "<a title="xkcd 693" href="http://xkcd.com/693/">Children\'s Fantasy</a>”</em></blockquote>
在视觉模式编辑器中,这一切都被压缩了。每个报价之间没有中断。在预览中,第一个块引号的行为完全符合我的要求:每个引号的引用直接显示在其下方,没有间隙,然后在下一个引号之前有间隙。美丽的我花了很长时间才弄到这样的结果,我不得不进入文本模式,删除换行符,并将其替换为<br> 标签(当我稍后返回到文本模式时,标签消失了,但显然仍然存在,因为它起作用了)。

这篇文章还没有发表,但在预览中,上面的部分看起来不错。

但今天,我在底部添加了第二个blockquote。我尝试了完全相同的技巧。这一次它不起作用了。

不过,在可视化编辑器中,所有内容都被压缩了。但这一次,在预览中,所有内容都被隔开了。

以下是第一个块引号的摘录,显示了所有正确对齐的内容:需要换行符的地方是单行换行符,需要换行符的地方是双线换行符:

Screenshot of blog preview

下面是另一个屏幕截图,显示第二个blockquote有不需要的换行符:

Screenshot of blog preview

后引号可能是另一天的另一个问题。

2 个回复
SO网友:Milo

br和p标记被剥离并转换为换行符,直到输出帖子内容后才添加。有关wpautop 函数,这就是将这些换行符转换为\\u内容上的br和p标记的原因。但很难说在这种情况下到底发生了什么。我发现在视觉模式下切换并返回换行符更容易,而在需要段落的地方硬返回。

SO网友:Josh

如果这样做更简单,您可以使用TinyMCE Advanced plugin 它会给你一个不删除的选项<p><br> 标签

结束

相关推荐

Similar posts formatting

我正在使用类似的帖子插件http://wordpress.org/extend/plugins/similar-posts/, 我希望类似的帖子显示在同一行,而不是列表。。。如链路1、链路2、链路3、链路4而不是链接1链接2链接3链接4几天前,我在wordpress论坛和插件的官方网站上发布了这篇文章,但仍然没有答案。。。救救我!(我对编码知之甚少,所以请尽量具体,如果你给我代码,请解释每一行的作用,以便我可以学习)谢谢补充信息:我正在使用插件的大部分默认设置,我认为我所做的唯一更改是将其设置为只考虑标签