diff options
| author | Xe Iaso <me@christine.website> | 2023-01-21 15:42:53 -0500 |
|---|---|---|
| committer | Xe Iaso <me@christine.website> | 2023-01-21 15:42:53 -0500 |
| commit | 12d3a86c3976db81929e26ee96afa5ca2ad1c5d6 (patch) | |
| tree | f590d63e0737fca36d0985cae7052b2ce36961f7 /lib/xesite_markdown/src | |
| parent | 16bf3a0f1f1a06c17474467648592ad4025f87c2 (diff) | |
| download | xesite-12d3a86c3976db81929e26ee96afa5ca2ad1c5d6.tar.xz xesite-12d3a86c3976db81929e26ee96afa5ca2ad1c5d6.zip | |
support xedn resizable stickers
Signed-off-by: Xe Iaso <me@christine.website>
Diffstat (limited to 'lib/xesite_markdown/src')
| -rw-r--r-- | lib/xesite_markdown/src/lib.rs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/xesite_markdown/src/lib.rs b/lib/xesite_markdown/src/lib.rs index 941761d..0767c30 100644 --- a/lib/xesite_markdown/src/lib.rs +++ b/lib/xesite_markdown/src/lib.rs @@ -111,16 +111,23 @@ pub fn render(inp: &str) -> Result<String> { .ok_or(Error::MissingElementAttribute("mood".to_string()))?; let name = name.replace("_", " "); - el.before(&format!(r#" + let (size, class) = el + .get_attribute("standalone") + .map_or((64, "conversation-smol"), |_| { + (128, "conversation-standalone") + }); + + el.before( + &format!( + r#" <div class="conversation"> - <div class="conversation-picture conversation-smol"> - <picture> - <source srcset="https://cdn.xeiaso.net/file/christine-static/stickers/{name_lower}/{mood}.avif" type="image/avif"> - <source srcset="https://cdn.xeiaso.net/file/christine-static/stickers/{name_lower}/{mood}.webp" type="image/webp"> - <img src="https://cdn.xeiaso.net/file/christine-static/stickers/{name_lower}/{mood}.png" alt="{name} is {mood}"> - </picture> + <div class="{class}"> + <img src="https://cdn.xeiaso.net/sticker/{name_lower}/{mood}/{size}" alt="{name} is {mood}"> </div> - <div class="conversation-chat"><<b>{name}</b>> "#), ContentType::Html); + <div class="conversation-chat"><<b>{name}</b>> "# + ), + ContentType::Html, + ); el.after("</div></div>", ContentType::Html); el.remove_and_keep_content(); |
