to_plain_text

Function to_plain_text 

Source
pub fn to_plain_text(markdown: &str) -> String
Expand description

Extract plain text from markdown content.

Strips all markdown syntax, returning only text that would be visible when rendered. This is useful for:

  • Search indexing: Index only searchable text
  • Accessibility: Screen reader text extraction
  • Word counts: Accurate content word counts
  • Diffs: Compare semantic content, not syntax

§Elements stripped

MarkdownPlain Text
[text](url)text
![alt](url)alt
[[Page]]Page
[[Page|Display]]Display
**bold**bold
*italic*italic
`code`code
~~strike~~strike
# HeadingHeading
> quote(quote content)
Code fences(content preserved)

§Example

use turbovault_parser::to_plain_text;

let plain = to_plain_text("[Overview](#overview) and **bold**");
assert_eq!(plain, "Overview and bold");

// Wikilinks are handled properly
let plain = to_plain_text("See [[Note]] and [[Other|display]]");
assert_eq!(plain, "See Note and display");