Prefer user-provided node summary if it exists

This commit is contained in:
Juno Takano 2026-01-11 17:32:14 -03:00
commit ccee6b2500

View file

@ -73,20 +73,31 @@ fn modulate_nodes(graph: &Graph) -> HashMap<String, Node> {
node.title.clone() node.title.clone()
}; };
let mut summary = if let Some(summary) = node.text.lines().next() { // Populate empty summaries with the leading part of the node text
if let Some(sentence) = node.text.split_once('.') { let summary = if node.summary.is_empty() {
format!("{}.", sentence.0) let first_line = if let Some(first) =
node.text.lines().find(|s| !s.is_empty())
{
String::from(first)
} else { } else {
String::from(summary) node.text.clone()
} };
} else {
node.text.clone()
};
if summary.len() > 300 { let mut candidate =
summary.truncate(300); if let Some(dot_split) = first_line.split_once('.') {
summary.push('…'); format!("{}.", dot_split.0)
} } else {
first_line
};
if candidate.len() > 300 {
candidate.truncate(300);
candidate.push('…');
}
candidate
} else {
node.summary.clone()
};
let new_node = Node { let new_node = Node {
id: key.clone(), id: key.clone(),