【问题标题】:Omitting surrounding <p> being generated from HAML省略从 HAML 生成的周围 <p>
【发布时间】:2012-09-07 03:55:49
【问题描述】:

已经得到以下HAML代码,结合Markdown:

%h2.slogan.align-center
  :markdown
    No more big words. Enough of the abbreviations.  
    **Project management for the rest of us.**

生成 HTML:

<h2 class='slogan align-center'>
  <p>No more big words. Enough of the abbreviations.<br/>
  <strong>Project management for the rest of us.</strong></p>
</h2>

我希望 HTML 看起来像(省略周围的 &lt;p&gt; 标签):

<h2 class='slogan align-center'>
  No more big words. Enough of the abbreviations.<br/>
  <strong>Project management for the rest of us.</strong>
</h2>

创建该 HTML 的 HAML/Markdown 是什么?

【问题讨论】:

  • 如果您有多个段落块怎么办。您要全部删除吗?
  • 我不会有超过一个段落块
  • @cole-johnson 谢谢,我将如何将正则表达式与 HAML 和 Markdown 一起使用?
  • 你不想你永远不想为此使用正则表达式。

标签: html haml markdown


【解决方案1】:

嗯,只用haml很容易:

%h2.slogan.align-center
  No more big words. Enough of the abbreviations.
  %br/
  %strong Project management for the rest of us.

好像haml的markdown插件加了p标签。根据documentation,这是通过使用 4 个不同的降价处理器之一来完成的。我想结果可能会有所不同,具体取决于您使用的是哪一个。

【讨论】:

  • Tack @froderik,是的,我希望转向“用于标记内容的降价;用于页面布局的 haml”。我想我正在使用rdiscount gem。
  • 我认为 haml 也可以很好地用于内容,而不是将两者混合使用。如果是 erb,我会一直和你在一起。