Module crowbook_text_processing::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, "<foo> & <bar>");
let input = "#2: 20%";
let output = escape::tex(input);
assert_eq!(&output, r"\#2: 20\%");
Functions
- Escape characters for HTML output, replacing
<
,>
, and&
with appropriate HTML entities. - Escape narrow non-breaking spaces for HTML.
- 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)
- nnbspDeprecatedOld name of nb_spaces html
- Very naively escape quotes
- Remove xml 1.0 invalid characters
- Escape characters for LaTeX