///|
fn xml_text(value : String) -> String {
let safe = String::from_array(
value.to_array().filter(c => c >= ' ' || c == '\n' || c == '\t'),
)
safe
.replace_all(old="&", new="&")
.replace_all(old="<", new="<")
.replace_all(old=">", new=">")
.replace_all(old="\"", new=""")
.replace_all(old="'", new="'")
}
///|
fn svg_rect(x : Int32, y : Int32, width : Int32, fill : String) -> String {
""
}
///|
fn svg_text(
x : Int32,
y : Int32,
label : String,
color : String,
size : Int32,
) -> String {
"" +
xml_text(label) +
""
}
///|
fn svg_edge(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32) -> String {
let middle = (x1 + x2) / 2
""
}
///|
/// Deterministic topic/document overview. Detailed headings remain in HTML/Markdown exports.
pub fn export_svg(atlas : Atlas, title : String) -> String {
let topics : Map[String, Array[Page]] = Map([])
for page in atlas.pages {
if !topics.contains(page.topic) {
topics[page.topic] = []
}
topics[page.topic].push(page)
}
let names = topics.keys().to_array()
names.sort()
let height = 160 + atlas.pages.length() * 68 + names.length() * 24
let root_y = height / 2 + 25
let parts = [
"")
parts.join("\n")
}