From bf4263a81bc27c02a663ddd875de055691afabda Mon Sep 17 00:00:00 2001
From: Thibaut Lienart
Date: Wed, 20 Nov 2019 13:58:37 +0100
Subject: [PATCH] Minorfixes (#298)
---
Project.toml | 4 +-
src/JuDoc.jl | 33 ++++--------
src/converter/html.jl | 4 +-
src/converter/lx.jl | 2 +-
src/converter/lx_simple.jl | 2 +-
src/converter/md.jl | 6 ++-
src/converter/md_blocks.jl | 14 +++---
src/manager/file_utils.jl | 12 ++---
src/manager/judoc.jl | 10 ++--
src/manager/post_processing.jl | 14 ++++--
src/misc_html.jl | 2 +-
src/misc_utils.jl | 16 +-----
src/parser/lx_blocks.jl | 4 +-
src/parser/lx_tokens.jl | 2 +-
test/converter/eval.jl | 7 ++-
test/converter/html.jl | 2 +-
test/converter/hyperref.jl | 4 +-
test/converter/lx_input.jl | 2 +-
test/converter/lx_simple.jl | 91 ++++++++++++++++++++++++++++------
test/converter/markdown.jl | 2 +-
test/converter/markdown2.jl | 4 +-
test/global/cases1.jl | 7 ++-
test/global/cases2.jl | 49 ++++++++++--------
test/manager/rss.jl | 2 +-
test/misc.jl | 4 +-
test/parser/footnotes.jl | 2 +-
test/parser/markdown+latex.jl | 2 +-
test/test_utils.jl | 3 +-
28 files changed, 181 insertions(+), 125 deletions(-)
diff --git a/Project.toml b/Project.toml
index ee60607d9..b8c367cf3 100644
--- a/Project.toml
+++ b/Project.toml
@@ -1,7 +1,7 @@
name = "JuDoc"
uuid = "4ca9428c-4c75-11e9-2efb-bf5cb6c1e8f8"
authors = ["Thibaut Lienart "]
-version = "0.3.7"
+version = "0.3.8"
[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
@@ -23,7 +23,7 @@ HTTP = "^0.8"
JuDocTemplates = "^0.2"
Literate = "^2.0"
LiveServer = "^0.3"
-NodeJS = "^0.6"
+NodeJS = "^0.6, ^1"
OrderedCollections = "^1.1"
julia = "^1.1"
diff --git a/src/JuDoc.jl b/src/JuDoc.jl
index 47dd83c06..edf70ab32 100644
--- a/src/JuDoc.jl
+++ b/src/JuDoc.jl
@@ -27,17 +27,16 @@ export serve, publish, cleanpull, newsite, optimize, jd2html, literate_folder, v
"""Big number when we want things to be far."""
const BIG_INT = typemax(Int)
-"""Flag for debug mode."""
-const DEBUG_MODE = Ref(false)
-
-"""Flag for the initial pass over pages"""
-const FULL_PASS = Ref(true)
-
-"""Flag for re-evaluation of all code blocks"""
-const FORCE_REEVAL = Ref(false)
-
-"""Flag for error suppression mode (set and unset in optimize only)."""
-const SUPPRESS_ERR = Ref(false)
+const JD_ENV = LittleDict(
+ :DEBUG_MODE => false,
+ :FULL_PASS => true,
+ :FORCE_REEVAL => false,
+ :SUPPRESS_ERR => false,
+ :SILENT_MODE => false,
+ :OFFSET_GLOB_LXDEFS => -BIG_INT,
+ :CUR_PATH => "",
+ :CUR_PATH_WITH_EVAL => "",
+ )
"""Dict to keep track of languages and how comments are indicated and their extensions."""
const CODE_LANG = LittleDict{String,NTuple{2,String}}(
@@ -55,12 +54,6 @@ const CODE_LANG = LittleDict{String,NTuple{2,String}}(
"toml" => (".toml", "#"),
)
-"""Flag to suppress all statements including eval ones."""
-const SILENT_MODE = Ref(false)
-
-"""Extreme negative offset for ordering of newcommands defined in config."""
-const OFFSET_GLOB_LXDEFS = Ref(-BIG_INT)
-
# copied from Base/path.jl
if Sys.isunix()
"""Indicator for directory separation on the OS."""
@@ -74,12 +67,6 @@ end
"""Type of the containers for page variables (local and global)."""
const PageVars = LittleDict{String,Pair{K,NTuple{N, DataType}} where {K, N}}
-"""Relative path to the current file being processed by JuDoc."""
-const CUR_PATH = Ref("")
-
-"""Relative path to the last with eval'd code blocks (to know what's in scope)."""
-const CUR_PATH_WITH_EVAL = Ref("")
-
"""Shorter name for a type that we use everywhere"""
const AS = Union{String,SubString{String}}
diff --git a/src/converter/html.jl b/src/converter/html.jl
index 8b6a45268..a0ae8f069 100644
--- a/src/converter/html.jl
+++ b/src/converter/html.jl
@@ -47,7 +47,7 @@ function jd2html(st::AbstractString; internal::Bool=false, dir::String="")::Stri
if !internal
FOLDER_PATH[] = isempty(dir) ? mktempdir() : dir
set_paths!()
- CUR_PATH[] = "index.md"
+ JD_ENV[:CUR_PATH] = "index.md"
def_GLOBAL_LXDEFS!()
def_GLOBAL_PAGE_VARS!()
end
@@ -162,7 +162,7 @@ function process_html_cond(hs::AS, allvars::PageVars, qblocks::Vector{AbstractBl
# current path is relative to /src/ for instance
# /src/pages/blah.md -> pages/blah
# if starts with `pages/`, replaces by `pub/`: pages/blah => pub/blah
- rpath = splitext(unixify(CUR_PATH[]))[1]
+ rpath = splitext(unixify(JD_ENV[:CUR_PATH]))[1]
rpath = replace(rpath, Regex("^pages") => "pub")
# compare with β.pages
inpage = any(p -> splitext(p)[1] == rpath, βi.pages)
diff --git a/src/converter/lx.jl b/src/converter/lx.jl
index e19db7523..ba945b095 100644
--- a/src/converter/lx.jl
+++ b/src/converter/lx.jl
@@ -30,7 +30,7 @@ function resolve_lxcom(lxc::LxCom, lxdefs::Vector{LxDef}; inmath::Bool=false)::S
# lxdef = something -> maybe inmath + found; retrieve & apply
partial = lxdef
for (argnum, β) ∈ enumerate(lxc.braces)
- content_ = ignore_starting_line_spaces(content(β))
+ content_ = strip(content(β))
# space sensitive "unsafe" one
# e.g. blah/!#1 --> blah/blah but note that
# \command!#1 --> \commandblah and \commandblah would not be found
diff --git a/src/converter/lx_simple.jl b/src/converter/lx_simple.jl
index c0fc02d26..8adcbd6e0 100644
--- a/src/converter/lx_simple.jl
+++ b/src/converter/lx_simple.jl
@@ -62,7 +62,7 @@ function resolve_lx_literate(lxc::LxCom)::String
set_var!(LOCAL_PAGE_VARS, "freezecode", true)
end
end
- if haschanged && FULL_PASS[]
+ if haschanged && JD_ENV[:FULL_PASS]
set_var!(LOCAL_PAGE_VARS, "reeval", true)
end
# if haschanged=true and not full pass then this will be handled cell by cell
diff --git a/src/converter/md.jl b/src/converter/md.jl
index b9bda3c8f..faf766c17 100644
--- a/src/converter/md.jl
+++ b/src/converter/md.jl
@@ -40,8 +40,10 @@ function convert_md(mds::String, pre_lxdefs::Vector{LxDef}=Vector{LxDef}();
validate_footnotes!(tokens)
# ignore header tokens that are not at the start of a line
validate_headers!(tokens)
- #> 1b. Find indented blocks
- tokens = find_indented_blocks(tokens, mds)
+ #> 1b. Find indented blocks (ONLY if not recursive to avoid ambiguities!)
+ if !isrecursive
+ tokens = find_indented_blocks(tokens, mds)
+ end
#> 2. Open-Close blocks (OCBlocks)
#>> a. find them
diff --git a/src/converter/md_blocks.jl b/src/converter/md_blocks.jl
index 7bf35efcd..d3f6a5ce6 100644
--- a/src/converter/md_blocks.jl
+++ b/src/converter/md_blocks.jl
@@ -24,7 +24,7 @@ function convert_block(β::AbstractBlock, lxcontext::LxContext)::AS
# Div block --> need to process the block as a sub-element
if βn == :DIV
- raw_ct = ignore_starting_line_spaces(content(β))
+ raw_ct = strip(content(β))
ct, _ = convert_md(raw_ct * EOS, lxcontext.lxdefs;
isrecursive=true, has_mddefs=false)
name = chop(otok(β).ss, head=2, tail=0)
@@ -173,7 +173,7 @@ function eval_and_resolve_code(code::AS, rpath::AS;
end
write(path, MESSAGE_FILE_GEN_JMD * code)
- SILENT_MODE[] || print(rpad("\r→ evaluating code [...] ($(CUR_PATH[]), $rpath)", 79) * "\r")
+ JD_ENV[:SILENT_MODE] || print(rpad("\r→ evaluating code [...] ($(JD_ENV[:CUR_PATH]), $rpath)", 79) * "\r")
# - execute the code while redirecting stdout to file
Logging.disable_logging(Logging.LogLevel(3_000))
res = nothing
@@ -192,7 +192,7 @@ function eval_and_resolve_code(code::AS, rpath::AS;
end
end
Logging.disable_logging(Logging.Debug)
- SILENT_MODE[] || print(rpad("\r→ evaluating code [✓]", 79) * "\r")
+ JD_ENV[:SILENT_MODE] || print(rpad("\r→ evaluating code [✓]", 79) * "\r")
# resolve the code block (highlighting) and return it
return resolve_lx_input_hlcode(rpath, "julia")
@@ -232,7 +232,7 @@ function convert_code_block(ss::SubString)::String
# In the case of forced re-eval, we don't care about the
# code scope just force-reeval everything sequentially
- if FORCE_REEVAL[] || reeval || eval
+ if JD_ENV[:FORCE_REEVAL] || reeval || eval
length(scope.codes) ≥ head && purgefrom!(scope, head)
return eval_and_resolve_code(code, rpath)
end
@@ -242,7 +242,7 @@ function convert_code_block(ss::SubString)::String
# the case then there will be a check to see if the relevant
# files exist, if they don't exist the code *will* be eval'ed
# (see `eval_and_resolve_code`)
- if FULL_PASS[] || freeze
+ if JD_ENV[:FULL_PASS] || freeze
length(scope.codes) ≥ head && purgefrom!(scope, head)
return eval_and_resolve_code(code, rpath, eval=false)
end
@@ -252,14 +252,14 @@ function convert_code_block(ss::SubString)::String
# B. local pass with non-frozen code
# check if the page we're looking at is in scope
- if CUR_PATH[] != CUR_PATH_WITH_EVAL[]
+ if JD_ENV[:CUR_PATH] != JD_ENV[:CUR_PATH_WITH_EVAL]
# we're necessarily at the first code block of the page.
# need to re-instantiate a code scope; note that if we
# are here then necessarily a def_LOCAL_PAGE_VARS was
# called, so LOCAL_PAGE_VARS["jd_code_head"] points to 1
reset!(scope)
# keep track that the page is now in scope
- CUR_PATH_WITH_EVAL[] = CUR_PATH[]
+ JD_ENV[:CUR_PATH_WITH_EVAL] = JD_ENV[:CUR_PATH]
# flag rest of page as to be eval-ed (might be stale)
toggle_jd_code_eval()
# eval and resolve code
diff --git a/src/manager/file_utils.jl b/src/manager/file_utils.jl
index 7e92c471a..658c4cb7f 100644
--- a/src/manager/file_utils.jl
+++ b/src/manager/file_utils.jl
@@ -34,12 +34,12 @@ function write_page(root::String, file::String, head::String,
# The curpath is the relative path starting after /src/ so for instance:
# f1/blah/page1.md or index.md etc... this is useful in the code evaluation and management
# of paths
- CUR_PATH[] = fpath[lastindex(PATHS[:src])+length(PATH_SEP)+1:end]
+ JD_ENV[:CUR_PATH] = fpath[lastindex(PATHS[:src])+length(PATH_SEP)+1:end]
(content, jd_vars) = convert_md(read(fpath, String) * EOS, collect(values(GLOBAL_LXDEFS)))
# Check for RSS elements
- if GLOBAL_PAGE_VARS["generate_rss"].first && FULL_PASS[] &&
+ if GLOBAL_PAGE_VARS["generate_rss"].first && JD_ENV[:FULL_PASS] &&
!all(e -> e |> first |> isempty, (jd_vars["rss"], jd_vars["rss_description"]))
# add item to RSSDICT
add_rss_item(jd_vars)
@@ -52,7 +52,7 @@ function write_page(root::String, file::String, head::String,
s = stat(fpath)
set_var!(jd_vars, "jd_ctime", jd_date(unix2datetime(s.ctime)))
set_var!(jd_vars, "jd_mtime", jd_date(unix2datetime(s.mtime)))
- set_var!(jd_vars, "jd_rpath", CUR_PATH[])
+ set_var!(jd_vars, "jd_rpath", JD_ENV[:CUR_PATH])
# 3. process blocks in the html infra elements based on `jd_vars`
# (e.g.: add the date in the footer)
@@ -93,12 +93,12 @@ function process_file(case::Symbol, fpair::Pair{String,String}, args...; kwargs.
try
process_file_err(case, fpair, args...; kwargs...)
catch err
- DEBUG_MODE[] && throw(err)
+ JD_ENV[:DEBUG_MODE] && throw(err)
rp = fpair.first
rp = rp[end-min(20, length(rp))+1 : end]
println("\n... encountered an issue processing '$(fpair.second)' in ...$rp.")
println("Verify, then start judoc again...\n")
- SUPPRESS_ERR[] || @show err
+ JD_ENV[:SUPPRESS_ERR] || @show err
return -1
end
return 0
@@ -138,7 +138,7 @@ function process_file_err(case::Symbol, fpair::Pair{String, String}, head::AS=""
force=true)
end
end
- FULL_PASS[] || print(rpad("\r→ page updated [✓]", 79)*"\r")
+ JD_ENV[:FULL_PASS] || JD_ENV[:SILENT_MODE] || print(rpad("\r→ page updated [✓]", 79)*"\r")
return nothing
end
diff --git a/src/manager/judoc.jl b/src/manager/judoc.jl
index 41d960122..ca8a550cc 100644
--- a/src/manager/judoc.jl
+++ b/src/manager/judoc.jl
@@ -31,7 +31,7 @@ function serve(; clear::Bool=true,
FOLDER_PATH[] = pwd()
# silent mode?
- silent && (SILENT_MODE[] = true; verb = false)
+ silent && (JD_ENV[:SILENT_MODE] = true; verb = false)
# brief check to see if we're in a folder that looks promising, otherwise stop
# and tell the user to check (#155)
@@ -55,10 +55,10 @@ function serve(; clear::Bool=true,
# do a first full pass
nomess || println("→ Initial full pass...")
start = time()
- FORCE_REEVAL[] = eval_all
+ JD_ENV[:FORCE_REEVAL] = eval_all
sig = jd_fullpass(watched_files; clear=clear, verb=verb, prerender=prerender,
isoptim=isoptim, no_fail_prerender=no_fail_prerender)
- FORCE_REEVAL[] = false
+ JD_ENV[:FORCE_REEVAL] = false
sig < 0 && return sig
fmsg = rpad("✔ full pass...", 40)
verb && (println(""); print(fmsg); print_final(fmsg, start); println(""))
@@ -134,7 +134,7 @@ See also [`jd_loop`](@ref), [`serve`](@ref) and [`publish`](@ref).
"""
function jd_fullpass(watched_files::NamedTuple; clear::Bool=false,
verb::Bool=false, prerender::Bool=false, isoptim::Bool=false, no_fail_prerender::Bool=true)::Int
- FULL_PASS[] = true
+ JD_ENV[:FULL_PASS] = true
# initiate page segments
head = read(joinpath(PATHS[:src_html], "head.html"), String)
pg_foot = read(joinpath(PATHS[:src_html], "page_foot.html"), String)
@@ -192,7 +192,7 @@ function jd_fullpass(watched_files::NamedTuple; clear::Bool=false,
end
# generate RSS if appropriate
GLOBAL_PAGE_VARS["generate_rss"].first && rss_generator()
- FULL_PASS[] = false
+ JD_ENV[:FULL_PASS] = false
# return -1 if any page
return ifelse(s<0, -1, 0)
end
diff --git a/src/manager/post_processing.jl b/src/manager/post_processing.jl
index b2f8334d2..b41710d8d 100644
--- a/src/manager/post_processing.jl
+++ b/src/manager/post_processing.jl
@@ -61,7 +61,13 @@ Verify all links in generated HTML.
"""
function verify_links()::Nothing
# check that the user is online (otherwise only verify internal links)
- online = HTTP.request("HEAD", "https://discourse.julialang.org/").status == 200
+ online =
+ try
+ HTTP.request("HEAD", "https://discourse.julialang.org/", readtimeout=10).status == 200
+ catch
+ # might fail with DNSError
+ false
+ end
print("Verifying links...")
if online
@@ -81,7 +87,7 @@ function verify_links()::Nothing
overallok = overallok && allok
end
end
- overallok && println("\rAll internal $(online && "and external ")links verified ✓. ")
+ overallok && println("\rAll internal $(ifelse(online,"and external ",""))links verified ✓. ")
return nothing
end
@@ -104,7 +110,7 @@ will be larger (especially if you have lots of maths on pages).
function optimize(; prerender::Bool=true, minify::Bool=true, sig::Bool=false,
prepath::String="", no_fail_prerender::Bool=true,
suppress_errors::Bool=true)::Union{Nothing,Bool}
- suppress_errors && (SUPPRESS_ERR[] = true)
+ suppress_errors && (JD_ENV[:SUPPRESS_ERR] = true)
#
# Prerendering
#
@@ -148,7 +154,7 @@ function optimize(; prerender::Bool=true, minify::Bool=true, sig::Bool=false,
"The output will not be minified."
end
end
- SUPPRESS_ERR[] = false
+ JD_ENV[:SUPPRESS_ERR] = false
return ifelse(sig, succ, nothing)
end
diff --git a/src/misc_html.jl b/src/misc_html.jl
index 03182176b..bdb93e4e9 100644
--- a/src/misc_html.jl
+++ b/src/misc_html.jl
@@ -90,7 +90,7 @@ Helper function to get the relative url of the current page.
function url_curpage()
# go from /pages/.../something.md to /pub/.../something.html note that if
# on windows then it would be \\ whence the PATH_SEP
- rp = replace(CUR_PATH[], Regex("^pages$(escape_string(PATH_SEP))")=>"pub$(PATH_SEP)")
+ rp = replace(JD_ENV[:CUR_PATH], Regex("^pages$(escape_string(PATH_SEP))")=>"pub$(PATH_SEP)")
rp = unixify(rp)
rp = splitext(rp)[1] * ".html"
startswith(rp, "/") || (rp = "/" * rp)
diff --git a/src/misc_utils.jl b/src/misc_utils.jl
index a7ceac347..f24b2b610 100644
--- a/src/misc_utils.jl
+++ b/src/misc_utils.jl
@@ -94,18 +94,6 @@ julia> JuDoc.matchrange(match(r"ell", "hello"))
"""
matchrange(m::RegexMatch)::UnitRange{Int} = m.offset .+ (0:(length(m.match)-1))
-
-"""
-$SIGNATURES
-
-In an lxdef or a div, ignore any whitespace at the beginning of lines to avoid ambiguities with indented
-code blocks.
-"""
-function ignore_starting_line_spaces(content::SubString)::AS
- s = strip(content)
- return replace(s, r"\n\s*" => "\n ")
-end
-
# Other convenience functions
"""
@@ -218,8 +206,8 @@ function resolve_assets_rpath(rpath::AS; canonical::Bool=false, code::Bool=false
# for instance if calling from `src/pages/pg1.md` with `./im1.png` it would refer to
# /assets/pages/pg1/im1.png
@assert length(rpath) > 2 "relative path '$rpath' doesn't seem right"
- canonical || return "/assets/" * unixify(splitext(CUR_PATH[])[1]) * rpath[3:end]
- return normpath(joinpath(PATHS[:assets], splitext(CUR_PATH[])[1], joinrp(rpath[3:end])))
+ canonical || return "/assets/" * unixify(splitext(JD_ENV[:CUR_PATH])[1]) * rpath[3:end]
+ return normpath(joinpath(PATHS[:assets], splitext(JD_ENV[:CUR_PATH])[1], joinrp(rpath[3:end])))
end
if code
# in the code mode we allow a short, this: `julia:ex` is considered
diff --git a/src/parser/lx_blocks.jl b/src/parser/lx_blocks.jl
index b81a50d87..9af962259 100644
--- a/src/parser/lx_blocks.jl
+++ b/src/parser/lx_blocks.jl
@@ -63,10 +63,8 @@ function find_md_lxdefs(tokens::Vector{Token}, blocks::Vector{OCBlock})
# keep track of the command name, definition and where it stops
lxname = matched.captures[1]
- lxdef = content(defining_braces)
+ lxdef = strip(content(defining_braces))
todef = to(defining_braces)
- # post-process the def
- lxdef = ignore_starting_line_spaces(lxdef)
# store the new latex command
push!(lxdefs, LxDef(lxname, lxnarg, lxdef, fromτ, todef))
diff --git a/src/parser/lx_tokens.jl b/src/parser/lx_tokens.jl
index 72ad1d70c..4c3fe1b60 100644
--- a/src/parser/lx_tokens.jl
+++ b/src/parser/lx_tokens.jl
@@ -46,7 +46,7 @@ mutable struct LxDef
end
# if offset unspecified, start from basically -∞ (configs etc)
function LxDef(name::String, narg::Int, def::AS)
- o = OFFSET_GLOB_LXDEFS[] += 5 # we don't care just fwd a bit
+ o = JD_ENV[:OFFSET_GLOB_LXDEFS] += 5 # we don't care just fwd a bit
LxDef(name, narg, def, o, o + 3) # we also don't care YOLO
end
diff --git a/test/converter/eval.jl b/test/converter/eval.jl
index 78c0b7102..6ab5f483a 100644
--- a/test/converter/eval.jl
+++ b/test/converter/eval.jl
@@ -1,7 +1,10 @@
+J.JD_ENV[:CUR_PATH] = "index.md"
+
@testset "Evalcode" begin
# see `converter/md_blocks:convert_code_block`
# see `converter/lx/resolve_lx_input_*`
# --------------------------------------------
+
h = raw"""
Simple code:
```julia:./code/exca1
@@ -96,7 +99,7 @@ end
# ------------
- J.CUR_PATH[] = "pages/pg1.md"
+ J.JD_ENV[:CUR_PATH] = "pages/pg1.md"
h = raw"""
Simple code:
@@ -142,7 +145,7 @@ end
end
@testset "Eval (img)" begin
- J.CUR_PATH[] = "index.html"
+ J.JD_ENV[:CUR_PATH] = "index.html"
h = raw"""
Simple code:
```julia:tv2
diff --git a/test/converter/html.jl b/test/converter/html.jl
index 00532f19a..9a65b36a8 100644
--- a/test/converter/html.jl
+++ b/test/converter/html.jl
@@ -112,6 +112,6 @@ end
{{isnotpage blah.html ya/xx}} blih {{end}} done.
"""
- J.CUR_PATH[] = "index.md"
+ J.JD_ENV[:CUR_PATH] = "index.md"
@test J.convert_html(hs, allvars) == "Some text then blah but\n blih done.\n"
end
diff --git a/test/converter/hyperref.jl b/test/converter/hyperref.jl
index 6a538a8cc..ace670678 100644
--- a/test/converter/hyperref.jl
+++ b/test/converter/hyperref.jl
@@ -1,5 +1,5 @@
@testset "Hyperref" begin
- J.CUR_PATH[] = "index.md"
+ J.JD_ENV[:CUR_PATH] = "index.md"
st = raw"""
Some string
$$ x = x \label{eq 1}$$
@@ -51,7 +51,7 @@
end
@testset "Href-space" begin
- J.CUR_PATH[] = "index.md"
+ J.JD_ENV[:CUR_PATH] = "index.md"
st = raw"""
A
$$ x = x \label{eq 1}$$
diff --git a/test/converter/lx_input.jl b/test/converter/lx_input.jl
index d722bf969..2d7bc4e0d 100644
--- a/test/converter/lx_input.jl
+++ b/test/converter/lx_input.jl
@@ -2,7 +2,7 @@
#
# check_input_fname
#
- J.CUR_PATH[] = "index.html"
+ J.JD_ENV[:CUR_PATH] = "index.html"
script1 = joinpath(J.PATHS[:assets], "index", "code", "script1.jl")
write(script1, "1+1")
fp, d, fn = J.check_input_rpath("script1.jl", code=true)
diff --git a/test/converter/lx_simple.jl b/test/converter/lx_simple.jl
index 2d9ec3031..6ee1002f7 100644
--- a/test/converter/lx_simple.jl
+++ b/test/converter/lx_simple.jl
@@ -62,11 +62,30 @@ end
\tableinput{}{/assets/testcsv.csv}
Done.
""" |> seval
- shouldbe = """A table:
h1 | h2 | h3 |
- string1 | 1.567 | 0 |
- | | |
- l i n e | .158 | 99999999 |
+
+ # NOTE: in VERSION > 1.4, Markdown has alignment for tables:
+ # -- https://github.com/JuliaLang/julia/pull/33849
+ if VERSION > v"1.3.0-rc5.1"
+ shouldbe = """
+ A table:
+
+ h1 | h2 | h3 |
+ string1 | 1.567 | 0 |
+ | | |
+ l i n e | .158 | 99999999 |
+
+ Done.
"""
+ else
+ shouldbe = """
+ A table:
+
+ h1 | h2 | h3 |
+ string1 | 1.567 | 0 |
+ | | |
+ l i n e | .158 | 99999999 |
+
Done."""
+ end
@test isapproxstr(h, shouldbe)
# header specified
h = raw"""
@@ -74,12 +93,29 @@ end
\tableinput{A,B,C}{/assets/testcsv.csv}
Done.
""" |> seval
- shouldbe = """A table:
A | B | C |
- h1 | h2 | h3 |
- string1 | 1.567 | 0 |
- | | |
- l i n e | .158 | 99999999 |
+ if VERSION > v"1.3.0-rc5.1"
+ shouldbe = """
+ A table:
+
+ A | B | C |
+ h1 | h2 | h3 |
+ string1 | 1.567 | 0 |
+ | | |
+ l i n e | .158 | 99999999 |
+
+ Done."""
+ else
+ shouldbe = """
+ A table:
+
+ A | B | C |
+ h1 | h2 | h3 |
+ string1 | 1.567 | 0 |
+ | | |
+ l i n e | .158 | 99999999 |
+
Done."""
+ end
@test isapproxstr(h, shouldbe)
# wrong header
h = raw"""
@@ -103,10 +139,25 @@ end
\tableinput{}{/assets/testcsv.csv}
Done.
""" |> seval
- shouldbe = """A table:
string1 | 1.567 | 0 |
- | | |
- l i n e | .158 | 99999999 |
+ if VERSION > v"1.3.0-rc5.1"
+ shouldbe = """
+ A table:
+
+ string1 | 1.567 | 0 |
+ | | |
+ l i n e | .158 | 99999999 |
+
Done."""
+ else
+ shouldbe = """
+ A table:
+
+ string1 | 1.567 | 0 |
+ | | |
+ l i n e | .158 | 99999999 |
+
+ Done."""
+ end
@test isapproxstr(h, shouldbe)
# header specified
h = raw"""
@@ -114,11 +165,18 @@ end
\tableinput{A,B,C}{/assets/testcsv.csv}
Done.
""" |> seval
- shouldbe = """A table:
A | B | C |
- string1 | 1.567 | 0 |
- | | |
- l i n e | .158 | 99999999 |
+
+ if VERSION > v"1.3.0-rc5.1"
+ shouldbe = """
+ A table:
A | B | C |
---|
string1 | 1.567 | 0 |
| | |
l i n e | .158 | 99999999 |
Done."""
+ else
+ shouldbe = """A table:
A | B | C |
+ string1 | 1.567 | 0 |
+ | | |
+ l i n e | .158 | 99999999 |
+ Done."""
+ end
@test isapproxstr(h, shouldbe)
# wrong header
h = raw"""
@@ -126,6 +184,7 @@ end
\tableinput{A,B}{/assets/testcsv.csv}
Done.
""" |> seval
+
shouldbe = """A table:
// header size (2) and number of columns (3) do not match //
Done."""
@test isapproxstr(h, shouldbe)
diff --git a/test/converter/markdown.jl b/test/converter/markdown.jl
index 57ccd2981..b9cf2bb0d 100644
--- a/test/converter/markdown.jl
+++ b/test/converter/markdown.jl
@@ -110,7 +110,7 @@ end
@testset "headers" begin
- J.CUR_PATH[] = "index.md"
+ J.JD_ENV[:CUR_PATH] = "index.md"
h = """
# Title
and then
diff --git a/test/converter/markdown2.jl b/test/converter/markdown2.jl
index 72604427c..15e47ab6f 100644
--- a/test/converter/markdown2.jl
+++ b/test/converter/markdown2.jl
@@ -29,7 +29,7 @@ end
@testset "TOC" begin
- J.CUR_PATH[] = "pages/ff/aa.md"
+ J.JD_ENV[:CUR_PATH] = "pages/ff/aa.md"
h = raw"""
\toc
## Hello `jd`
@@ -59,7 +59,7 @@ end
end
@testset "TOC" begin
- J.CUR_PATH[] = "pages/ff/aa.md"
+ J.JD_ENV[:CUR_PATH] = "pages/ff/aa.md"
s = raw"""
@def mintoclevel = 2
@def maxtoclevel = 3
diff --git a/test/global/cases1.jl b/test/global/cases1.jl
index 2f0d62aef..d4d7d21cb 100644
--- a/test/global/cases1.jl
+++ b/test/global/cases1.jl
@@ -172,11 +172,16 @@ end
| C | D |
""" * J.EOS
- @test isapproxstr(st |> conv,
+ if VERSION > v"1.3.0-rc5.1"
+ @test isapproxstr(st |> conv,
+ """""")
+ else
+ @test isapproxstr(st |> conv,
"""""")
+ end
@test J.convert_md(st, isrecursive=true) |> chtml == st |> conv
diff --git a/test/global/cases2.jl b/test/global/cases2.jl
index a43fd62f5..5f56f050a 100644
--- a/test/global/cases2.jl
+++ b/test/global/cases2.jl
@@ -61,7 +61,7 @@ end
@testset "Table" begin
- J.CUR_PATH[] = "pages/pg1.html"
+ J.JD_ENV[:CUR_PATH] = "pages/pg1.html"
st = """
A
@@ -76,24 +76,31 @@ end
C
""" * J.EOS
- @test isapproxstr(st |> seval, raw""" A
-
-
-
-
- No. | Graph | Vertices | Edges |
-
-
- 1 | Twitter Social Circles | 81,306 | 1,342,310 |
-
-
- 2 | Astro-Physics Collaboration | 17,903 | 197,031 |
-
-
- 3 | Facebook Social Circles | 4,039 | 88,234 |
-
-
-
- C
- """)
+ if VERSION > v"1.3.0-rc5.1"
+ @test isapproxstr(st |> seval, raw"""A
+
+No. | Graph | Vertices | Edges |
---|
1 | Twitter Social Circles | 81,306 | 1,342,310 |
2 | Astro-Physics Collaboration | 17,903 | 197,031 |
3 | Facebook Social Circles | 4,039 | 88,234 |
+C
""")
+ else
+ @test isapproxstr(st |> seval, raw""" A
+
+
+
+
+ No. | Graph | Vertices | Edges |
+
+
+ 1 | Twitter Social Circles | 81,306 | 1,342,310 |
+
+
+ 2 | Astro-Physics Collaboration | 17,903 | 197,031 |
+
+
+ 3 | Facebook Social Circles | 4,039 | 88,234 |
+
+
+
+ C
+ """)
+ end
end
diff --git a/test/manager/rss.jl b/test/manager/rss.jl
index c666d1528..362760514 100644
--- a/test/manager/rss.jl
+++ b/test/manager/rss.jl
@@ -14,7 +14,7 @@ end
@testset "RSSbasics" begin
empty!(J.RSS_DICT)
- J.CUR_PATH[] = "hey/ho.md"
+ J.JD_ENV[:CUR_PATH] = "hey/ho.md"
J.set_var!(J.GLOBAL_PAGE_VARS, "website_title", "Website title")
J.set_var!(J.GLOBAL_PAGE_VARS, "website_descr", "Website descr")
J.set_var!(J.GLOBAL_PAGE_VARS, "website_url", "https://github.com/tlienart/JuDoc.jl/")
diff --git a/test/misc.jl b/test/misc.jl
index 008585de2..a413bdcd5 100644
--- a/test/misc.jl
+++ b/test/misc.jl
@@ -91,7 +91,7 @@ end
@testset "paths" begin
@test J.unixify(pwd()) == replace(pwd(), J.PATH_SEP => "/") * "/"
#
- J.CUR_PATH[] = "cpA/cpB/"
+ J.JD_ENV[:CUR_PATH] = "cpA/cpB/"
# non-canonical mode
@test J.resolve_assets_rpath("./hello/goodbye") == "/assets/cpA/cpB/hello/goodbye"
@test J.resolve_assets_rpath("/blah/blih.txt") == "/blah/blih.txt"
@@ -106,7 +106,7 @@ end
@testset "html misc" begin
λ = "blah/blah.ext"
- J.CUR_PATH[] = "pages/cpB/blah.md"
+ J.JD_ENV[:CUR_PATH] = "pages/cpB/blah.md"
@test J.html_ahref(λ, 1) == "1"
@test J.html_ahref(λ, "bb") == "bb"
@test J.html_ahref_key("cc", "dd") == "dd"
diff --git a/test/parser/footnotes.jl b/test/parser/footnotes.jl
index c83a6fa24..0c585d6ea 100644
--- a/test/parser/footnotes.jl
+++ b/test/parser/footnotes.jl
@@ -1,5 +1,5 @@
@testset "footnotes" begin
- J.CUR_PATH[] = "index.md"
+ J.JD_ENV[:CUR_PATH] = "index.md"
st = """
A[^1] B[^blah] C
""" * J.EOS
diff --git a/test/parser/markdown+latex.jl b/test/parser/markdown+latex.jl
index 965b9d111..d28692bee 100644
--- a/test/parser/markdown+latex.jl
+++ b/test/parser/markdown+latex.jl
@@ -261,7 +261,7 @@ end
@test blocks[5].name == :H5
@test blocks[6].name == :H6
- J.CUR_PATH[] = "index.md"
+ J.JD_ENV[:CUR_PATH] = "index.md"
h = raw"""
# t1
diff --git a/test/test_utils.jl b/test/test_utils.jl
index d2169ecf5..28170d7ff 100644
--- a/test/test_utils.jl
+++ b/test/test_utils.jl
@@ -37,7 +37,8 @@ function set_globals()
J.def_GLOBAL_LXDEFS!()
empty!(J.LOCAL_PAGE_VARS)
J.def_LOCAL_PAGE_VARS!()
- J.CUR_PATH_WITH_EVAL[] = ""
+ J.JD_ENV[:CUR_PATH] = "index.md"
+ J.JD_ENV[:CUR_PATH_WITH_EVAL] = ""
end
function explore_md_steps(mds)