diff options
Diffstat (limited to 'src/app/markdown.rs')
| -rw-r--r-- | src/app/markdown.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/app/markdown.rs b/src/app/markdown.rs index 1410776..0b5f096 100644 --- a/src/app/markdown.rs +++ b/src/app/markdown.rs @@ -37,7 +37,9 @@ pub fn render(inp: &str) -> Result<String> { format_html(child, &options, &mut message)?; } let message = std::str::from_utf8(&message)?; - let message = markdown_to_html(message, &options); + let mut message = markdown_to_html(message, &options); + crop_letters(&mut message, 3); + message.drain((message.len() - 5)..); let mood = without_first(u.path()); let name = u.host_str().unwrap_or("Mara"); @@ -79,3 +81,14 @@ fn without_first(string: &str) -> &str { .and_then(|(i, _)| string.get(i..)) .unwrap_or("") } + +fn crop_letters(s: &mut String, pos: usize) { + match s.char_indices().nth(pos) { + Some((pos, _)) => { + s.drain(..pos); + } + None => { + s.clear(); + } + } +} |
