diff --git a/.gitignore b/.gitignore index 0365b23..65d5bce 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ *_files/ /.luarc.json Emo_think.png +_renderinfo.json +quickanswers.tex diff --git a/_extensions/qquestion/qquestion.lua b/_extensions/qquestion/qquestion.lua index e6764e8..bdde189 100644 --- a/_extensions/qquestion/qquestion.lua +++ b/_extensions/qquestion/qquestion.lua @@ -47,6 +47,7 @@ function init_qnum(renderinfo) for i, v in ipairs(renderinfo.rendr) do if i < renderinfo.currentindex then if v.qcount then + -- if v.qcount > 0 then pout("add counts "..v.qcount) end qnum = qnum + v.qcount end end end @@ -111,7 +112,6 @@ end function Pandoc_doit(doc) - -- pout("the pandoc") if rinfo.ishtml then quarto.doc.add_html_dependency({ @@ -125,8 +125,10 @@ function Pandoc_doit(doc) end if rinfo.ishtmlbook and rinfo.currentindex > 0 then + -- pout ("updating render info with counts "..qcount) rinfo.rendr[rinfo.currentindex].qcount = qcount end; + -- pout ("save rinfo for current index"..rinfo.currentindex) utelz.save_info(rinfo) return(doc) end @@ -136,7 +138,6 @@ return{ { -- first get rendering information Meta = function(meta) rinfo = utelz.Meta_getinfo(meta) - -- pout("now init") init_qnum(rinfo) -- pout("fertig") end diff --git a/_extensions/qquestion/renderinfo.lua b/_extensions/qquestion/renderinfo.lua index d99fe4c..121769f 100644 --- a/_extensions/qquestion/renderinfo.lua +++ b/_extensions/qquestion/renderinfo.lua @@ -32,7 +32,8 @@ SOFTWARE. local str = pandoc.utils.stringify local pout = quarto.log.output -local dumpfile = "_renderinfo.json" +local projectdir = os.getenv("QUARTO_PROJECT_DIR") +local dumpfile = projectdir.."/_renderinfo.json" -- rendering information @@ -53,6 +54,7 @@ local function save_info(renderinfo) local rjson = quarto.json.encode(renderinfo) local file = io.open(dumpfile,"w") if file ~= nil then + -- pout ("dumping render info to "..dumpfile) file:write(rjson) file:close() end @@ -75,7 +77,7 @@ local function update_otherchapinfo(rinfo, newinfo) end end if not OK then - -- pout("there have been changes in chapters. Overwriting information now!") + pout("there have been changes in chapters. Overwriting render information now.") save_info(rinfo) else -- update other information for i, v in ipairs(oldchap) do @@ -85,8 +87,8 @@ local function update_otherchapinfo(rinfo, newinfo) oldchap[i] = newchap[i] end end - -- pout("updated info") - -- pout(rinfo) + -- pout("updated info") + -- pout(rinfo) end end end @@ -95,6 +97,7 @@ local function Meta_projectfiles(meta) local processedfile = pandoc.path.split_extension(PANDOC_STATE.output_file) local rinfo={} local fname="" + local file = "" local ir = 0 local chapno = "" -- pout("here we go") @@ -118,12 +121,14 @@ local function Meta_projectfiles(meta) -- pout("setup chapter "..ir.." file "..str(v.file)) if v.number then chapno = str(v.number) end; -- else chapno = "" end - fname = pandoc.path.split_extension(str(v.file)) + file = str(v.file) + fname = pandoc.path.filename(pandoc.path.split_extension(file)) + -- pout("process "..processedfile.." fname "..fname) if fname == processedfile then rinfo.currentindex = ir end -- rinfo.last = fname -- if rinfo.first == "" then rinfo.first = fname end rinfo.rendr[ir] ={ - file = str(v.file), + file = file, chapno = chapno, fname = fname } @@ -155,8 +160,15 @@ local function Meta_getinfo(meta) rinfo = Meta_projectfiles(meta) -- pout(oldinfo) - if oldinfo then if rinfo.chapternumber then update_otherchapinfo(rinfo, oldinfo) end - else pout ("no old info available") + if oldinfo + then + -- pout("old info found") + if rinfo.chapno -- is chapter + then + -- pout("is chapter "..rinfo.chapno) + update_otherchapinfo(rinfo, oldinfo) + end + -- else pout ("no old chapter info available ") end return(rinfo) end