use uuid::Uuid;
use crate::project::ProjectLayout;
use crate::store::hierarchy::Hierarchy;
use crate::store::NodeKind;
pub(crate) fn chapter_paragraphs_raw(
layout: &ProjectLayout,
h: &Hierarchy,
chapter_id: Uuid,
) -> Vec<String> {
let mut out = Vec::new();
for id in h.collect_subtree(chapter_id) {
let Some(p) = h.get(id) else { continue };
if p.kind != NodeKind::Paragraph {
continue;
}
let Some(rel) = p.file.as_ref() else { continue };
let abs = layout.root.join(rel);
if let Ok(text) = std::fs::read_to_string(&abs) {
out.push(text);
}
}
out
}
pub(crate) fn chapter_raw_prose(
layout: &ProjectLayout,
h: &Hierarchy,
chapter_id: Uuid,
) -> String {
let mut body = String::new();
for p in chapter_paragraphs_raw(layout, h, chapter_id) {
body.push_str(&p);
body.push('\n');
}
body
}