Keep context implementations with their document models

This commit is contained in:
2026-11-30 18:56:28 +08:00
parent 455a3580d6
commit 66b6910eb1
9 changed files with 110 additions and 106 deletions
+20
View File
@@ -1,5 +1,7 @@
use serde::{Deserialize, Serialize};
use super::contextualize::Contextualize;
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(tag = "kind", content = "data", rename_all = "snake_case")]
pub enum Inline {
@@ -16,3 +18,21 @@ impl From<&str> for RichText {
Self(vec![Inline::Text(value.into())])
}
}
impl Contextualize for RichText {
fn render_context(&self) -> String {
let mut text = String::new();
for item in &self.0 {
match item {
Inline::Text(value) => text.push_str(value),
Inline::Link { label, url } => {
text.push_str(label);
text.push_str(" (");
text.push_str(url);
text.push(')');
}
}
}
text
}
}