ideasoncanvas / ashton Goto Github PK
View Code? Open in Web Editor NEWConverts NSAttributedStrings into HTML (and back)
License: MIT License
Converts NSAttributedStrings into HTML (and back)
License: MIT License
… if we are affected from https://twitter.com/pieteromvlee/status/1329851164356190210?s=21
Thank your for this amazing API.
Could you please add support for ".lineHeightMultiple" it's a part of ( NSMutableParagraphStyle key )
To adjust line height
Parsing an unknown font returns and AttributedString with a fallback font. Roundtripping overrides the unknown font in the html.
Please add a cocoapods spec for easier integration into projects
Hi,
Please support installation via cocoapods, this method can solve the compatibility problem of m1 chip. Thank you.
Thanks for the update, could you please update the pod spec for Cocoapods integration?
If there a way to include an Image in the NSAttributedText to be converted to HTML?
Thanks
Could we tag the recent commits on master as a release or is there some reason against it?
From my test using Ashton on ios 5.x it crashes with EXC_BAD_ACCESS because you're using NSAttributedString constants from iOS 6: https://github.com/pinguet62/SMSToXMPPiOSApp/blob/master/Frameworks/UIKit.framework/Headers/NSAttributedString.h
I only use the html to NSAttributedString for iOS and I've fixed the area where my app crashed: https://github.com/cristianbica/Ashton
So either you're going to modify the podspec compatibility for iOS to version 6 or we're going to implement support for iOS 5 also.
Can I with Ashton make header support?
I see there is no ashton intermediate header representations.
If i read <b>Wow!</b> Now <em>iOS</em> can create <h3>NSAttributedString</h3> from HTMLs!
markdown output would be "**Wow**! Now *iOS* can create\n\n**NSAttributedString**\n\nfrom HTMLs!\n\n"
but it will be cool if output can be the same as input string.
Sorry, I'm not quite understand how attributedString work yet.
Thanks.
You can convert html String
to NSAttributedString
the native way like this:
let htmlString = "some html string"
guard let data = htmlString.data(using: String.Encoding.utf16, allowLossyConversion: false) else {
return nil
}
guard let attributedString = try? NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding: String.Encoding.utf8.rawValue], documentAttributes: nil) else {
return nil
}
let attributedString = NSAttributedString(attributedString: attributedString)
Have you done any benchmark of Ashton vs this method?
Ashton currently ignores characters like \u000d \u0009 \u000c \u0085 \u2028 \u2029 and leaves them in the output. This can cause issues when displaying the string in a web browser as the web browser will ignore the line separator or paragraph separator character. The correct solution would be to for example replace them with
/Ashton/Sources/Ashton/AshtonXMLParser.swift:17:35: Using 'class' keyword for protocol inheritance is deprecated; use 'AnyObject' instead
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.