Remove toString from Node as it seems to be causing issues on Linux
This commit is contained in:
parent
37de23e94d
commit
3a6c7657b1
|
@ -50,15 +50,6 @@ public class Comment: Node {
|
|||
|
||||
override func outerHtmlTail(_ accum: StringBuilder, _ depth: Int, _ out: OutputSettings) {}
|
||||
|
||||
public override func toString() -> String {
|
||||
do {
|
||||
return try
|
||||
outerHtml()
|
||||
} catch {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
public override func copy(with zone: NSZone? = nil) -> Any {
|
||||
let clone = Comment(attributes!.get(key: Comment.COMMENT_KEY), baseUri!)
|
||||
return copy(clone: clone)
|
||||
|
|
|
@ -58,10 +58,6 @@ open class DataNode: Node {
|
|||
|
||||
override func outerHtmlTail(_ accum: StringBuilder, _ depth: Int, _ out: OutputSettings) {}
|
||||
|
||||
open override func toString()throws->String {
|
||||
return try outerHtml()
|
||||
}
|
||||
|
||||
/**
|
||||
Create a new DataNode from HTML encoded data.
|
||||
@param encodedData encoded data
|
||||
|
|
|
@ -1244,10 +1244,6 @@ open class Element: Node {
|
|||
return self
|
||||
}
|
||||
|
||||
open override func toString()throws->String {
|
||||
return try outerHtml()
|
||||
}
|
||||
|
||||
public override func copy(with zone: NSZone? = nil) -> Any {
|
||||
let clone = Element(_tag, baseUri!, attributes!)
|
||||
return copy(clone: clone)
|
||||
|
|
|
@ -646,10 +646,6 @@ open class Node: Equatable, Hashable {
|
|||
return appendable
|
||||
}
|
||||
|
||||
open func toString()throws->String {
|
||||
return try outerHtml()
|
||||
}
|
||||
|
||||
public func indent(_ accum: StringBuilder, _ depth: Int, _ out: OutputSettings) {
|
||||
accum.append("\n").append(StringUtil.padding(depth * Int(out.indentAmount())))
|
||||
}
|
||||
|
@ -785,7 +781,7 @@ open class Node: Equatable, Hashable {
|
|||
extension Node : CustomStringConvertible {
|
||||
public var description: String {
|
||||
do {
|
||||
return try toString()
|
||||
return try outerHtml()
|
||||
} catch {
|
||||
|
||||
}
|
||||
|
@ -796,7 +792,7 @@ extension Node : CustomStringConvertible {
|
|||
extension Node : CustomDebugStringConvertible {
|
||||
public var debugDescription: String {
|
||||
do {
|
||||
return try String(describing: type(of: self)) + " " + toString()
|
||||
return try String(describing: type(of: self)) + " " + outerHtml()
|
||||
} catch {
|
||||
|
||||
}
|
||||
|
|
|
@ -118,10 +118,6 @@ open class TextNode: Node {
|
|||
override func outerHtmlTail(_ accum: StringBuilder, _ depth: Int, _ out: OutputSettings) {
|
||||
}
|
||||
|
||||
open override func toString()throws->String {
|
||||
return try outerHtml()
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new TextNode from HTML encoded (aka escaped) data.
|
||||
* @param encodedText Text containing encoded HTML (e.g. <)
|
||||
|
|
|
@ -63,13 +63,6 @@ public class XmlDeclaration: Node {
|
|||
|
||||
override func outerHtmlTail(_ accum: StringBuilder, _ depth: Int, _ out: OutputSettings) {}
|
||||
|
||||
public override func toString() -> String {
|
||||
do {
|
||||
return try outerHtml()
|
||||
} catch {}
|
||||
return ""
|
||||
}
|
||||
|
||||
public override func copy(with zone: NSZone? = nil) -> Any {
|
||||
let clone = XmlDeclaration(_name, baseUri!, isProcessingInstruction)
|
||||
return copy(clone: clone)
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
8C19C8321DB7ECB700B8FC22 /* ParseErrorList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParseErrorList.swift; sourceTree = "<group>"; };
|
||||
8C246B521DD7396200B31DA7 /* OrderedSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderedSet.swift; sourceTree = "<group>"; };
|
||||
8C3617C01DBAC2AE00E00CFE /* Selector.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Selector.swift; sourceTree = "<group>"; };
|
||||
8C55AE181E2904BB00DF7A9F /* CleanerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CleanerTest.swift; sourceTree = "<group>"; };
|
||||
8C55AE181E2904BB00DF7A9F /* CleanerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CleanerTest.swift; path = SwiftSoupTests/CleanerTest.swift; sourceTree = "<group>"; };
|
||||
8C6239C11DBE76D40024F42D /* TreeBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TreeBuilder.swift; sourceTree = "<group>"; };
|
||||
8C6239C31DBE90740024F42D /* HtmlTreeBuilderState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HtmlTreeBuilderState.swift; sourceTree = "<group>"; };
|
||||
8C6239C51DBE910B0024F42D /* HtmlTreeBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HtmlTreeBuilder.swift; sourceTree = "<group>"; };
|
||||
|
|
|
@ -235,7 +235,7 @@ class DocumentTest: XCTestCase {
|
|||
}
|
||||
|
||||
let htmlCharsetUTF8: String = "<html>\n" + " <head>\n" + " <meta charset=\"" + "UTF-8" + "\">\n" + " </head>\n" + " <body></body>\n" + "</html>"
|
||||
XCTAssertEqual(htmlCharsetUTF8, try! doc.toString())
|
||||
XCTAssertEqual(htmlCharsetUTF8, try! doc.outerHtml())
|
||||
|
||||
let selectedElement: Element = try! doc.select("meta[charset]").first()!
|
||||
XCTAssertEqual(DocumentTest.charsetUtf8, doc.charset())
|
||||
|
@ -255,7 +255,7 @@ class DocumentTest: XCTestCase {
|
|||
" </head>\n" +
|
||||
" <body></body>\n" +
|
||||
"</html>"
|
||||
XCTAssertEqual(htmlCharsetISO, try doc.toString())
|
||||
XCTAssertEqual(htmlCharsetISO, try doc.outerHtml())
|
||||
|
||||
let selectedElement: Element = try doc.select("meta[charset]").first()!
|
||||
XCTAssertEqual(String.Encoding.isoLatin2.displayName(), doc.charset().displayName())
|
||||
|
@ -276,7 +276,7 @@ class DocumentTest: XCTestCase {
|
|||
" </head>\n" +
|
||||
" <body></body>\n" +
|
||||
"</html>"
|
||||
try XCTAssertEqual(htmlCharsetUTF8, docNoCharset.toString())
|
||||
try XCTAssertEqual(htmlCharsetUTF8, docNoCharset.outerHtml())
|
||||
}
|
||||
|
||||
func testMetaCharsetUpdateDisabled()throws {
|
||||
|
@ -286,7 +286,7 @@ class DocumentTest: XCTestCase {
|
|||
" <head></head>\n" +
|
||||
" <body></body>\n" +
|
||||
"</html>"
|
||||
try XCTAssertEqual(htmlNoCharset, docDisabled.toString())
|
||||
try XCTAssertEqual(htmlNoCharset, docDisabled.outerHtml())
|
||||
try XCTAssertNil(docDisabled.select("meta[charset]").first())
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,7 @@ class DocumentTest: XCTestCase {
|
|||
" </head>\n" +
|
||||
" <body></body>\n" +
|
||||
"</html>"
|
||||
try XCTAssertEqual(htmlCharset, doc.toString())
|
||||
try XCTAssertEqual(htmlCharset, doc.outerHtml())
|
||||
|
||||
var selectedElement: Element = try doc.select("meta[charset]").first()!
|
||||
XCTAssertNotNil(selectedElement)
|
||||
|
@ -332,7 +332,7 @@ class DocumentTest: XCTestCase {
|
|||
" <body></body>\n" +
|
||||
"</html>"
|
||||
|
||||
try XCTAssertEqual(htmlCharsetUTF8, doc.toString())
|
||||
try XCTAssertEqual(htmlCharsetUTF8, doc.outerHtml())
|
||||
}
|
||||
|
||||
func testMetaCharsetUpdateXmlUtf8()throws {
|
||||
|
@ -344,7 +344,7 @@ class DocumentTest: XCTestCase {
|
|||
"<root>\n" +
|
||||
" node\n" +
|
||||
"</root>"
|
||||
try XCTAssertEqual(xmlCharsetUTF8, doc.toString())
|
||||
try XCTAssertEqual(xmlCharsetUTF8, doc.outerHtml())
|
||||
|
||||
let selectedNode: XmlDeclaration = doc.childNode(0) as! XmlDeclaration
|
||||
XCTAssertEqual(String.Encoding.utf8.displayName(), doc.charset().displayName())
|
||||
|
@ -361,7 +361,7 @@ class DocumentTest: XCTestCase {
|
|||
"<root>\n" +
|
||||
" node\n" +
|
||||
"</root>"
|
||||
try XCTAssertEqual(xmlCharsetISO, doc.toString())
|
||||
try XCTAssertEqual(xmlCharsetISO, doc.outerHtml())
|
||||
|
||||
let selectedNode: XmlDeclaration = doc.childNode(0) as! XmlDeclaration
|
||||
XCTAssertEqual(String.Encoding.iso2022JP.displayName(), doc.charset().displayName())
|
||||
|
@ -378,7 +378,7 @@ class DocumentTest: XCTestCase {
|
|||
"<root>\n" +
|
||||
" node\n" +
|
||||
"</root>"
|
||||
try XCTAssertEqual(xmlCharsetUTF8, doc.toString())
|
||||
try XCTAssertEqual(xmlCharsetUTF8, doc.outerHtml())
|
||||
|
||||
let selectedNode: XmlDeclaration = doc.childNode(0) as! XmlDeclaration
|
||||
try XCTAssertEqual(String.Encoding.utf8.displayName(), selectedNode.attr("encoding"))
|
||||
|
@ -390,7 +390,7 @@ class DocumentTest: XCTestCase {
|
|||
let xmlNoCharset = "<root>\n" +
|
||||
" node\n" +
|
||||
"</root>"
|
||||
try XCTAssertEqual(xmlNoCharset, doc.toString())
|
||||
try XCTAssertEqual(xmlNoCharset, doc.outerHtml())
|
||||
}
|
||||
|
||||
func testMetaCharsetUpdateXmlDisabledNoChanges()throws {
|
||||
|
@ -400,7 +400,7 @@ class DocumentTest: XCTestCase {
|
|||
"<root>\n" +
|
||||
" node\n" +
|
||||
"</root>"
|
||||
try XCTAssertEqual(xmlCharset, doc.toString())
|
||||
try XCTAssertEqual(xmlCharset, doc.outerHtml())
|
||||
|
||||
let selectedNode: XmlDeclaration = doc.childNode(0) as! XmlDeclaration
|
||||
try XCTAssertEqual("dontTouch", selectedNode.attr("encoding"))
|
||||
|
|
|
@ -573,10 +573,10 @@ class ElementTest: XCTestCase {
|
|||
func testpParentlessToString()throws {
|
||||
let doc: Document = try SwiftSoup.parse("<img src='foo'>")
|
||||
let img: Element = try doc.select("img").first()!
|
||||
XCTAssertEqual("<img src=\"foo\">", try img.toString())
|
||||
XCTAssertEqual("<img src=\"foo\">", try img.outerHtml())
|
||||
|
||||
try img.remove() // lost its parent
|
||||
XCTAssertEqual("<img src=\"foo\">", try img.toString())
|
||||
XCTAssertEqual("<img src=\"foo\">", try img.outerHtml())
|
||||
}
|
||||
|
||||
func testClone()throws {
|
||||
|
@ -906,7 +906,7 @@ class ElementTest: XCTestCase {
|
|||
|
||||
try body.insertChildren(0, toMove)
|
||||
|
||||
let result: String = try doc.toString().replaceAll(of: "\\s+", with: "")
|
||||
let result: String = try doc.outerHtml().replaceAll(of: "\\s+", with: "")
|
||||
XCTAssertEqual("<body><div3>Check</div3><div4></div4><div1></div1><div2></div2></body>", result)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue