【发布时间】:2017-12-05 09:15:00
【问题描述】:
我正在使用 customfilter 模块为 Drupal 使用 asciidoc 语法为文本创建自定义过滤器。我将它包含在 [asciidoc][/asciidoc] 标签中,当我通过 asciidoctor 命令运行它时,输出包含在 <div class="paragraph"><p> 标签中。
我使用 [asciidoc] 标签格式化 html 链接的输出是这样的。
On the markup side Drupal's contrib `markdown` filter has been somewhat iffy,
and so has the `bbcode` filter. Looking around for other more compact documenting
systems led me to the https://asciidoc.org[Asciidoc] utility and its more
advanced brother https://asciidoctor.org[Asciidoctor]. In combination with another
Drupal module called https://drupal.org/project/customfilter[customfilter] which
makes it easy to create your own filters, I think I have hit on a combination
of modules which allow me as much freedom and fine control on my pages as I want.
<div class="paragraph">
<p>On the markup side Drupal’s contrib <code>markdown</code> filter has been somewhat iffy,
and so has the <code>bbcode</code> filter. Looking around for other more compact documenting
systems led me to the <a href="https://asciidoc.org">Asciidoc</a> utility and its more
advanced brother <a href="https://asciidoctor.org">Asciidoctor</a>. In combination with another
Drupal module called <a href="https://drupal.org/project/customfilter">customfilter</a> which
makes it easy to create your own filters, I think I have hit on a combination
of modules which allow me as much freedom and fine control on my pages as I want.</p>
</div>
是否有一些 PHP 函数可以将字符串 HTML 和一组封闭标签转换为字符串,并返回它们所包含的内部 HTML?或者也许是一些可以匹配标签之间部分的正则表达式?
这是想要的输出
On the markup side Drupal’s contrib <code>markdown</code> filter has been somewhat iffy,
and so has the <code>bbcode</code> filter. Looking around for other more compact documenting
systems led me to the <a href="https://asciidoc.org">Asciidoc</a> utility and its more
advanced brother <a href="https://asciidoctor.org">Asciidoctor</a>. In combination with another
Drupal module called <a href="https://drupal.org/project/customfilter">customfilter</a> which
makes it easy to create your own filters, I think I have hit on a combination
of modules which allow me as much freedom and fine control on my pages as I want.
我问了一个相关问题,是否可以配置 asciidoc 以避免将输出包含在 <div class="paragraph"><p>...</p></div> - Does asciidoctor have a setting to remove the <paragraph> and <p> tags from the source it outputs? 中
【问题讨论】:
-
strip-tags为此目的是错误的。目的是只去除外部标签,因为它们会创建额外的段落。例如,如果我更喜欢使用 asciidoc URL 并在 URL 周围使用[asciidoc]https://asciidoctor.org[Asciidoctor][/asciidoc],过滤器将在 URL 周围创建段落,这会破坏文本的流动。strip-enclosing-tags会更喜欢。
标签: php regex html-content-extraction