You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(the answer of issue #26 cannot solve my problem)
Hi, when I use parse() method to parse a html file, and then write the dom outer html to a new file, it will contain wrong spaces. For example, in the raw html, it has: <div><p>a<p></div>
but in outerHtml():
<div>
<p>
a
</p>
</div>
in this case, the position of 'a' change when render the html page.
Is there any method or solution to solve this problem?
The text was updated successfully, but these errors were encountered:
func testABC()throws{
let doc: Document = Document("")
let div = try doc.appendElement("div")
let p = try div.appendElement("p")
try p.appendText("abc")
let text = try doc.outerHtml()
//Result: "<div>\n <p>abc</p>\n</div>"
}
if you need output "<div><p>abc</p></div>", you need to remove the pretty setting:
func testABC()throws{
let doc: Document = Document("<div><p>a<p></div>")
let div = try doc.appendElement("div")
let p = try div.appendElement("p")
try p.appendText("abc")
doc.outputSettings().prettyPrint(pretty: false)
let text = try doc.outerHtml()
//"<div><p>abc</p></div>"
}
(the answer of issue #26 cannot solve my problem)
Hi, when I use parse() method to parse a html file, and then write the dom outer html to a new file, it will contain wrong spaces. For example, in the raw html, it has:
<div><p>a<p></div>
but in outerHtml():
in this case, the position of 'a' change when render the html page.
Is there any method or solution to solve this problem?
The text was updated successfully, but these errors were encountered: