crowbook-text-processing 1.1.1

Provides some utilities functions for escaping text (HTML/LaTeX) and formatting it according to typographic rules (smart quotes, ellipsis, french typograhic rules)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
extern crate crowbook_text_processing;

use crowbook_text_processing::escape;
use crowbook_text_processing::clean;
use crowbook_text_processing::FrenchFormatter;

fn main() {

    let s = " Some  string with  too much   whitespaces & around 1% characters that might cause trouble to HTML or LaTeX.";
    let new_s = clean::whitespaces(s);
    println!("for HTML: {}", escape::html(new_s.clone()));
    println!("for LaTeX: {}", escape::tex(new_s));
    
    let s = " Une chaîne en français ! On voudrait un résultat « typographiquement correct ».";
    let new_s = FrenchFormatter::new().format(s);
    println!("for HTML: {}", escape::nb_spaces_html(escape::html(new_s.clone())));
    println!("for LaTeX: {}", escape::nb_spaces_tex(escape::tex(new_s)));
}