Skip to main content

render_post_html_to_text

Function render_post_html_to_text 

Source
pub fn render_post_html_to_text(post_html: &str) -> String
Expand description

Renders a hashiverse post body (the HTML subset produced by the web client or by convert_text_to_hashiverse_html) as plain text:

  • <hashtag> → its visible text (#Rust), or #<attr> if it has none
  • <mention client_id="…"> → @<client_id>
  • <br> and block-element boundaries → newlines
  • <a href> → link text, followed by <href> when the two differ
  • <img src> → [image: src]
  • everything else → its text content

Post content comes from arbitrary network peers, so the result is passed through sanitize_for_terminal (covering both text nodes and attribute values).