templates/mara.rs.html: make smol smoller

Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
Cadey Ratio 2021-04-02 22:28:18 -04:00
parent de4256c06f
commit 0b32b1da1c
2 changed files with 15 additions and 2 deletions

View File

@ -37,7 +37,9 @@ pub fn render(inp: &str) -> Result<String> {
format_html(child, &options, &mut message)?; format_html(child, &options, &mut message)?;
} }
let message = std::str::from_utf8(&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 mood = without_first(u.path());
let name = u.host_str().unwrap_or("Mara"); let name = u.host_str().unwrap_or("Mara");
@ -79,3 +81,14 @@ fn without_first(string: &str) -> &str {
.and_then(|(i, _)| string.get(i..)) .and_then(|(i, _)| string.get(i..))
.unwrap_or("") .unwrap_or("")
} }
fn crop_letters(s: &mut String, pos: usize) {
match s.char_indices().nth(pos) {
Some((pos, _)) => {
s.drain(..pos);
}
None => {
s.clear();
}
}
}

View File

@ -8,7 +8,7 @@
</picture> </picture>
</div> </div>
@if smol { @if smol {
<div class="conversation-chat"><b>&lt;@character&gt;</b> @message</div> <div class="conversation-chat">&lt;<b>@character</b>&gt; @message</div>
} else { } else {
<div> <div>
<p> <p>