From ed90a4de3cb954a66888e69a8f9ae600285c986b Mon Sep 17 00:00:00 2001
From: Thibaut Lienart ` and ` ... Simple code:
"
+ return html_code(code, lang)
end
if lang!="julia"
- @warn "Eval of non-julia code blocks is not supported at the moment"
- return "$code
"
+ @warn "Eval of non-julia code blocks is not yet supported."
+ return html_code(code, lang)
end
# path currently has an indicative `:` we don't care about
rpath = rpath[2:end]
@@ -173,3 +174,16 @@ function convert_code_block(ss::SubString)::String
# step 3, insertion of code stripping of "hide" lines.
return resolve_lx_input_hlcode(rpath, "julia")
end
+
+
+"""
+$(SIGNATURES)
+
+Helper function for the indented code block case of `convert_block`.
+"""
+function convert_indented_code_block(ss::SubString)::String
+ # 1. decrease indentation of all lines (either frontal \n\t or \n⎵⎵⎵⎵)
+ code = replace(ss, r"\n(?:\t| {4})" => "\n")
+ # 2. return; lang is a LOCAL_PAGE_VARS that is julia by default and can be set
+ return html_code(code, "{{fill lang}}")
+end
diff --git a/src/converter/md_utils.jl b/src/converter/md_utils.jl
index 500968485..808eac407 100644
--- a/src/converter/md_utils.jl
+++ b/src/converter/md_utils.jl
@@ -7,9 +7,10 @@ The boolean `stripp` indicates whether to remove the inserted `$code
done.", h)
end
-@testset "Eval code (errs)" begin
+@testset "Eval (errs)" begin
# see `converter/md_blocks:convert_code_block`
# --------------------------------------------
h = raw"""
@@ -42,7 +42,7 @@ end
@test occursin("code: 25
done.", h)
end
-@testset "Eval (rel-input)" begin
+@testset "Eval (rinput)" begin
h = raw"""
Simple code:
```julia:/scripts/test2
@@ -92,7 +92,7 @@ end
@test occursin("then: a = 5\nprint(a**2)\n
done.", h)
end
-@testset "Eval code (module)" begin
+@testset "Eval (module)" begin
h = raw"""
Simple code:
```julia:scripts/test1
@@ -108,7 +108,7 @@ end
@test occursin("then: 25
done.", h)
end
-@testset "Eval code (img)" begin
+@testset "Eval (img)" begin
h = raw"""
Simple code:
```julia:scripts/test1
@@ -121,7 +121,7 @@ end
@test occursin("then: done.", h)
end
-@testset "Eval code (exception)" begin
+@testset "Eval (throw)" begin
h = raw"""
Simple code:
```julia:scripts/test1
@@ -135,7 +135,7 @@ end
@test occursin("then: 54
There was an error running the code: DomainError", h)
end
-@testset "Eval code (no-julia)" begin
+@testset "Eval (nojl)" begin
h = raw"""
Simple code:
```python:scripts/test1
@@ -144,7 +144,7 @@ end
done.
""" * J.EOS
- @test (@test_logs (:warn, "Eval of non-julia code blocks is not supported at the moment") h |> seval) == "
done.sqrt(-1)\n
Simple code:
sqrt(-1)\n
done.\n"
end
# temporary fix for 186: make error appear and also use `abspath` in internal include
diff --git a/test/converter/lx_simple.jl b/test/converter/lx_simple.jl
index 2e4a6b35e..2d9ec3031 100644
--- a/test/converter/lx_simple.jl
+++ b/test/converter/lx_simple.jl
@@ -50,7 +50,10 @@ end
""")
end
-@testset "table: source with header" begin
+@testset "table" begin
+ #
+ # has header in source
+ #
testcsv = "h1,h2,h3\nstring1, 1.567, 0\n,,\n l i n e ,.158,99999999"
write(joinpath(J.PATHS[:assets], "testcsv.csv"), testcsv)
# no header specified
@@ -87,9 +90,11 @@ end
shouldbe = """A table:
// header size (2) and number of columns (3) do not match //
Done.""" @test isapproxstr(h, shouldbe) -end -@testset "table: source without header" begin + # + # does not have header in source + # + testcsv = "string1, 1.567, 0\n,,\n l i n e ,.158,99999999" write(joinpath(J.PATHS[:assets], "testcsv.csv"), testcsv) # no header specified diff --git a/test/converter/markdown2.jl b/test/converter/markdown2.jl index 8bcac9712..fc4e9f701 100644 --- a/test/converter/markdown2.jl +++ b/test/converter/markdown2.jl @@ -5,7 +5,7 @@ function inter(st::String) return steps[:inter_md].inter_md, steps[:inter_html].inter_html end -@testset "Code+italic (#163)" begin +@testset "issue163" begin st = raw"""A _B `C` D_ E""" * J.EOS imd, ih = inter(st) @test imd == "A _B ##JDINSERT## D_ E" diff --git a/test/converter/markdown3.jl b/test/converter/markdown3.jl index 48a0f3aaf..95573867d 100644 --- a/test/converter/markdown3.jl +++ b/test/converter/markdown3.jl @@ -227,3 +227,62 @@ end D """) end + + +@testset "IndCode" begin # issue 207 + st = raw""" + A + a = 1+1 + if a > 1 + @show a + end + b = 2 + @show a+b + end + """ * J.EOS + @test isapproxstr(st |> seval, raw""" ++ A +
+ a = 1+1
+ if a > 1
+ @show a
+ end
+ b = 2
+ @show a+b
+
+ end
+
+ """)
+
+ st = raw"""
+ A `single` and ```python blah``` and
+ a = 1+1
+ then
+ * blah
+ + blih
+ + bloh
+ end
+ """ * J.EOS
+ @test isapproxstr(st |> seval, raw"""
+
+ A single
and
+
+ blah
+
+ and
+
+ a = 1+1
+
+ then
+ blah
+blih
bloh
end
+ """) +end diff --git a/test/global/postprocess.jl b/test/global/postprocess.jl index 7ae644c7b..055a15242 100644 --- a/test/global/postprocess.jl +++ b/test/global/postprocess.jl @@ -1,4 +1,4 @@ -@testset "Generation and optimisation" begin +@testset "Gen&Opt" begin isdir("basic") && rm("basic", recursive=true, force=true) newsite("basic") diff --git a/test/manager/utils.jl b/test/manager/utils.jl index 479a6aad6..028885d10 100644 --- a/test/manager/utils.jl +++ b/test/manager/utils.jl @@ -15,7 +15,7 @@ write(temp_css, "some css") JuDoc.process_config() -@testset "Prep outdir" begin # ✅ aug 15, 2018 +@testset "Prep outdir" begin JuDoc.prepare_output_dir() @test isdir(JuDoc.PATHS[:pub]) @test isdir(JuDoc.PATHS[:css]) @@ -29,7 +29,7 @@ JuDoc.process_config() @test !isfile(temp_out) end -@testset "Scan dir" begin # ✅ aug 16, 2018 +@testset "Scan dir" begin println("🐝 Testing file tracking...:") # it also tests add_if_new_file and last md_files = Dict{Pair{String, String}, Float64}() @@ -44,7 +44,7 @@ end @test other_files[JuDoc.PATHS[:src_pages]=>"temp.rnd"] == mtime(temp_rnd) end -@testset "Config+write" begin # ✅ 4 Sept, 2018 +@testset "Config+write" begin JuDoc.process_config() @test JuDoc.GLOBAL_PAGE_VARS["author"].first == "Stefan Zweig" rm(temp_config) diff --git a/test/test_utils.jl b/test/test_utils.jl index c4f710b60..2f4b93277 100644 --- a/test/test_utils.jl +++ b/test/test_utils.jl @@ -27,8 +27,8 @@ end function seval(st) J.def_GLOBAL_PAGE_VARS!() J.def_GLOBAL_LXDEFS!() - m, _ = J.convert_md(st, collect(values(J.GLOBAL_LXDEFS))) - h = J.convert_html(m, J.PageVars()) + m, v = J.convert_md(st, collect(values(J.GLOBAL_LXDEFS))) + h = J.convert_html(m, v) return h end