@@ -11,60 +11,40 @@ for in_file in string.gmatch(in_file_string, "([^\n]+)") do
1111 table.insert (in_files , in_file )
1212end
1313
14- -- print("--------------")
15- -- print(">>> PRERENDER")
16- -- print("Files going in:")
17- -- print(in_file_string)
18- -- print("--------------")
19-
2014-- test case: single file (we want to do this for all files!)
2115
2216first_file_name = in_files [1 ]
23-
2417first_file = io.open (first_file_name , " r" )
25- -- print(">>> PRERENDER: CONTENT OF FIRST FILE: " .. first_file_name)
2618first_file_contents = pandoc .read (io.output (first_file ):read (" a" ))
27- -- print(first_file_contents)
2819
2920-- check if there's svelte in the frontmatter
3021
31-
3222svelte_key = first_file_contents .meta [" svelte" ]
3323
3424if (svelte_key ) then
35- -- print("Found a svelte key in the frontmatter")
3625 import_block = " ```{ojs}\n "
3726 for i , item in ipairs (svelte_key ) do
3827 -- TODO - assert item is a pandoc string
3928
4029 item_string = pandoc .utils .stringify (item )
4130 item_js = string.sub (item_string , 1 , string.len (item_string ) - 7 )
42- -- print(" - " .. item_string .. " => " .. item_js .. ".js")
4331
4432 -- write the item out to .sverto/.svelte-imports
4533 import_list_file = io.open (" .sverto/.sverto-imports" , " a" )
4634 io.output (import_list_file ):write (item_string .. " \n " )
47- print (" Added to .sverto/.sverto-imports" )
4835 io.close (import_list_file )
4936
5037 -- add the item to the require block
51- -- print(">>>>>> Next item:")
52- -- print(item_js .. ".js")
5338 import_block = import_block ..
5439 item_js .. " = import(\" /" .. item_js .. " .js\" )\n "
5540
5641 end
5742
5843 -- write the import block out to .sverto/[path]
5944 import_block = import_block .. " ```"
60- -- print("Import block:")
61- -- print(import_block)
62- -- print("Writing out to " .. ".sverto/" .. first_file_name)
6345 import_file = io.open (" .sverto/" .. first_file_name , " w" )
6446 io.output (import_file ):write (import_block .. " \n " )
6547 io.close (import_file )
66- else
67- -- print("No svelte key in " .. first_file_name)
6848end
6949
7050-- write the output dir temporarily
0 commit comments