M Cargo.lock => Cargo.lock +1 -1
@@ 4,7 4,7 @@ version = 3
[[package]]
name = "flatiron"
-version = "1.0.0"
+version = "1.0.1"
dependencies = [
"nom",
]
M Cargo.toml => Cargo.toml +1 -1
@@ 1,6 1,6 @@
[package]
name = "flatiron"
-version = "1.0.0"
+version = "1.0.1"
edition = "2021"
description = "A parser and HTML renderer for the Textile markup language"
license-file = "LICENSE.textile"
M src/lib.rs => src/lib.rs +16 -2
@@ 10,7 10,7 @@ mod structs;
/// Convert a textile String to HTML.
///
-/// ## Example
+/// ## Example
///
/// ```
/// use flatiron::convert;
@@ 23,5 23,19 @@ mod structs;
/// ```
pub fn convert(input: String) -> String {
let (_, textile) = complete(parse::textile)(&input).unwrap();
- format!("{}", textile)
+ escape_unicode(format!("{}", textile))
+}
+
+fn escape_unicode(input: String) -> String {
+ input
+ .chars()
+ .into_iter()
+ .map(|c| {
+ if !c.is_ascii() {
+ format!("&#{};", u32::from(c))
+ } else {
+ String::from(c)
+ }
+ })
+ .collect()
}