From caa4b23d5fc97d49c13df7cd31cf084e0d6ac6b4 Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Tue, 7 Feb 2023 13:54:36 +0100 Subject: [PATCH] Tex export: fix array support --- src/main.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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,