scinfu/SwiftSoup

How to get text from element without whitespace normalization and trimmed

dhanrajbhandari opened this issue ยท 3 comments

Currently, element.text() method gives trimmed and whitespace normalised text.
Any other way to get element text without trimmed and whitespace normalised?

Look like in my case. I have filtered TextNode and get original text

node.children()
                    .filter {
                        $0.hasText()
                    }
                    .compactMap {
                        print("๐Ÿš€๐Ÿš€๐Ÿš€")
                        print($0.ownText())
                    }

@thanhdiqit good except delete hasText() as this reintroduces the behavior OP doesn't want (check the source code - it will exclude whitespace text nodes)

Is there any option to disable trimming whitespaces?