Skip to main content

escape_text

Function escape_text 

Source
pub fn escape_text(s: &str) -> String
Expand description

Escapes text for inclusion in a roff text line.

Neutralises the four sequences a roff processor would otherwise act on: a backslash, a hyphen (which becomes a typographic dash), and a leading period or apostrophe on a line, either of which starts a control line and would silently swallow the rest of it.

ยงExamples

use ssg::cmd::man::escape_text;
assert_eq!(escape_text("a-b"), r"a\-b");
assert_eq!(escape_text("x\n.y"), "x\n\\&.y");