3de0275b52
Both when outputting HTML, and when highlighting code blocks within a Markdown text, Splash now fully escapes all required character entities.
25 lines
522 B
Swift
25 lines
522 B
Swift
/**
|
|
* Splash
|
|
* Copyright (c) John Sundell 2019
|
|
* MIT license - see LICENSE.md
|
|
*/
|
|
|
|
import Foundation
|
|
|
|
internal extension StringProtocol {
|
|
func escapingHTMLEntities() -> String {
|
|
return String(flatMap { character -> String in
|
|
switch character {
|
|
case "&":
|
|
return "&"
|
|
case "<":
|
|
return "<"
|
|
case ">":
|
|
return ">"
|
|
default:
|
|
return String(character)
|
|
}
|
|
})
|
|
}
|
|
}
|