@@ -66,16 +66,14 @@ local preprocess_qmd_filter = {
6666 " import%_svelte%(\" ([%w;,/%?:@&=%+%$%-_%.!~%*'%(%)#]+)%.svelte\" %)"
6767
6868 local block_text = block .text
69-
70- print ( " >>> OJS block found... " )
71- print ( block_text )
69+
70+ -- get the qmd_path from disk
71+ local current_qmd_path = read_file ( " .sverto/.sverto-current-qmd-folder " )
7272
7373 -- first, extract .svelte paths in import_svelte() statements
7474 for svelte_path in block_text :gmatch (svelte_import_syntax ) do
75- print (" Svelte file found..." )
76- print (svelte_path )
77- -- table.insert(svelte_files, svelte_path .. ".svelte")
78- append_to_file (" .sverto/.sverto-imports" , svelte_path .. " .svelte\n " )
75+ append_to_file (" .sverto/.sverto-imports" ,
76+ current_qmd_path .. svelte_path .. " .svelte\n " )
7977 end
8078
8179 -- now change `import_svelte("X.svelte")` refs to `import("X.js")`
@@ -117,20 +115,16 @@ end
117115-- (write the identified .svelte files out to a file too!)
118116for key , qmd_path in ipairs (in_files ) do
119117
120- -- print(">>> CREATING IMPORT FOR " .. qmd_path)
121118 local doc = pandoc .read (read_file (qmd_path ))
119+
120+ -- store the current qmd_path on disk so the filter can access it
121+ write_file (" .sverto/.sverto-current-qmd-folder" , path_dir (qmd_path ))
122122
123123 -- pre-process the qmd, populating `svelte_files` in the process
124124 -- local svelte_files = {}
125125 local transformed_doc = doc :walk (preprocess_qmd_filter )
126126 create_dir_recursively (" .sverto/" .. path_dir (qmd_path ))
127127 write_file (" .sverto/" .. qmd_path , pandoc .write (transformed_doc , " markdown" ))
128-
129- -- write the svelte_files out to .sverto-imports
130- -- svelte_file_text = table.concat(svelte_files, "\n")
131- -- print("Saving Svelte imports:")
132- -- print(svelte_file_text)
133- -- write_file(".sverto/.sverto-imports", svelte_file_text)
134128
135129end
136130
0 commit comments