Skip to main content

strip_code_with

Function strip_code_with 

Source
pub fn strip_code_with(text: &str, rules: CodeRules) -> String
Expand description

Blank out fenced and inline code under rules.

Every character of code, fence marker lines included, becomes a space, and every \n stays. The output has the same number of characters as the input, so a char index into it is a char index into the input. It is not a byte index: a multi-byte character in code becomes a one-byte space.

§Examples

use markdown_link::code::{CodeRules, strip_code_with};

let blanked = strip_code_with("`é` x", CodeRules::CommonMark);
assert_eq!(blanked, "    x"); // 3 chars of code, now 3 one-byte spaces