diff --git a/.github/workflows/docker-image-latest.yml b/.github/workflows/docker-image-latest.yml index ed9fd64..750e3be 100644 --- a/.github/workflows/docker-image-latest.yml +++ b/.github/workflows/docker-image-latest.yml @@ -47,7 +47,7 @@ jobs: --cache-from=type=local,src=/tmp/.buildx-cache \ --cache-to=type=local,dest=/tmp/.buildx-cache,mode=max \ --tag ghcr.io/ximeraproject/ximeralatex:latest \ - --file docker/Dockerfile \ + --file docker/Dockerfile.full \ --push . # - name: Build and Push full Docker image diff --git a/docker/Dockerfile b/docker/Dockerfile index 8f4ce13..8c4a2f2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -123,6 +123,9 @@ RUN tlmgr update --self; \ needspace \ ninecolors + +RUN apt-get install -y mupdf-tools lsof + # make4ht is not in /usr/local/bin if installed with tlmgr!!! ENV PATH="$PATH:/usr/local/texlive/2024/bin/x86_64-linux" diff --git a/docker/Dockerfile.full b/docker/Dockerfile.full index b797d2a..bf772a3 100644 --- a/docker/Dockerfile.full +++ b/docker/Dockerfile.full @@ -18,6 +18,9 @@ RUN apt-get update -y; \ ADD docker/hashcash_1.22-1_amd64.deb . RUN dpkg -i hashcash_1.22-1_amd64.deb +RUN apt-get install -y mupdf-tools lsof + + # Add this complete ximeraLatex repo (is overkill, but allows bugfixing/editing inside the docker image! # It automatically adds the luaxake and xmlatex scripts RUN mkdir -p /root/texmf/tex/latex diff --git a/luaxake/luaxake b/luaxake/luaxake index 7b69351..67176b2 100755 --- a/luaxake/luaxake +++ b/luaxake/luaxake @@ -43,7 +43,8 @@ Options: --compile (default none) Compile sequence (default 'pdf,html', or as set in settings) --settingsfile (default none) Luaxake settings script --configfile (default none) TeX4ht config file --j,--jobs (optional 1..1000) Number of compile jobs to run in parallel +-j,--jobs (optional 1..1000) Number of compile jobs to run in parallel +--img_format (default svg) Either svg or png for image-format in HTML Possible commands: bake @@ -171,6 +172,16 @@ config = { output_format = "html", infix = "draft" , }, + ["htmlexport"] = { -- NEW, TEST + -- command = 'pdflatex -interaction=nonstopmode -file-line-error -shell-escape -jobname @{basename}.handout "\\PassOptionsToClass{handout}{ximera}\\PassOptionsToClass{handout}{xourse}\\input{@{filename}}"', + command = "make4ht -l -c @{configfile} -f html5 -m draft -d build -j @{basename} -s @{make4ht_extraoptions} @{filename} 'svg,htex4ht,mathjax,-css' '' '' '--interaction=nonstopmode -shell-escape -file-line-error'", + check_log = true, -- check log + status = 0, -- check that the latex command return 0 + post_command = 'post_process_html', + extension = "html", + output_format = "html", + infix = "" , + }, ["make4ht.html"] = { command = "make4ht -l -c @{configfile} -f html5+dvisvgm_hashes -j @{basename}.make4ht -s @{make4ht_extraoptions} @{filename} 'svg,htex4ht,mathjax,-css' '' '' '--interaction=nonstopmode -shell-escape -file-line-error'", check_log = true, -- check log @@ -188,7 +199,7 @@ config = { post_command = 'post_process_html', extension = "html", output_format = "html", - infix = "draft" , + infix = "tikz" , }, ["test.html"] = { -- command = "make4ht -f html5+dvisvgm_hashes -c @{configfile} -sm draft @{filename}", @@ -201,7 +212,6 @@ config = { output_format = "html", infix = "make4ht" , }, - -- sage not tested/implemented !!!! ["sagetex.sage"] = { command = "sage @{output_file}", @@ -210,6 +220,20 @@ config = { status = 0, -- check that the latex command return 0 extension = "sage", -- ? }, + ["pdfexport"] = { -- NEW, TEST + -- this doesn't work well + command = 'pdflatex -j @{basename} -interaction=nonstopmode -file-line-error -shell-escape "\\PassOptionsToClass{tikzexport}{ximera}\\PassOptionsToClass{tikzexport}{ximera}\\PassOptionsToClass{tikzexport}{xourse}\\nonstopmode\\input{@{filename}}"', + -- command = 'pdflatex -interaction=nonstopmode -file-line-error -shell-escape "\\PassOptionsToClass{xake}{ximera}\\PassOptionsToClass{xake}{xourse}\\input{@{filename}}"', + check_log = true, -- check log + status = 0, -- check that the latex command return 0 + infix = "" , -- used for .handout, and .make4k4 + extension = "pdf", -- not used ???? + output_format = "pdf",-- the extension of the 'final' output file, that is eg checked for uptodate-ness + post_command = 'post_process_pdf', + download_folder = 'ximera-downloads/pdfexport', + -- post_command = 'post_process_pdf', + -- download_folder = 'ximera-downloads/with-answers', + }, -- a dummy test: create .ddd files that contain the date .. ddd = { command = 'date >@{basename}.ddd', @@ -276,6 +300,7 @@ config = { -- number of lines in tex files where we should look for \documentclass -- dump_fileinfo = "aFirstXourse.tex", jobs = 2, + img_format = "svg", } @@ -326,6 +351,7 @@ config.noclean = args.noclean or os.getenv("XM_NOCLEAN") or co config.nodependencies = args.nodependencies or os.getenv("XM_NODEPENDENCIES") or config.nodependencies config.force = args.force or os.getenv("XM_FORCE") or config.force config.jobs = args.jobs or os.getenv("XM_JOBS") or config.jobs +config.img_format = args.img_format or os.getenv("XM_IMG_FORMAT") or config.img_format if args.configfile ~= "none" then config.configfile = args.configfile @@ -663,4 +689,4 @@ if command == "extrainfo" then log:infof("Potentially duplicate labels:") require 'pl.pretty'.dump(all_labels) end -end \ No newline at end of file +end diff --git a/luaxake/luaxake-files.lua b/luaxake/luaxake-files.lua index f4746d4..cd60794 100644 --- a/luaxake/luaxake-files.lua +++ b/luaxake/luaxake-files.lua @@ -445,7 +445,7 @@ local function update_output_files(metadata, extensions) end metadata.needs_compilation = needs_compilation - log:infof( "Marked source %-12s %-18s for %s", metadata.extension, needs_compilation and 'NEEDS_COMPILATIONS' or 'NO_COMPILATION', metadata.relative_path) + log:debugf( "Marked source %-12s %-18s for %s", metadata.extension, needs_compilation and 'NEEDS_COMPILATIONS' or 'NO_COMPILATION', metadata.relative_path) if metadata.tex_documentclass == "ximera" or metadata.tex_documentclass == "xourse" then diff --git a/luaxake/luaxake-transform-html.lua b/luaxake/luaxake-transform-html.lua index c850d87..4d53546 100644 --- a/luaxake/luaxake-transform-html.lua +++ b/luaxake/luaxake-transform-html.lua @@ -367,13 +367,18 @@ local function get_associated_files(dom, file) ass_files[#ass_files+1] = src - -- local u = url.parse(src) - -- if false and get_extension(u.path) == "svg" - -- then - -- local png = u.path:gsub(".svg$", ".png") - -- log:debug("also adding "..png) - -- ass_files[#ass_files+1] = png - -- end + local u = url.parse(src) + if get_extension(u.path) == "svg" + then + local png = u.path:gsub(".svg$", ".png") + log:debugf("also adding PNG %s", png) + ass_files[#ass_files+1] = png + elseif get_extension(u.path) == "png" + then + local svg = u.path:gsub(".png$", ".svg") + log:debugf("also adding SVG %s", svg) + ass_files[#ass_files+1] = svg + end ::next_image:: end @@ -463,6 +468,18 @@ local function post_process_html(cmd) cmd.error = msg return cmd end + + -- find all elements +for _, img in ipairs(dom:query_selector("img")) do + local src = img:get_attribute("src") + if src then + local pat = file.basename .. "(%d+)x%.svg" + local new = src:gsub(pat, "tikz/"..file.basename.."-figure%1." .. config.img_format) + log:debugf("Set src in %s to %s (from %s).", file.basename, new, src) + + img:set_attribute("src", new) + end +end local ret, msg = update_html_fileinfo(file, dom) -- not really 'post-processing', but implicit checking-of-generated-images diff --git a/xmScripts/xmlatex b/xmScripts/xmlatex index 2a3679d..7ad7b2a 100755 --- a/xmScripts/xmlatex +++ b/xmScripts/xmlatex @@ -223,6 +223,7 @@ if [[ -d .ximera_local ]]; then if [[ -f .ximera_local/xmScripts/xmlatex ]]; then PATH=.ximera_local/xmScripts/:$PATH echo "USING local xmlatex script ($(type xmlatex))" + # THIS CAN NOT POSSIBLY WORK: the script is running already !!! fi fi @@ -843,11 +844,15 @@ then echo "Starting name (from bash script $0)" xake_name ## TODO?: get rid of these combinations, and put them in luaxake ... ? -elif [[ "$COMMAND" == "all" ]] +elif [[ "$COMMAND" == "all" ]] # OPTION USED FOR ADHOC CALCULUS DEPLOYMENT 2025/09/02 then - echo "Starting all (bake/name/frost/serve)" + echo "Starting all (bake pdfexport/bake htmlexport/name/frost/serve; no ximera-downloads)" shift - $LUAXAKE bake $* || error "Problem with 'bake'; Exiting..." + # HACK: split + $LUAXAKE bake --compile pdfexport $* || error "Problem with 'bake'; Exiting..." + $LUAXAKE bake --compile htmlexport $* || error "Problem with 'bake'; Exiting..." + + rm -rf ximera-downloads/* # contains pdfexport versions # git remote show ximera 2>/dev/null || xake_name