diff --git a/src/converter/lx.jl b/src/converter/lx.jl index bd4dd077f..c985603db 100644 --- a/src/converter/lx.jl +++ b/src/converter/lx.jl @@ -57,7 +57,7 @@ JD_LOC_EQDICT_COUNTER Counter to keep track of equation numbers as they appear along the page, this helps with equation referencing. """ -const JD_LOC_EQDICT_COUNTER = randstring(JD_LEN_RANDSTRING+1) +const JD_LOC_EQDICT_COUNTER = "COUNTER_" * randstring(JD_LEN_RANDSTRING) """ $(SIGNATURES) @@ -106,7 +106,6 @@ Given a latex command such as `\\eqref{abc}`, hash the reference (here `abc`), c dictionary `d` has an entry corresponding to that hash and return the appropriate HTML for it. """ function form_href(lxc::LxCom, dname::String; parens="("=>")", class="href")::String - ct = content(lxc.braces[1]) # "r1, r2, r3" refs = strip.(split(ct, ",")) # ["r1", "r2", "r3"] names = refstring.(refs) diff --git a/src/converter/md_blocks.jl b/src/converter/md_blocks.jl index 98bfaad82..526085d09 100644 --- a/src/converter/md_blocks.jl +++ b/src/converter/md_blocks.jl @@ -74,6 +74,7 @@ function convert_mathblock(β::OCBlock, lxdefs::Vector{LxDef})::String # check if there's a label, if there is, add that to the dictionary matched = match(r"\\label{(.*?)}", inner) + if !isnothing(matched) name = refstring(strip(matched.captures[1])) write(htmls, "") diff --git a/src/manager/judoc.jl b/src/manager/judoc.jl index e9c446a49..2dcd5560a 100644 --- a/src/manager/judoc.jl +++ b/src/manager/judoc.jl @@ -10,16 +10,19 @@ Keyword arguments: * `port=8000`: the port to use for the local server (should pick a number between 8000 and 9000) * `single=false`: whether to run a single pass or run continuously * `prerender=false`: whether to pre-render javascript (KaTeX and highlight.js) +* `nomess=false`: suppresses all messages (internal use). """ function serve(; clear::Bool=true, verb::Bool=false, port::Int=8000, single::Bool=false, - prerender::Bool=false)::Union{Nothing,Int} + prerender::Bool=false, nomess::Bool=false)::Union{Nothing,Int} # set the global path JD_FOLDER_PATH[] = pwd() # construct the set of files to watch watched_files = jd_setup(clear=clear) + nomess && (verb = false) + # do a first full pass - println("→ Initial full pass... ") + nomess || println("→ Initial full pass... ") start = time() sig = jd_fullpass(watched_files; clear=clear, verb=verb, prerender=prerender) sig < 0 && return sig @@ -27,7 +30,7 @@ function serve(; clear::Bool=true, verb::Bool=false, port::Int=8000, single::Boo # start the continuous loop if !single - println("→ Starting the server...") + nomess || println("→ Starting the server...") coreloopfun = (cntr, fw) -> jd_loop(cntr, fw, watched_files; clear=clear, verb=verb) # start the liveserver in the current directory LiveServer.setverbose(verb) @@ -91,9 +94,8 @@ function jd_fullpass(watched_files::NamedTuple; clear::Bool=false, verb::Bool=fa pg_foot = read(joinpath(JD_PATHS[:in_html], "page_foot.html"), String) foot = read(joinpath(JD_PATHS[:in_html], "foot.html"), String) - # reset page variables and latex definitions + # reset global page variables and latex definitions def_GLOB_VARS!() - def_LOC_VARS!() def_GLOB_LXDEFS!() # process configuration file @@ -104,27 +106,26 @@ function jd_fullpass(watched_files::NamedTuple; clear::Bool=false, verb::Bool=fa indexhtml = JD_PATHS[:in] => "index.html" # rest of the pages, done asynchronously - tasks = Vector{Task}() + s = 0 @sync begin if isfile(joinpath(indexmd...)) - push!(tasks, @async process_file(:md, indexmd, head, pg_foot, foot; clear=clear, - prerender=prerender)) + s += process_file(:md, indexmd, head, pg_foot, foot; clear=clear, + prerender=prerender) elseif isfile(joinpath(indexhtml...)) - push!(tasks, @async process_file(:html, indexhtml, head, pg_foot, foot; clear=clear, - prerender=prerender)) + s += process_file(:html, indexhtml, head, pg_foot, foot; clear=clear, + prerender=prerender) else @warn "I didn't find an index.[md|html], there should be one. Ignoring." end # process rest of the files for (case, dict) ∈ pairs(watched_files), (fpair, t) ∈ dict occursin("index.", fpair.second) && continue - sleep(0.001) - push!(tasks, @async process_file(case, fpair, head, pg_foot, foot, t; clear=clear, - prerender=prerender)) + s += process_file(case, fpair, head, pg_foot, foot, t; clear=clear, + prerender=prerender) end end # return -1 if any task has failed - return -Int(any(t->t.result < 0, tasks)) + return ifelse(s<0, -1, 0) end diff --git a/src/manager/post_processing.jl b/src/manager/post_processing.jl index b84c80c02..d19e93af6 100644 --- a/src/manager/post_processing.jl +++ b/src/manager/post_processing.jl @@ -29,7 +29,7 @@ function optimize(; prerender::Bool=true, minify::Bool=true, sig::Bool=false)::U print("→ Full pass") withpre = ifelse(prerender, rpad(" (with pre-rendering)", 24), rpad(" (no pre-rendering)", 24)) print(withpre) - succ = (serve(single=true, prerender=prerender) == 0) + succ = (serve(single=true, prerender=prerender, nomess=true) === nothing) time_it_took(start) #