young
(rtSwift)
1
I'm trying to add syntax highlighting to MarkdownUI. This uses Splash.
Adding some sample code and get this compile error:
But TextOutputFormat is from the Standard Library.
bbrk24
2
TextOutputFormat isn’t in the standard library. Can you find some documentation or an article that mentions it, to point us to what you’re looking for?
young
(rtSwift)
3
Nevermind, I search "swift TextOutputFormat" and got TextOutputStream.
So where is TextOutputFormat? Must be something in the Splash package?
Here: TextOutputStream | Apple Developer Documentation
This compile:
import Foundation
struct ASCIILogger: TextOutputStream {
mutating func write(_ string: String) {
let ascii = string.unicodeScalars.lazy.map { scalar in
scalar == "\n"
? "\n"
: scalar.escaped(asASCII: true)
}
print(ascii.joined(separator: ""), terminator: "")
}
}
bbrk24
4
I have no idea what TextOutputFormat you’re talking about. That’s why I asked for a link to an article, to see if the article would make it more clear where it comes from or what was intended.
young
(rtSwift)
5
I found it. It's part of the Demo of MarkdownUI code syntax highlighting using Splash.
Just clone it, there is a Demo app Xcode project. Open it and TextOutputFormat is an implement of protocol Splash.OutputFormat