diff --git a/src/main.rs b/src/main.rs index 85c79f3..9fee0ce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -106,16 +106,20 @@ fn tex_escape_str(s: &str) -> String { .replace('\n', "\\newline\n") } -fn tex_export_inner(tree: &ObjectChild, out: &mut String, required: bool) { - let type_str = match &tree.node.r#type { +fn tex_type_str(t: &TreeNode) -> String { + match &t.r#type { NodeType::Null => "NULL".to_string(), NodeType::Boolean => "bool".to_string(), - NodeType::Array { item } => format!("{}[]", item.name), - NodeType::Object { .. } => tree.node.name.to_string(), + NodeType::Array { item } => format!("{}[]", tex_type_str(&item)), + NodeType::Object { .. } => t.name.to_string(), NodeType::String => "string".to_string(), NodeType::Number => "number".to_string(), NodeType::Integer => "integer".to_string(), - }; + } +} + +fn tex_export_inner(tree: &ObjectChild, out: &mut String, required: bool) { + let type_str = tex_type_str(&tree.node); writeln!( out,