-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
textContent strips <br/>s #32
Comments
Actually a better question would be: how do I get HTMLKit to behave just like |
@guidedways NSAttributedString
In order for Plain Text
This is a much more complex topic than you would initially realise. The same with you other issue #31 Strictly speaking, the plain text variant of
However HTML parsing is very lenient and even the most corrupt/invalid/unknown HTML would still produce a DOM tree that is more or less usable. Hence an input like this:
would produce this:
Notice how the email Now let's take a look at another example, say the input is:
What would the What I am trying to say is: If you could provide a universally valid definition to HTML standard specifies one such definition and it is implemented via the ...All this to say, I don't have a solution for this issue and still not completely sure how to solve #31 in a general way. I'll let you know when I come to a conclusion. |
@iabudiab sorry old here, but i'm new to the class :) i'm agree with your point on the strategy or the aglo to switch html element to plain text, obviously with a basic styling html string, the main issue for using here is |
@Jcragons 👋 hey there. Let me see if I understood correctly. You want an option to be able to specify how some tags should be replaced when retrieving the textContent of a node, correct? i.e. something like let element: HTMLElement = HTMLElement(tagName: "div")
element.innerHTML = "Hello<br/>World"
let text = element.textContent(withCustomRules: ["br": " "])
// text: Hello World I guess this shouldn't be hard to implement. However, I won't promise anything about an ETA 😉 |
@iabudiabA yeah exactly that :) no pressure for ETA, I know :) anyway I think it could be a nice addition, a lot of people use an old class in Php just because there is this feature. I'm sure it could help a lot here :) |
output:
desired:
At leas this is how
NSAttributedString
'sinitWithHTML
works. Anything I need to do to get this to work properly?The text was updated successfully, but these errors were encountered: