我想將嵌套程度不高的有效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