A Swift library to convert text with ANSI escape codes to HTML.
The heavy lifting of the conversion is done by the ANSIEsc2HTML library.
This SPM includes a slightly modified version of the library copied on 2023/5/5.
Usages
Direct Usage
You can create a string builder and use the conversion method directly on the builder.
import Ansi2Html
let builder = AnsiHtmlStringBuilder()
if builder.stringHasAnsi(stringWithAnsiCodes) {
let html = builder.stringToHtml(stringWithAnsiCodes)
}
String Extension
It may be more useful to add an extension on string for convenience.
Ansi2Html
A Swift library to convert text with ANSI escape codes to HTML.
The heavy lifting of the conversion is done by the ANSIEsc2HTML library. This SPM includes a slightly modified version of the library copied on 2023/5/5.
Usages
Direct Usage
You can create a string builder and use the conversion method directly on the builder.
String Extension
It may be more useful to add an extension on string for convenience.
Elsewhere in your code you can use the
ansiToHtml
computed attribute.