11local function parse_yaml (content )
22 local data = {}
3- local key = nil
43 local item = {}
54 local in_details = false
65
@@ -11,10 +10,10 @@ local function parse_yaml(content)
1110 if line_trimmed == " " then
1211 -- Skip empty lines
1312 elseif indent_level == 0 and line_trimmed :match (" ^[%w_-]+:$" ) then
14- if key and next (item ) then
15- data [key ] = item
13+ -- New entry starts, save the previous one if it exists
14+ if next (item ) then
15+ table.insert (data , item )
1616 end
17- key = line_trimmed :gsub (" :$" , " " )
1817 item = {}
1918 in_details = false
2019 elseif indent_level > 0 and line_trimmed :match (" ^title:%s*(.+)" ) then
@@ -37,37 +36,17 @@ local function parse_yaml(content)
3736 end
3837
3938 -- Add the last item
40- if key and next (item ) then
41- data [ key ] = item
39+ if next (item ) then
40+ table.insert ( data , item )
4241 end
4342
4443 return data
4544end
4645
4746local function construct_entry (data )
4847 local typst_code = {}
49-
50- -- Convert table to array if it's a dictionary
51- local entries = {}
52- if data and type (data ) == " table" then
53- -- Check if it's a dictionary (has string keys)
54- local is_dict = false
55- for k , v in pairs (data ) do
56- if type (k ) == " string" then
57- is_dict = true
58- break
59- end
60- end
61-
62- if is_dict then
63- -- Convert dictionary values to array
64- for k , v in pairs (data ) do
65- table.insert (entries , v )
66- end
67- else
68- entries = data
69- end
70- end
48+
49+ local entries = data or {}
7150
7251 for _ , item in ipairs (entries ) do
7352 local entry_parts = {}
0 commit comments