-
Notifications
You must be signed in to change notification settings - Fork 333
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
[Legacy API] toAttributedString() adding trailing newline via toHTML()
#219
Comments
It seems like your NSAttributedStringTests even expect the trailing newline to be added. Is this intended behavior?
|
toHTML()
Hi @gsbernstein 👋 I would likely switch to using the attributed string styler API (which is background thread safe as well) rather than that legacy API which does indeed use See #177 and examples in the test suite, e.g. https://github.com/iwasrobbed/Down/blob/master/Tests/Styler/StylerTestSuite.swift#L64 |
Thanks Rob! Does that API support using a stylesheet? Our current full code looks like this
And I'm not sure if DownStylerConfiguration lets you do all of that (or how to translate it) |
@gsbernstein unfortunately no it currently does not support using a stylesheet. |
No style sheets, but you could set general styles like John does here https://github.com/iwasrobbed/Down/blob/master/Tests/Styler/StylerTestSuite.swift#L90 If you need more custom styling, you could also fork the repo and add it in (such as your |
This is quite old thread, but since I needed to render Markdown + superscripts and subscripts, which are HTML, I ended up using @iwasrobbed-ks, is there any better way to support both Markdown and HTML than allowing unsafe and rendering as attributedString? |
@o15a3d4l11s2 I'm curious why you wouldn't just use an attributed string transform for sub/superscript instead of opting into HTML? E.g. https://github.com/Flinesoft/HandyUIKit/blob/3353856a1d50df5ffd370ded078c1a21ffb18a68/Frameworks/HandyUIKit/Extensions/NSAttributedStringExt.swift#L55 Otherwise, no, handling any sort of HTML requires switching into unsafe mode since HTML code isn't safe for raw rendering without opening up your app to various scripting attacks |
@iwasrobbed-ks, thanks for the fast response and the suggested alternative. I have external constraints, so I need to support |
Please help prevent duplicate issues before submitting a new one:
Report
What did you do?
Example code:
What did you expect to happen?
attributedString.string == "test"
What happened instead?
attributedString.string == "test\n"
Seems like internally
toAttributedString()
usestoHTML()
, andtoHTML()
is the one adding the newline.The text was updated successfully, but these errors were encountered: