我想将嵌套程度不高的有效HTML转换为具有更多受限制规则的另一个HTML。在Haskell中转换HTML
仅下列标签支持HTML结果:
<b></b>, <strong></strong>, <i></i>, <em></em>, <a
href="URL"></a>, <code></code>, <pre></pre>
嵌套的标签是不允许的。
对于其余的标签及其组合,我必须创建一些规则来处理每个标签。 所以我要像转换:因为<code>
嵌套在<a>
等
<p>text</p>
成简单的字符串text
与断行,
<b>text <a href="url">link</a> text</b>
到text link text
<a href="url">text<code> code here</code></a>
到<a href="url">text code here</a>
。
例如HTML(换行符仅用于方便):
<p>long paragraph <a href="url">link</a> </p>
<p>another text <pre><code>my code block</code></pre> the rest of description</p>
<p><code>inline monospaced text with <a href="url">link</a></code></p>
应转变为:
long paragraph <a href="url">link</a>
another text <code>my code block</code> the rest of description
<code>inline monospaced text with link</code>
任何建议来解决,该方法是什么?
感谢向我们展示你发现了什么。 – ErikR