Module escape

Module escape 

Source
Expand description

Some functions to escape character for display in HTML or LaTeX.

The two most useful ones are tex and html.

§Example

use crowbook_text_processing::escape;
let input = "<foo> & <bar>";
let output = escape::html(input);
assert_eq!(&output, "&lt;foo&gt; &amp; &lt;bar&gt;");

let input = "#2: 20%";
let output = escape::tex(input);
assert_eq!(&output, r"\#2: 20\%");

Functions§

html
Escape characters for HTML output, replacing <, >, and & with appropriate HTML entities.
nb_spaces_html
Escape narrow non-breaking spaces for HTML.
nb_spaces_tex
Escape non breaking spaces for LaTeX, replacing them with the appropriate TeX code. This ensures it works correctly with some LaTeX versions (and it makes the non-breaking spaces shenanigans more visible with most editors)
nnbspDeprecated
Old name of nb_spaces html
quotes
Very naively escape quotes
remove_xml_chars
Remove xml 1.0 invalid characters
tex
Escape characters for LaTeX