Browse Source

Revert "Formatted"

This reverts commit fa050c7863.
pull/200/head
J S 3 years ago
parent
commit
76183c0476
  1. 21
      docs/make.jl
  2. 3
      src/IJulia.jl
  3. 183
      src/Literate.jl
  4. 569
      test/runtests.jl

21
docs/make.jl

@ -5,11 +5,7 @@ if haskey(ENV, "GITHUB_ACTIONS")
end end
deployconfig = Documenter.auto_detect_deploy_system() deployconfig = Documenter.auto_detect_deploy_system()
Documenter.post_status( Documenter.post_status(deployconfig; type="pending", repo="github.com/fredrikekre/Literate.jl.git")
deployconfig;
type = "pending",
repo = "github.com/fredrikekre/Literate.jl.git",
)
using Literate using Literate
using Plots # to not capture precompilation output using Plots # to not capture precompilation output
@ -27,12 +23,7 @@ Literate.notebook(EXAMPLE, OUTPUT, preprocess = preprocess)
Literate.script(EXAMPLE, OUTPUT, preprocess = preprocess) Literate.script(EXAMPLE, OUTPUT, preprocess = preprocess)
# generate the example notebook for the documentation, keep in sync with outputformats.md # generate the example notebook for the documentation, keep in sync with outputformats.md
Literate.markdown( Literate.markdown(joinpath(@__DIR__, "src/outputformats.jl"), OUTPUT; credit = false, name = "name")
joinpath(@__DIR__, "src/outputformats.jl"),
OUTPUT;
credit = false,
name = "name",
)
Literate.notebook(joinpath(@__DIR__, "src/outputformats.jl"), OUTPUT; name = "notebook") Literate.notebook(joinpath(@__DIR__, "src/outputformats.jl"), OUTPUT; name = "notebook")
Literate.script(joinpath(@__DIR__, "src/outputformats.jl"), OUTPUT; credit = false) Literate.script(joinpath(@__DIR__, "src/outputformats.jl"), OUTPUT; credit = false)
@ -50,10 +41,7 @@ if haskey(ENV, "GITHUB_ACTIONS")
end end
url = "https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/$(folder)/" url = "https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/$(folder)/"
str = read(joinpath(@__DIR__, "src/outputformats.md"), String) str = read(joinpath(@__DIR__, "src/outputformats.md"), String)
str = replace( str = replace(str, "[notebook.ipynb](generated/notebook.ipynb)." => "[notebook.ipynb]($(url)generated/notebook.ipynb).")
str,
"[notebook.ipynb](generated/notebook.ipynb)." => "[notebook.ipynb]($(url)generated/notebook.ipynb).",
)
write(joinpath(@__DIR__, "src/outputformats.md"), str) write(joinpath(@__DIR__, "src/outputformats.md"), str)
end end
@ -73,8 +61,7 @@ makedocs(
"customprocessing.md", "customprocessing.md",
"documenter.md", "documenter.md",
"tips.md", "tips.md",
"generated/example.md", "generated/example.md"]
],
) )
deploydocs( deploydocs(

3
src/IJulia.jl

@ -19,8 +19,7 @@ const application_vnd_vegalite_v2 = MIME("application/vnd.vegalite.v2+json")
function display_dict(x) function display_dict(x)
data = Dict{String,Any}("text/plain" => limitstringmime(text_plain, x)) data = Dict{String,Any}("text/plain" => limitstringmime(text_plain, x))
if showable(application_vnd_vegalite_v2, x) if showable(application_vnd_vegalite_v2, x)
data[string(application_vnd_vegalite_v2)] = data[string(application_vnd_vegalite_v2)] = JSON.parse(limitstringmime(application_vnd_vegalite_v2, x))
JSON.parse(limitstringmime(application_vnd_vegalite_v2, x))
end end
if showable(image_svg, x) if showable(image_svg, x)
data[string(image_svg)] = limitstringmime(image_svg, x) data[string(image_svg)] = limitstringmime(image_svg, x)

183
src/Literate.jl

@ -44,9 +44,7 @@ mutable struct CodeChunk <: Chunk
end end
CodeChunk() = CodeChunk(String[], false) CodeChunk() = CodeChunk(String[], false)
ismdline(line) = ismdline(line) = (occursin(r"^\h*#$", line) || occursin(r"^\h*# .*$", line)) && !occursin(r"^\h*##", line)
(occursin(r"^\h*#$", line) || occursin(r"^\h*# .*$", line)) &&
!occursin(r"^\h*##", line)
function parse(content; allow_continued = true) function parse(content; allow_continued = true)
lines = collect(eachline(IOBuffer(content))) lines = collect(eachline(IOBuffer(content)))
@ -80,10 +78,7 @@ function parse(content; allow_continued = true)
end end
# remove "## " and "##\n", strip the leading "#" from "## xyz" and "##| xyz" # remove "## " and "##\n", strip the leading "#" from "## xyz" and "##| xyz"
# Note: accepts only standard space character (not no-break space U+00A0) # Note: accepts only standard space character (not no-break space U+00A0)
line = replace( line = replace(replace(line, r"^(\h*)#(#(:? |\|).*)$" => s"\1\2"), r"^(\h*#)#$" => s"\1")
replace(line, r"^(\h*)#(#(:? |\|).*)$" => s"\1\2"),
r"^(\h*#)#$" => s"\1",
)
push!(chunks[end].lines, line) push!(chunks[end].lines, line)
end end
end end
@ -113,10 +108,7 @@ function parse(content; allow_continued = true)
append!(merged_chunks[end].lines, chunk.lines) append!(merged_chunks[end].lines, chunk.lines)
else # need to put back "#" else # need to put back "#"
for line in chunk.lines for line in chunk.lines
push!( push!(merged_chunks[end].lines, rstrip(line.first * "# " * line.second))
merged_chunks[end].lines,
rstrip(line.first * "# " * line.second),
)
end end
end end
else else
@ -132,7 +124,11 @@ function parse(content; allow_continued = true)
return chunks return chunks
end end
function replace_default(content, sym; config::Dict, branch = "gh-pages", commit = "master") function replace_default(content, sym;
config::Dict,
branch = "gh-pages",
commit = "master"
)
repls = Pair{Any,Any}[] repls = Pair{Any,Any}[]
# add some shameless advertisement # add some shameless advertisement
@ -203,16 +199,12 @@ function replace_default(content, sym; config::Dict, branch = "gh-pages", commit
# fix links # fix links
if get(ENV, "DOCUMENTATIONGENERATOR", "") == "true" if get(ENV, "DOCUMENTATIONGENERATOR", "") == "true"
## DocumentationGenerator.jl ## DocumentationGenerator.jl
base_url = base_url = get(ENV, "DOCUMENTATIONGENERATOR_BASE_URL", "DOCUMENTATIONGENERATOR_BASE_URL")
get(ENV, "DOCUMENTATIONGENERATOR_BASE_URL", "DOCUMENTATIONGENERATOR_BASE_URL")
nbviewer_root_url = "https://nbviewer.jupyter.org/urls/$(base_url)" nbviewer_root_url = "https://nbviewer.jupyter.org/urls/$(base_url)"
push!(repls, "@__NBVIEWER_ROOT_URL__" => nbviewer_root_url) push!(repls, "@__NBVIEWER_ROOT_URL__" => nbviewer_root_url)
else else
push!(repls, "@__REPO_ROOT_URL__" => get(config, "repo_root_url", "<unknown>")) push!(repls, "@__REPO_ROOT_URL__" => get(config, "repo_root_url", "<unknown>"))
push!( push!(repls, "@__NBVIEWER_ROOT_URL__" => get(config, "nbviewer_root_url", "<unknown>"))
repls,
"@__NBVIEWER_ROOT_URL__" => get(config, "nbviewer_root_url", "<unknown>"),
)
push!(repls, "@__BINDER_ROOT_URL__" => get(config, "binder_root_url", "<unknown>")) push!(repls, "@__BINDER_ROOT_URL__" => get(config, "binder_root_url", "<unknown>"))
end end
@ -235,11 +227,8 @@ end
filename(str) = first(splitext(last(splitdir(str)))) filename(str) = first(splitext(last(splitdir(str))))
isdocumenter(cfg) = cfg["flavor"]::AbstractFlavor isa DocumenterFlavor isdocumenter(cfg) = cfg["flavor"]::AbstractFlavor isa DocumenterFlavor
_DEFAULT_IMAGE_FORMATS = [ _DEFAULT_IMAGE_FORMATS = [(MIME("image/svg+xml"), ".svg"), (MIME("image/png"), ".png"),
(MIME("image/svg+xml"), ".svg"), (MIME("image/jpeg"), ".jpeg")]
(MIME("image/png"), ".png"),
(MIME("image/jpeg"), ".jpeg"),
]
# Cache of inputfile => head branch # Cache of inputfile => head branch
const HEAD_BRANCH_CACHE = Dict{String,String}() const HEAD_BRANCH_CACHE = Dict{String,String}()
@ -258,7 +247,7 @@ function edit_commit(inputfile, user_config)
pipeline( pipeline(
setenv(`$(git) rev-parse --show-toplevel`; dir=dirname(inputfile)); setenv(`$(git) rev-parse --show-toplevel`; dir=dirname(inputfile));
stderr=devnull, stderr=devnull,
), )
) )
catch catch
end end
@ -294,17 +283,13 @@ function edit_commit(inputfile, user_config)
end end
# Default to DefaultFlavor() setting # Default to DefaultFlavor() setting
pick_codefence(flavor::AbstractFlavor, execute::Bool, name::AbstractString) = pick_codefence(flavor::AbstractFlavor,execute::Bool,name::AbstractString)=pick_codefence(DefaultFlavor(),execute,name)
pick_codefence(DefaultFlavor(), execute, name) pick_codefence(flavor::DefaultFlavor,execute::Bool,name::AbstractString)=("````julia" => "````")
pick_codefence(flavor::DefaultFlavor, execute::Bool, name::AbstractString) = pick_codefence(flavor::DocumenterFlavor,execute::Bool,name::AbstractString)=(execute ?
("````julia" => "````") pick_codefence(DefaultFlavor(),execute,name) : ("````@example $(name)" => "````")
pick_codefence(flavor::DocumenterFlavor, execute::Bool, name::AbstractString) = (
execute ? pick_codefence(DefaultFlavor(), execute, name) :
("````@example $(name)" => "````")
) )
pick_codefence(flavor::QuartoFlavor, execute::Bool, name::AbstractString) = ( pick_codefence(flavor::QuartoFlavor,execute::Bool,name::AbstractString)=(execute ?
execute ? error("QuartoFlavor does not support argument execute=true!") : error("QuartoFlavor does not support argument execute=true!") : ("```{julia}" => "```")
("```{julia}" => "```")
) )
function create_configuration(inputfile; user_config, user_kwargs, type=nothing) function create_configuration(inputfile; user_config, user_kwargs, type=nothing)
@ -316,25 +301,16 @@ function create_configuration(inputfile; user_config, user_kwargs, type = nothin
# deprecation of documenter kwarg # deprecation of documenter kwarg
if (d = get(user_config, "documenter", nothing); d !== nothing) if (d = get(user_config, "documenter", nothing); d !== nothing)
if type === :md if type === :md
Base.depwarn( Base.depwarn("The documenter=$(d) keyword to Literate.markdown is deprecated." *
"The documenter=$(d) keyword to Literate.markdown is deprecated." *
" Pass `flavor = Literate.$(d ? "DocumenterFlavor" : "CommonMarkFlavor")()`" * " Pass `flavor = Literate.$(d ? "DocumenterFlavor" : "CommonMarkFlavor")()`" *
" instead.", " instead.", Symbol("Literate.markdown"))
Symbol("Literate.markdown"),
)
user_config["flavor"] = d ? DocumenterFlavor() : CommonMarkFlavor() user_config["flavor"] = d ? DocumenterFlavor() : CommonMarkFlavor()
elseif type === :nb elseif type === :nb
Base.depwarn( Base.depwarn("The documenter=$(d) keyword to Literate.notebook is deprecated." *
"The documenter=$(d) keyword to Literate.notebook is deprecated." * " It is not used anymore for notebook output.", Symbol("Literate.notebook"))
" It is not used anymore for notebook output.",
Symbol("Literate.notebook"),
)
elseif type === :jl elseif type === :jl
Base.depwarn( Base.depwarn("The documenter=$(d) keyword to Literate.script is deprecated." *
"The documenter=$(d) keyword to Literate.script is deprecated." * " It is not used anymore for script output.", Symbol("Literate.script"))
" It is not used anymore for script output.",
Symbol("Literate.script"),
)
end end
end end
@ -351,7 +327,7 @@ function create_configuration(inputfile; user_config, user_kwargs, type = nothin
cfg["codefence"] = pick_codefence( cfg["codefence"] = pick_codefence(
get(user_config, "flavor", cfg["flavor"]), get(user_config, "flavor", cfg["flavor"]),
get(user_config, "execute", cfg["execute"]), get(user_config, "execute", cfg["execute"]),
get(user_config, "name", replace(cfg["name"], r"\s" => "_")), get(user_config, "name", replace(cfg["name"], r"\s" => "_"))
) )
cfg["image_formats"] = _DEFAULT_IMAGE_FORMATS cfg["image_formats"] = _DEFAULT_IMAGE_FORMATS
cfg["edit_commit"] = edit_commit(inputfile, user_config) cfg["edit_commit"] = edit_commit(inputfile, user_config)
@ -391,8 +367,7 @@ function create_configuration(inputfile; user_config, user_kwargs, type = nothin
else else
get(user_config, "devurl", "dev") get(user_config, "devurl", "dev")
end end
elseif (m = match(r"refs\/pull\/(\d+)\/merge", get(ENV, "GITHUB_REF", ""))) !== elseif (m = match(r"refs\/pull\/(\d+)\/merge", get(ENV, "GITHUB_REF", ""))) !== nothing
nothing
"previews/PR$(m.captures[1])" "previews/PR$(m.captures[1])"
else else
"dev" "dev"
@ -472,12 +447,8 @@ const DEFAULT_CONFIGURATION = nothing # Dummy const for documentation
function preprocessor(inputfile, outputdir; user_config, user_kwargs, type) function preprocessor(inputfile, outputdir; user_config, user_kwargs, type)
# Create configuration by merging default and userdefined # Create configuration by merging default and userdefined
config = create_configuration( config = create_configuration(inputfile; user_config=user_config,
inputfile; user_kwargs=user_kwargs, type=type)
user_config = user_config,
user_kwargs = user_kwargs,
type = type,
)
# normalize paths # normalize paths
inputfile = normpath(inputfile) inputfile = normpath(inputfile)
@ -486,21 +457,15 @@ function preprocessor(inputfile, outputdir; user_config, user_kwargs, type)
mkpath(outputdir) mkpath(outputdir)
outputdir = realpath(abspath(outputdir)) outputdir = realpath(abspath(outputdir))
isdir(outputdir) || error("not a directory: $(outputdir)") isdir(outputdir) || error("not a directory: $(outputdir)")
ext = ext = type === (:nb) ? ".ipynb" : (type === (:md) && config["flavor"] isa QuartoFlavor) ? ".qmd" : ".$(type)"
type === (:nb) ? ".ipynb" :
(type === (:md) && config["flavor"] isa QuartoFlavor) ? ".qmd" : ".$(type)"
outputfile = joinpath(outputdir, config["name"]::String * ext) outputfile = joinpath(outputdir, config["name"]::String * ext)
if inputfile == outputfile if inputfile == outputfile
throw( throw(ArgumentError("outputfile (`$outputfile`) is identical to inputfile (`$inputfile`)"))
ArgumentError(
"outputfile (`$outputfile`) is identical to inputfile (`$inputfile`)",
),
)
end end
output_thing = output_thing = type === (:md) ? "markdown page" :
type === (:md) ? "markdown page" : type === (:nb) ? "notebook" :
type === (:nb) ? "notebook" : type === (:jl) ? "plain script file" : error("nope") type === (:jl) ? "plain script file" : error("nope")
@info "generating $(output_thing) from `$(Base.contractuser(inputfile))`" @info "generating $(output_thing) from `$(Base.contractuser(inputfile))`"
# Add some information for passing around Literate methods # Add some information for passing around Literate methods
@ -556,13 +521,8 @@ of possible configuration with `config` and other keyword arguments.
""" """
function script(inputfile, outputdir=pwd(); config::AbstractDict=Dict(), kwargs...) function script(inputfile, outputdir=pwd(); config::AbstractDict=Dict(), kwargs...)
# preprocessing and parsing # preprocessing and parsing
chunks, config = preprocessor( chunks, config =
inputfile, preprocessor(inputfile, outputdir; user_config=config, user_kwargs=kwargs, type=:jl)
outputdir;
user_config = config,
user_kwargs = kwargs,
type = :jl,
)
# create the script file # create the script file
ioscript = IOBuffer() ioscript = IOBuffer()
@ -600,13 +560,8 @@ of possible configuration with `config` and other keyword arguments.
""" """
function markdown(inputfile, outputdir=pwd(); config::AbstractDict=Dict(), kwargs...) function markdown(inputfile, outputdir=pwd(); config::AbstractDict=Dict(), kwargs...)
# preprocessing and parsing # preprocessing and parsing
chunks, config = preprocessor( chunks, config =
inputfile, preprocessor(inputfile, outputdir; user_config=config, user_kwargs=kwargs, type=:md)
outputdir;
user_config = config,
user_kwargs = kwargs,
type = :md,
)
# create the markdown file # create the markdown file
sb = sandbox() sb = sandbox()
@ -623,9 +578,7 @@ function markdown(inputfile, outputdir = pwd(); config::AbstractDict = Dict(), k
write(iocode, codefence.first) write(iocode, codefence.first)
# make sure the code block is finalized if we are printing to ```@example # make sure the code block is finalized if we are printing to ```@example
# (or ````@example, any number of backticks >= 3 works) # (or ````@example, any number of backticks >= 3 works)
if chunk.continued && if chunk.continued && occursin(r"^`{3,}@example", codefence.first) && isdocumenter(config)
occursin(r"^`{3,}@example", codefence.first) &&
isdocumenter(config)
write(iocode, "; continued = true") write(iocode, "; continued = true")
end end
write(iocode, '\n') write(iocode, '\n')
@ -643,16 +596,11 @@ function markdown(inputfile, outputdir = pwd(); config::AbstractDict = Dict(), k
any(write_line, chunk.lines) && write(iomd, seekstart(iocode)) any(write_line, chunk.lines) && write(iomd, seekstart(iocode))
if execute if execute
cd(config["literate_outputdir"]) do cd(config["literate_outputdir"]) do
execute_markdown!( execute_markdown!(iomd, sb, join(chunk.lines, '\n'), outputdir;
iomd,
sb,
join(chunk.lines, '\n'),
outputdir;
inputfile=config["literate_inputfile"], inputfile=config["literate_inputfile"],
fake_source=config["literate_outputfile"], fake_source=config["literate_outputfile"],
flavor=config["flavor"], flavor=config["flavor"],
image_formats = config["image_formats"], image_formats=config["image_formats"])
)
end end
end end
end end
@ -667,16 +615,9 @@ function markdown(inputfile, outputdir = pwd(); config::AbstractDict = Dict(), k
return outputfile return outputfile
end end
function execute_markdown!( function execute_markdown!(io::IO, sb::Module, block::String, outputdir;
io::IO, inputfile::String, fake_source::String,
sb::Module, flavor::AbstractFlavor, image_formats::Vector)
block::String,
outputdir;
inputfile::String,
fake_source::String,
flavor::AbstractFlavor,
image_formats::Vector,
)
# TODO: Deal with explicit display(...) calls # TODO: Deal with explicit display(...) calls
r, str, _ = execute_block(sb, block; inputfile=inputfile, fake_source=fake_source) r, str, _ = execute_block(sb, block; inputfile=inputfile, fake_source=fake_source)
# issue #101: consecutive codefenced blocks need newline # issue #101: consecutive codefenced blocks need newline
@ -685,8 +626,7 @@ function execute_markdown!(
if r !== nothing && !REPL.ends_with_semicolon(block) if r !== nothing && !REPL.ends_with_semicolon(block)
if (flavor isa FranklinFlavor || flavor isa DocumenterFlavor) && if (flavor isa FranklinFlavor || flavor isa DocumenterFlavor) &&
Base.invokelatest(showable, MIME("text/html"), r) Base.invokelatest(showable, MIME("text/html"), r)
htmlfence = htmlfence = flavor isa FranklinFlavor ? ("~~~" => "~~~") : ("```@raw html" => "```")
flavor isa FranklinFlavor ? ("~~~" => "~~~") : ("```@raw html" => "```")
write(io, "\n", htmlfence.first, "\n") write(io, "\n", htmlfence.first, "\n")
Base.invokelatest(show, io, MIME("text/html"), r) Base.invokelatest(show, io, MIME("text/html"), r)
write(io, "\n", htmlfence.second, "\n") write(io, "\n", htmlfence.second, "\n")
@ -745,13 +685,8 @@ of possible configuration with `config` and other keyword arguments.
""" """
function notebook(inputfile, outputdir=pwd(); config::AbstractDict=Dict(), kwargs...) function notebook(inputfile, outputdir=pwd(); config::AbstractDict=Dict(), kwargs...)
# preprocessing and parsing # preprocessing and parsing
chunks, config = preprocessor( chunks, config =
inputfile, preprocessor(inputfile, outputdir; user_config=config, user_kwargs=kwargs, type=:nb)
outputdir;
user_config = config,
user_kwargs = kwargs,
type = :nb,
)
# create the notebook # create the notebook
nb = jupyter_notebook(chunks, config) nb = jupyter_notebook(chunks, config)
@ -773,15 +708,13 @@ function jupyter_notebook(chunks, config)
chunktype = isa(chunk, MDChunk) ? "markdown" : "code" chunktype = isa(chunk, MDChunk) ? "markdown" : "code"
if !isempty(chunk.lines) && line_is_nbmeta(chunk.lines[1]) if !isempty(chunk.lines) && line_is_nbmeta(chunk.lines[1])
metatype, metadata = parse_nbmeta(chunk.lines[1]) metatype, metadata = parse_nbmeta(chunk.lines[1])
metatype !== nothing && metatype !== nothing && metatype != chunktype && error("specifying a different cell type is not supported")
metatype != chunktype &&
error("specifying a different cell type is not supported")
popfirst!(chunk.lines) popfirst!(chunk.lines)
else else
metadata = Dict{String, Any}() metadata = Dict{String, Any}()
end end
lines = lines = isa(chunk, MDChunk) ?
isa(chunk, MDChunk) ? String[x.second for x in chunk.lines] : # skip indent String[x.second for x in chunk.lines] : # skip indent
chunk.lines chunk.lines
@views map!(x -> x * '\n', lines[1:end-1], lines[1:end-1]) @views map!(x -> x * '\n', lines[1:end-1], lines[1:end-1])
cell["cell_type"] = chunktype cell["cell_type"] = chunktype
@ -820,11 +753,8 @@ function jupyter_notebook(chunks, config)
@info "executing notebook `$(config["name"] * ".ipynb")`" @info "executing notebook `$(config["name"] * ".ipynb")`"
try try
cd(config["literate_outputdir"]) do cd(config["literate_outputdir"]) do
nb = execute_notebook( nb = execute_notebook(nb; inputfile=config["literate_inputfile"],
nb; fake_source=config["literate_outputfile"])
inputfile = config["literate_inputfile"],
fake_source = config["literate_outputfile"],
)
end end
catch err catch err
@error "error when executing notebook based on input file: " * @error "error when executing notebook based on input file: " *
@ -843,8 +773,7 @@ function execute_notebook(nb; inputfile::String, fake_source::String)
execution_count += 1 execution_count += 1
cell["execution_count"] = execution_count cell["execution_count"] = execution_count
block = join(cell["source"]) block = join(cell["source"])
r, str, display_dicts = r, str, display_dicts = execute_block(sb, block; inputfile=inputfile, fake_source=fake_source)
execute_block(sb, block; inputfile = inputfile, fake_source = fake_source)
# str should go into stream # str should go into stream
if !isempty(str) if !isempty(str)
@ -946,16 +875,14 @@ function execute_block(sb::Module, block::String; inputfile::String, fake_source
end end
popdisplay(disp) # IOCapture.capture has a try-catch so should always end up here popdisplay(disp) # IOCapture.capture has a try-catch so should always end up here
if c.error if c.error
error( error("""
"""
$(sprint(showerror, c.value)) $(sprint(showerror, c.value))
when executing the following code block from inputfile `$(Base.contractuser(inputfile))` when executing the following code block from inputfile `$(Base.contractuser(inputfile))`
```julia ```julia
$block $block
``` ```
""", """)
)
end end
return c.value, c.output, disp.data return c.value, c.output, disp.data
end end

569
test/runtests.jl

@ -293,8 +293,7 @@ const GITLAB_ENV = Dict(
(k => nothing for k in keys(TRAVIS_ENV))..., (k => nothing for k in keys(TRAVIS_ENV))...,
(k => nothing for k in keys(ACTIONS_ENV))..., (k => nothing for k in keys(ACTIONS_ENV))...,
) )
@testset "Literate.script" begin @testset "Literate.script" begin; Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do
Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do
mktempdir(@__DIR__) do sandbox mktempdir(@__DIR__) do sandbox
cd(sandbox) do cd(sandbox) do
# write content to inputfile # write content to inputfile
@ -354,123 +353,69 @@ const GITLAB_ENV = Dict(
@test script == expected_script @test script == expected_script
# Travis with with PR preview build # Travis with with PR preview build
withenv(TRAVIS_ENV..., "TRAVIS_TAG" => "", "TRAVIS_PULL_REQUEST" => "42") do withenv(TRAVIS_ENV...,
"TRAVIS_TAG" => "",
"TRAVIS_PULL_REQUEST" => "42") do
Literate.script(inputfile, outdir) Literate.script(inputfile, outdir)
end end
script = read(joinpath(outdir, "inputfile.jl"), String) script = read(joinpath(outdir, "inputfile.jl"), String)
@test occursin( @test occursin("# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", script)
"# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", @test occursin("# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl", script)
script, @test occursin("# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl", script)
)
@test occursin(
"# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl",
script,
)
@test occursin(
"# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl",
script,
)
# Travis with no tag -> dev directory # Travis with no tag -> dev directory
withenv(TRAVIS_ENV..., "TRAVIS_TAG" => "") do withenv(TRAVIS_ENV...,
"TRAVIS_TAG" => "") do
Literate.script(inputfile, outdir) Literate.script(inputfile, outdir)
end end
script = read(joinpath(outdir, "inputfile.jl"), String) script = read(joinpath(outdir, "inputfile.jl"), String)
@test occursin( @test occursin("# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", script)
"# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", @test occursin("# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl", script)
script, @test occursin("# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl", script)
)
@test occursin(
"# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl",
script,
)
@test occursin(
"# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl",
script,
)
# GitHub Actions with a tag # GitHub Actions with a tag
withenv(ACTIONS_ENV...) do withenv(ACTIONS_ENV...) do
Literate.script(inputfile, outdir) Literate.script(inputfile, outdir)
end end
script = read(joinpath(outdir, "inputfile.jl"), String) script = read(joinpath(outdir, "inputfile.jl"), String)
@test occursin( @test occursin("# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", script)
"# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", @test occursin("# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/file.jl", script)
script, @test occursin("# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl", script)
)
@test occursin(
"# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/file.jl",
script,
)
@test occursin(
"# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl",
script,
)
# GitHub Actions with PR preview build # GitHub Actions with PR preview build
withenv( withenv(ACTIONS_ENV...,
ACTIONS_ENV...,
"GITHUB_EVENT_NAME" => "pull_request", "GITHUB_EVENT_NAME" => "pull_request",
"GITHUB_REF" => "refs/pull/42/merge", "GITHUB_REF" => "refs/pull/42/merge") do
) do
Literate.script(inputfile, outdir) Literate.script(inputfile, outdir)
end end
script = read(joinpath(outdir, "inputfile.jl"), String) script = read(joinpath(outdir, "inputfile.jl"), String)
@test occursin( @test occursin("# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", script)
"# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", @test occursin("# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl", script)
script, @test occursin("# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl", script)
)
@test occursin(
"# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl",
script,
)
@test occursin(
"# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl",
script,
)
# GitHub Actions without a tag -> dev directory # GitHub Actions without a tag -> dev directory
withenv(ACTIONS_ENV..., "GITHUB_REF" => "refs/heads/master") do withenv(ACTIONS_ENV...,
"GITHUB_REF" => "refs/heads/master") do
Literate.script(inputfile, outdir) Literate.script(inputfile, outdir)
end end
script = read(joinpath(outdir, "inputfile.jl"), String) script = read(joinpath(outdir, "inputfile.jl"), String)
@test occursin( @test occursin("# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", script)
"# Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", @test occursin("# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl", script)
script, @test occursin("# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl", script)
)
@test occursin(
"# Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl",
script,
)
@test occursin(
"# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl",
script,
)
# building under DocumentationGenerator.jl # building under DocumentationGenerator.jl
withenv( withenv("DOCUMENTATIONGENERATOR" => "true",
"DOCUMENTATIONGENERATOR" => "true", "DOCUMENTATIONGENERATOR_BASE_URL" => "pkg.julialang.org/docs/Literate/XPnWG/1.2.0") do
"DOCUMENTATIONGENERATOR_BASE_URL" => "pkg.julialang.org/docs/Literate/XPnWG/1.2.0",
) do
Literate.script(inputfile, outdir) Literate.script(inputfile, outdir)
end end
script = read(joinpath(outdir, "inputfile.jl"), String) script = read(joinpath(outdir, "inputfile.jl"), String)
@test occursin( @test occursin("jupyter.org/urls/pkg.julialang.org/docs/Literate/XPnWG/1.2.0/file.jl", script)
"jupyter.org/urls/pkg.julialang.org/docs/Literate/XPnWG/1.2.0/file.jl", @test_broken occursin("https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", script)
script,
)
@test_broken occursin(
"https://github.com/fredrikekre/Literate.jl/blob/master/file.jl",
script,
)
# pre- and post-processing # pre- and post-processing
Literate.script( Literate.script(inputfile, outdir,
inputfile,
outdir,
preprocess = x -> replace(x, "PLACEHOLDER3" => "3REDLOHECALP"), preprocess = x -> replace(x, "PLACEHOLDER3" => "3REDLOHECALP"),
postprocess = x -> replace(x, "PLACEHOLDER4" => "4REDLOHECALP"), postprocess = x -> replace(x, "PLACEHOLDER4" => "4REDLOHECALP"))
)
script = read(joinpath(outdir, "inputfile.jl"), String) script = read(joinpath(outdir, "inputfile.jl"), String)
@test !occursin("PLACEHOLDER1", script) @test !occursin("PLACEHOLDER1", script)
@test !occursin("PLACEHOLDER2", script) @test !occursin("PLACEHOLDER2", script)
@ -497,9 +442,7 @@ const GITLAB_ENV = Dict(
# mdstrings # mdstrings
mdstrings_file = "inputfile_mdstrings.jl" mdstrings_file = "inputfile_mdstrings.jl"
write( write(mdstrings_file, """
mdstrings_file,
"""
md\"\"\" md\"\"\"
# Markdown header # Markdown header
@ -514,14 +457,9 @@ Content of the multiline
comment comment
===# ===#
2 + 2 2 + 2
""", """)
) Literate.script(mdstrings_file, outdir,
Literate.script( keep_comments = true, credit=false)
mdstrings_file,
outdir,
keep_comments = true,
credit = false,
)
script = read(joinpath(outdir, mdstrings_file), String) script = read(joinpath(outdir, mdstrings_file), String)
@test strip(script) == """ @test strip(script) == """
md\"\"\" md\"\"\"
@ -538,13 +476,8 @@ comment
# comment # comment
2 + 2""" 2 + 2"""
Literate.script( Literate.script(mdstrings_file, outdir,
mdstrings_file, keep_comments = true, mdstrings = true, credit=false)
outdir,
keep_comments = true,
mdstrings = true,
credit = false,
)
script = read(joinpath(outdir, mdstrings_file), String) script = read(joinpath(outdir, mdstrings_file), String)
@test strip(script) == """ @test strip(script) == """
# # Markdown header # # Markdown header
@ -568,11 +501,9 @@ comment
@test_throws ArgumentError Literate.script(inputfile) @test_throws ArgumentError Literate.script(inputfile)
end end
end end
end end end
end
@testset "Literate.markdown" begin @testset "Literate.markdown" begin; Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do
Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do
mktempdir(@__DIR__) do sandbox mktempdir(@__DIR__) do sandbox
cd(sandbox) do cd(sandbox) do
# write content to inputfile # write content to inputfile
@ -708,171 +639,84 @@ end
@test markdown == expected_markdown @test markdown == expected_markdown
# Travis with PR preview build # Travis with PR preview build
withenv(TRAVIS_ENV..., "TRAVIS_TAG" => "", "TRAVIS_PULL_REQUEST" => "42") do withenv(TRAVIS_ENV...,
"TRAVIS_TAG" => "",
"TRAVIS_PULL_REQUEST" => "42") do
Literate.markdown(inputfile, outdir) Literate.markdown(inputfile, outdir)
end end
markdown = read(joinpath(outdir, "inputfile.md"), String) markdown = read(joinpath(outdir, "inputfile.md"), String)
@test occursin( @test occursin("Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", markdown)
"Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", @test occursin("Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl", markdown)
markdown, @test occursin("Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl", markdown)
) @test occursin("EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", markdown)
@test occursin(
"Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl",
markdown,
)
@test occursin(
"Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl",
markdown,
)
@test occursin(
"EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"",
markdown,
)
# Travis with no tag -> dev directory # Travis with no tag -> dev directory
withenv(TRAVIS_ENV..., "TRAVIS_TAG" => "") do withenv(TRAVIS_ENV...,
"TRAVIS_TAG" => "") do
Literate.markdown(inputfile, outdir) Literate.markdown(inputfile, outdir)
end end
markdown = read(joinpath(outdir, "inputfile.md"), String) markdown = read(joinpath(outdir, "inputfile.md"), String)
@test occursin( @test occursin("Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", markdown)
"Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", @test occursin("Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl", markdown)
markdown, @test occursin("Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl", markdown)
) @test occursin("EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", markdown)
@test occursin(
"Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl",
markdown,
)
@test occursin(
"Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl",
markdown,
)
@test occursin(
"EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"",
markdown,
)
# GitHub Actions with a tag # GitHub Actions with a tag
withenv(ACTIONS_ENV...) do withenv(ACTIONS_ENV...) do
Literate.markdown(inputfile, outdir) Literate.markdown(inputfile, outdir)
end end
markdown = read(joinpath(outdir, "inputfile.md"), String) markdown = read(joinpath(outdir, "inputfile.md"), String)
@test occursin( @test occursin("Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", markdown)
"Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", @test occursin("Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/file.jl", markdown)
markdown, @test occursin("Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl", markdown)
) @test occursin("EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", markdown)
@test occursin(
"Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/file.jl",
markdown,
)
@test occursin(
"Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl",
markdown,
)
@test occursin(
"EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"",
markdown,
)
# GitHub Actions with PR preview build # GitHub Actions with PR preview build
withenv( withenv(ACTIONS_ENV...,
ACTIONS_ENV...,
"GITHUB_REF" => "refs/pull/42/merge", "GITHUB_REF" => "refs/pull/42/merge",
"GITHUB_EVENT_NAME" => "pull_request", "GITHUB_EVENT_NAME" => "pull_request") do
) do
Literate.markdown(inputfile, outdir) Literate.markdown(inputfile, outdir)
end end
markdown = read(joinpath(outdir, "inputfile.md"), String) markdown = read(joinpath(outdir, "inputfile.md"), String)
@test occursin( @test occursin("Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", markdown)
"Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", @test occursin("Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl", markdown)
markdown, @test occursin("Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl", markdown)
) @test occursin("EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", markdown)
@test occursin(
"Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/file.jl",
markdown,
)
@test occursin(
"Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=previews/PR42/file.jl",
markdown,
)
@test occursin(
"EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"",
markdown,
)
# GitHub Actions without a tag -> dev directory # GitHub Actions without a tag -> dev directory
withenv(ACTIONS_ENV..., "GITHUB_REF" => "refs/heads/master") do withenv(ACTIONS_ENV...,
"GITHUB_REF" => "refs/heads/master") do
Literate.markdown(inputfile, outdir) Literate.markdown(inputfile, outdir)
end end
markdown = read(joinpath(outdir, "inputfile.md"), String) markdown = read(joinpath(outdir, "inputfile.md"), String)
@test occursin( @test occursin("Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", markdown)
"Link to repo root: https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", @test occursin("Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl", markdown)
markdown, @test occursin("Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl", markdown)
) @test occursin("EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", markdown)
@test occursin(
"Link to nbviewer: https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/dev/file.jl",
markdown,
)
@test occursin(
"Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl",
markdown,
)
@test occursin(
"EditURL = \"https://github.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"",
markdown,
)
# GitLab CI with GitLab Pages # GitLab CI with GitLab Pages
withenv(GITLAB_ENV...) do withenv(GITLAB_ENV...) do
Literate.markdown(inputfile, outdir) Literate.markdown(inputfile, outdir)
end end
markdown = read(joinpath(outdir, "inputfile.md"), String) markdown = read(joinpath(outdir, "inputfile.md"), String)
@test occursin( @test occursin("Link to repo root: https://gitlab.com/fredrikekre/Literate.jl/blob/master/file.jl", markdown)
"Link to repo root: https://gitlab.com/fredrikekre/Literate.jl/blob/master/file.jl", @test occursin("Link to nbviewer: https://nbviewer.jupyter.org/urls/fredrikekre.gitlab.io/Literate.jl/file.jl", markdown)
markdown, @test_broken occursin("Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl", markdown)
) @test occursin("EditURL = \"https://gitlab.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"", markdown)
@test occursin(
"Link to nbviewer: https://nbviewer.jupyter.org/urls/fredrikekre.gitlab.io/Literate.jl/file.jl",
markdown,
)
@test_broken occursin(
"Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=dev/file.jl",
markdown,
)
@test occursin(
"EditURL = \"https://gitlab.com/fredrikekre/Literate.jl/blob/master/test/$(basename(sandbox))/inputfile.jl\"",
markdown,
)
# building under DocumentationGenerator.jl # building under DocumentationGenerator.jl
withenv( withenv("DOCUMENTATIONGENERATOR" => "true",
"DOCUMENTATIONGENERATOR" => "true", "DOCUMENTATIONGENERATOR_BASE_URL" => "pkg.julialang.org/docs/Literate/XPnWG/1.2.0") do
"DOCUMENTATIONGENERATOR_BASE_URL" => "pkg.julialang.org/docs/Literate/XPnWG/1.2.0",
) do
Literate.markdown(inputfile, outdir) Literate.markdown(inputfile, outdir)
end end
markdown = read(joinpath(outdir, "inputfile.md"), String) markdown = read(joinpath(outdir, "inputfile.md"), String)
@test occursin( @test occursin("jupyter.org/urls/pkg.julialang.org/docs/Literate/XPnWG/1.2.0/file.jl", markdown)
"jupyter.org/urls/pkg.julialang.org/docs/Literate/XPnWG/1.2.0/file.jl", @test_broken occursin("https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", markdown)
markdown,
)
@test_broken occursin(
"https://github.com/fredrikekre/Literate.jl/blob/master/file.jl",
markdown,
)
# pre- and post-processing # pre- and post-processing
Literate.markdown( Literate.markdown(inputfile, outdir,
inputfile, preprocess = x -> replace(replace(x, "PLACEHOLDER1" => "1REDLOHECALP"), "PLACEHOLDER3" => "3REDLOHECALP"),
outdir, postprocess = x -> replace(replace(x, "PLACEHOLDER2" => "2REDLOHECALP"), "PLACEHOLDER4" => "4REDLOHECALP"))
preprocess = x -> replace(
replace(x, "PLACEHOLDER1" => "1REDLOHECALP"),
"PLACEHOLDER3" => "3REDLOHECALP",
),
postprocess = x -> replace(
replace(x, "PLACEHOLDER2" => "2REDLOHECALP"),
"PLACEHOLDER4" => "4REDLOHECALP",
),
)
markdown = read(joinpath(outdir, "inputfile.md"), String) markdown = read(joinpath(outdir, "inputfile.md"), String)
@test !occursin("PLACEHOLDER1", markdown) @test !occursin("PLACEHOLDER1", markdown)
@test !occursin("PLACEHOLDER2", markdown) @test !occursin("PLACEHOLDER2", markdown)
@ -894,21 +738,10 @@ end
# flavor = QuartoFlavor() # flavor = QuartoFlavor()
# execution of Quarto markdown is not allowed # execution of Quarto markdown is not allowed
let expected_error = ErrorException( let expected_error = ErrorException("QuartoFlavor does not support argument execute=true!")
"QuartoFlavor does not support argument execute=true!", @test_throws expected_error Literate.markdown("quarto.jl",flavor=Literate.QuartoFlavor(),execute=true)
)
@test_throws expected_error Literate.markdown(
"quarto.jl",
flavor = Literate.QuartoFlavor(),
execute = true,
)
end end
Literate.markdown( Literate.markdown(inputfile, outdir, flavor = Literate.QuartoFlavor(),execute=false)
inputfile,
outdir,
flavor = Literate.QuartoFlavor(),
execute = false,
)
markdown = read(joinpath(outdir, "inputfile.qmd"), String) markdown = read(joinpath(outdir, "inputfile.qmd"), String)
@test occursin("```{julia}", markdown) @test occursin("```{julia}", markdown)
@test !occursin(r"`{3,}@example", markdown) @test !occursin(r"`{3,}@example", markdown)
@ -957,9 +790,7 @@ end
@test !occursin("blob/master/", markdown) @test !occursin("blob/master/", markdown)
# execute # execute
write( write(inputfile, """
inputfile,
"""
using DisplayAs using DisplayAs
#- #-
1+1 1+1
@ -1014,8 +845,7 @@ end
(@__DIR__) == pwd() ? "cwd correct" : "cwd incorrect" (@__DIR__) == pwd() ? "cwd correct" : "cwd incorrect"
#- #-
basename(@__FILE__) basename(@__FILE__)
""", """)
)
Literate.markdown(inputfile, outdir; execute=true) Literate.markdown(inputfile, outdir; execute=true)
markdown = read(joinpath(outdir, "inputfile.md"), String) markdown = read(joinpath(outdir, "inputfile.md"), String)
@test occursin("```\n2\n```", markdown) # text/plain @test occursin("```\n2\n```", markdown) # text/plain
@ -1041,25 +871,14 @@ end
@test occursin("```\n\"inputfile.md\"\n```", markdown) # Correct source file (@__FILE__) @test occursin("```\n\"inputfile.md\"\n```", markdown) # Correct source file (@__FILE__)
# FranklinFlavor # FranklinFlavor
Literate.markdown( Literate.markdown(inputfile, outdir; execute=true, flavor=Literate.FranklinFlavor())
inputfile,
outdir;
execute = true,
flavor = Literate.FranklinFlavor(),
)
markdown = read(joinpath(outdir, "inputfile.md"), String) markdown = read(joinpath(outdir, "inputfile.md"), String)
@test occursin("# MD", markdown) # text/markdown @test occursin("# MD", markdown) # text/markdown
@test occursin("~~~\n<h1>MD</h1>\n~~~", markdown) # text/html @test occursin("~~~\n<h1>MD</h1>\n~~~", markdown) # text/html
# QuartoFlavor file extension # QuartoFlavor file extension
write(inputfile, "#=\r\nhello world\n=#\r\n") write(inputfile, "#=\r\nhello world\n=#\r\n")
_, config = Literate.preprocessor( _, config = Literate.preprocessor(inputfile, outdir; user_kwargs=(), user_config=Dict("flavor"=>Literate.QuartoFlavor()), type=:md)
inputfile,
outdir;
user_kwargs = (),
user_config = Dict("flavor" => Literate.QuartoFlavor()),
type = :md,
)
@test config["literate_ext"] == ".qmd" @test config["literate_ext"] == ".qmd"
# verify that inputfile exists # verify that inputfile exists
@ -1072,39 +891,23 @@ end
# fredrikekre/Literate.jl#165: \r\n line endings with multiline comments/mdstrings # fredrikekre/Literate.jl#165: \r\n line endings with multiline comments/mdstrings
write(inputfile, "#=\r\nhello world\r\nhej världen\r\n=#\r\n") write(inputfile, "#=\r\nhello world\r\nhej världen\r\n=#\r\n")
chunks, _ = Literate.preprocessor( chunks, _ = Literate.preprocessor(inputfile, outdir; user_kwargs=(), user_config=(), type=:md)
inputfile,
outdir;
user_kwargs = (),
user_config = (),
type = :md,
)
@test chunks[2].lines == ["" => "hello world", "" => "hej världen"] @test chunks[2].lines == ["" => "hello world", "" => "hej världen"]
write(inputfile, "md\"\"\"\r\nhello world\r\nhej världen\r\n\"\"\"\r\n") write(inputfile, "md\"\"\"\r\nhello world\r\nhej världen\r\n\"\"\"\r\n")
chunks, _ = Literate.preprocessor( chunks, _ = Literate.preprocessor(inputfile, outdir; user_kwargs=pairs((; mdstrings=true)),
inputfile, user_config=(), type=:md)
outdir;
user_kwargs = pairs((; mdstrings = true)),
user_config = (),
type = :md,
)
@test chunks[2].lines == ["" => "hello world", "" => "hej världen"] @test chunks[2].lines == ["" => "hello world", "" => "hej världen"]
# fredrikekre/Literate.jl#168 # fredrikekre/Literate.jl#168
f = "file with space.jl" f = "file with space.jl"
write(f, "1 + 1") write(f, "1 + 1")
Literate.markdown(f, outdir) Literate.markdown(f, outdir)
@test occursin( @test occursin("file_with_space", read(joinpath(outdir, "file with space.md"), String))
"file_with_space",
read(joinpath(outdir, "file with space.md"), String),
)
end
end
end end
end end
end end
@testset "Literate.notebook" begin @testset "Literate.notebook" begin; Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do
Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do
mktempdir(@__DIR__) do sandbox mktempdir(@__DIR__) do sandbox
cd(sandbox) do cd(sandbox) do
# write content to inputfile # write content to inputfile
@ -1116,52 +919,59 @@ end
withenv(TRAVIS_ENV...) do withenv(TRAVIS_ENV...) do
Literate.notebook(inputfile, outdir, execute = false) Literate.notebook(inputfile, outdir, execute = false)
end end
expected_cells = expected_cells = rstrip.((
rstrip.((
""" """
"cells": [ "cells": [
""", """,
""" """
"source": [ "source": [
"# Example\\n", "# Example\\n",
"foo, bar" "foo, bar"
] ]
""", """,
""" """
"source": [ "source": [
"x = 1" "x = 1"
] ]
""", """,
""" """
"source": [ "source": [
"Not markdown\\n", "Not markdown\\n",
"Not markdown" "Not markdown"
], ],
""", """,
""" """
"source": [ "source": [
"x * 1\\n", "x * 1\\n",
"x * 1" "x * 1"
], ],
""", """,
""" """
"source": [ "source": [
"Only notebook\\n", "Only notebook\\n",
"Only notebook" "Only notebook"
] ]
""", """,
""" """
"source": [ "source": [
"x + 2\\n", "x + 2\\n",
"x + 2" "x + 2"
] ]
""", """,
""" """
"source": [ "source": [
"Not script\\n", "Not script\\n",
"Not script" "Not script"
], ],
""", """,
""" """
"source": [ "source": [
"x * 3\\n", "x * 3\\n",
@ -1171,6 +981,7 @@ end
"#| echo: false Quarto parameters" "#| echo: false Quarto parameters"
], ],
""", """,
""" """
"source": [ "source": [
"for i in 1:10\\n", "for i in 1:10\\n",
@ -1179,6 +990,7 @@ end
"end" "end"
] ]
""", """,
""" """
"source": [ "source": [
"name: inputfile\\n", "name: inputfile\\n",
@ -1187,6 +999,7 @@ end
"Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl" "Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl"
] ]
""", """,
""" """
"source": [ "source": [
"# name: inputfile\\n", "# name: inputfile\\n",
@ -1195,18 +1008,21 @@ end
"# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl" "# Link to binder: https://mybinder.org/v2/gh/fredrikekre/Literate.jl/gh-pages?filepath=v1.2.0/file.jl"
] ]
""", """,
""" """
"source": [ "source": [
"PLACEHOLDER1\\n", "PLACEHOLDER1\\n",
"PLACEHOLDER2" "PLACEHOLDER2"
] ]
""", """,
""" """
"source": [ "source": [
"# PLACEHOLDER3\\n", "# PLACEHOLDER3\\n",
"# PLACEHOLDER4" "# PLACEHOLDER4"
] ]
""", """,
""" """
"source": [ "source": [
"Some inline math: \$\\\\frac{df}{dx}\$, some multiline inline math: \$y =\\n", "Some inline math: \$\\\\frac{df}{dx}\$, some multiline inline math: \$y =\\n",
@ -1216,11 +1032,13 @@ end
"\$\$" "\$\$"
] ]
""", """,
""" """
"source": [ "source": [
"Indented markdown" "Indented markdown"
] ]
""", """,
""" """
"source": [ "source": [
"for i in 1:10\\n", "for i in 1:10\\n",
@ -1229,25 +1047,27 @@ end
"end" "end"
] ]
""", """,
""" """
"metadata": { "metadata": {
"meta": "data" "meta": "data"
} }
""", """,
""" """
"source": [ "source": [
"First multiline\\n", "First multiline\\n",
"comment" "comment"
] ]
""", """,
""" """
"source": [ "source": [
"---\\n", "---\\n",
"\\n", "\\n",
"*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" "*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*"
] ]
""", """))
))
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) notebook = read(joinpath(outdir, "inputfile.ipynb"), String)
@ -1258,25 +1078,16 @@ end
lastidx = nextind(notebook, last(idx)) lastidx = nextind(notebook, last(idx))
end end
# test some of the required metadata # test some of the required metadata
for metadata in ( for metadata in (" \"nbformat\": ", " \"nbformat_minor\": ", " \"metadata\": {", " \"language_info\": {",
" \"nbformat\": ", " \"file_extension\": \".jl\"", " \"mimetype\": \"application/julia\"",
" \"nbformat_minor\": ", " \"name\": \"julia\"", " \"version\": ", " \"kernelspec\": {",
" \"metadata\": {", " \"name\": \"julia-", " \"display_name\": \"Julia ", " \"language\": \"julia\"")
" \"language_info\": {",
" \"file_extension\": \".jl\"",
" \"mimetype\": \"application/julia\"",
" \"name\": \"julia\"",
" \"version\": ",
" \"kernelspec\": {",
" \"name\": \"julia-",
" \"display_name\": \"Julia ",
" \"language\": \"julia\"",
)
@test occursin(metadata, notebook) @test occursin(metadata, notebook)
end end
# no tag -> latest directory # no tag -> latest directory
withenv(TRAVIS_ENV..., "TRAVIS_TAG" => "") do withenv(TRAVIS_ENV...,
"TRAVIS_TAG" => "") do
Literate.notebook(inputfile, outdir, execute = false) Literate.notebook(inputfile, outdir, execute = false)
end end
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) notebook = read(joinpath(outdir, "inputfile.ipynb"), String)
@ -1290,65 +1101,44 @@ end
@test occursin("fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/", notebook) @test occursin("fredrikekre/Literate.jl/blob/gh-pages/v1.2.0/", notebook)
# GitHub Actions with PR preview build # GitHub Actions with PR preview build
withenv( withenv(ACTIONS_ENV...,
ACTIONS_ENV...,
"GITHUB_REF" => "refs/pull/42/merge", "GITHUB_REF" => "refs/pull/42/merge",
"GITHUB_EVENT_NAME" => "pull_request", "GITHUB_EVENT_NAME" => "pull_request") do
) do
Literate.notebook(inputfile, outdir, execute = false) Literate.notebook(inputfile, outdir, execute = false)
end end
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) notebook = read(joinpath(outdir, "inputfile.ipynb"), String)
@test occursin( @test occursin("fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/", notebook)
"fredrikekre/Literate.jl/blob/gh-pages/previews/PR42/",
notebook,
)
# GitHub Actions without a tag # GitHub Actions without a tag
withenv(ACTIONS_ENV..., "GITHUB_REF" => "refs/heads/master") do withenv(ACTIONS_ENV...,
"GITHUB_REF" => "refs/heads/master") do
Literate.notebook(inputfile, outdir, execute = false) Literate.notebook(inputfile, outdir, execute = false)
end end
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) notebook = read(joinpath(outdir, "inputfile.ipynb"), String)
@test occursin("fredrikekre/Literate.jl/blob/gh-pages/dev/", notebook) @test occursin("fredrikekre/Literate.jl/blob/gh-pages/dev/", notebook)
# building under DocumentationGenerator.jl # building under DocumentationGenerator.jl
withenv( withenv("DOCUMENTATIONGENERATOR" => "true",
"DOCUMENTATIONGENERATOR" => "true", "DOCUMENTATIONGENERATOR_BASE_URL" => "pkg.julialang.org/docs/Literate/XPnWG/1.2.0") do
"DOCUMENTATIONGENERATOR_BASE_URL" => "pkg.julialang.org/docs/Literate/XPnWG/1.2.0",
) do
Literate.notebook(inputfile, outdir, execute = false) Literate.notebook(inputfile, outdir, execute = false)
end end
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) notebook = read(joinpath(outdir, "inputfile.ipynb"), String)
@test occursin( @test occursin("jupyter.org/urls/pkg.julialang.org/docs/Literate/XPnWG/1.2.0/file.jl", notebook)
"jupyter.org/urls/pkg.julialang.org/docs/Literate/XPnWG/1.2.0/file.jl", @test_broken occursin("https://github.com/fredrikekre/Literate.jl/blob/master/file.jl", notebook)
notebook,
)
@test_broken occursin(
"https://github.com/fredrikekre/Literate.jl/blob/master/file.jl",
notebook,
)
# pre- and post-processing # pre- and post-processing
function post(nb) function post(nb)
for cell in nb["cells"] for cell in nb["cells"]
for i in eachindex(cell["source"]) for i in eachindex(cell["source"])
cell["source"][i] = cell["source"][i] = replace(cell["source"][i], "PLACEHOLDER2" => "2REDLOHECALP")
replace(cell["source"][i], "PLACEHOLDER2" => "2REDLOHECALP") cell["source"][i] = replace(cell["source"][i], "PLACEHOLDER4" => "4REDLOHECALP")
cell["source"][i] =
replace(cell["source"][i], "PLACEHOLDER4" => "4REDLOHECALP")
end end
end end
return nb return nb
end end
Literate.notebook( Literate.notebook(inputfile, outdir, execute = false,
inputfile, preprocess = x -> replace(replace(x, "PLACEHOLDER1" => "1REDLOHECALP"), "PLACEHOLDER3" => "3REDLOHECALP"),
outdir, postprocess = post)
execute = false,
preprocess = x -> replace(
replace(x, "PLACEHOLDER1" => "1REDLOHECALP"),
"PLACEHOLDER3" => "3REDLOHECALP",
),
postprocess = post,
)
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) notebook = read(joinpath(outdir, "inputfile.ipynb"), String)
@test !occursin("PLACEHOLDER1", notebook) @test !occursin("PLACEHOLDER1", notebook)
@test !occursin("PLACEHOLDER2", notebook) @test !occursin("PLACEHOLDER2", notebook)
@ -1361,12 +1151,7 @@ end
# documenter = false (deprecated) # documenter = false (deprecated)
@test_deprecated r"The documenter=false keyword to Literate.notebook is deprecated." begin @test_deprecated r"The documenter=false keyword to Literate.notebook is deprecated." begin
Literate.notebook( Literate.notebook(inputfile, outdir, documenter = false, execute = false)
inputfile,
outdir,
documenter = false,
execute = false,
)
end end
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) notebook = read(joinpath(outdir, "inputfile.ipynb"), String)
@test !occursin("# [Example](@id example-id", notebook) @test !occursin("# [Example](@id example-id", notebook)
@ -1381,22 +1166,22 @@ end
# execute = true # execute = true
Literate.notebook(inputfile, outdir) Literate.notebook(inputfile, outdir)
expected_outputs = expected_outputs = rstrip.((
rstrip.((
""" """
"cells": [ "cells": [
""", """,
""" """
"data": { "data": {
"text/plain": "3" "text/plain": "3"
}, },
""", """,
""" """
"text": [ "text": [
"12345678910" "12345678910"
] ]
""", """))
))
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) notebook = read(joinpath(outdir, "inputfile.ipynb"), String)
@ -1412,27 +1197,18 @@ end
write(joinpath(outdir, "issue31.jl"), "10 + 21") write(joinpath(outdir, "issue31.jl"), "10 + 21")
Literate.notebook(inputfile, outdir) Literate.notebook(inputfile, outdir)
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) notebook = read(joinpath(outdir, "inputfile.ipynb"), String)
@test occursin( @test occursin("\"data\": {\n \"text/plain\": \"31\"\n }", notebook)
"\"data\": {\n \"text/plain\": \"31\"\n }",
notebook,
)
# test error when executing notebook # test error when executing notebook
write(inputfile, "for i in 1:10\n println(i)") write(inputfile, "for i in 1:10\n println(i)")
r = @test_logs( r = @test_logs((:error, r"error when executing notebook based on input file: "), match_mode=:any,
(:error, r"error when executing notebook based on input file: "),
match_mode = :any,
try try
Literate.notebook(inputfile, outdir) Literate.notebook(inputfile, outdir)
catch err catch err
err err
end end)
)
@test isa(r, ErrorException) @test isa(r, ErrorException)
@test occursin( @test occursin("when executing the following code block from inputfile ", r.msg)
"when executing the following code block from inputfile ",
r.msg,
)
@test occursin(inputfile, r.msg) @test occursin(inputfile, r.msg)
# verify that inputfile exists # verify that inputfile exists
@ -1444,9 +1220,7 @@ end
@test isfile("inputfile.ipynb") @test isfile("inputfile.ipynb")
# world time problem with `IJulia.display_dict` # world time problem with `IJulia.display_dict`
write( write(inputfile, """
inputfile,
"""
struct VegaLiteRenderable end struct VegaLiteRenderable end
Base.show(io::IO, ::MIME"application/vnd.vegalite.v2+json", ::VegaLiteRenderable) = Base.show(io::IO, ::MIME"application/vnd.vegalite.v2+json", ::VegaLiteRenderable) =
write(io, \"\"\" write(io, \"\"\"
@ -1454,8 +1228,7 @@ end
\"\"\") \"\"\")
Base.Multimedia.istextmime(::MIME{Symbol("application/vnd.vegalite.v2+json")}) = true Base.Multimedia.istextmime(::MIME{Symbol("application/vnd.vegalite.v2+json")}) = true
VegaLiteRenderable() VegaLiteRenderable()
""", """)
)
Literate.notebook(inputfile, outdir) Literate.notebook(inputfile, outdir)
notebook = read(joinpath(outdir, "inputfile.ipynb"), String) notebook = read(joinpath(outdir, "inputfile.ipynb"), String)
@test occursin("\"application/vnd.vegalite.v2+json\":", notebook) @test occursin("\"application/vnd.vegalite.v2+json\":", notebook)
@ -1496,7 +1269,7 @@ end
push!(xs, x) push!(xs, x)
end end
""" """
for i = 1:9 for i in 1:9
script *= "\n#-\nxs[$i]" script *= "\n#-\nxs[$i]"
end end
write(inputfile, script) write(inputfile, script)
@ -1522,10 +1295,9 @@ end
# Cell 2 has 3 outputs: 2 display and one execute result # Cell 2 has 3 outputs: 2 display and one execute result
cellout = cells[2]["outputs"] cellout = cells[2]["outputs"]
@test length(cellout) == 3 @test length(cellout) == 3
for i = 1:3 for i in 1:3
exe_res = i == 3 exe_res = i == 3
@test cellout[i]["output_type"] == @test cellout[i]["output_type"] == (exe_res ? "execute_result" : "display_data")
(exe_res ? "execute_result" : "display_data")
@test keys(cellout[i]["data"]) == Set(("text/plain", "text/html")) @test keys(cellout[i]["data"]) == Set(("text/plain", "text/html"))
@test cellout[i]["data"]["text/plain"] == "DF($i) as text/plain" @test cellout[i]["data"]["text/plain"] == "DF($i) as text/plain"
@test cellout[i]["data"]["text/html"] == Any["DF($i) as text/html"] @test cellout[i]["data"]["text/html"] == Any["DF($i) as text/html"]
@ -1540,11 +1312,9 @@ end
@test !haskey(cellout[1], "execution_count") @test !haskey(cellout[1], "execution_count")
end end
end end
end end end
end
@testset "Configuration" begin @testset "Configuration" begin; Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do
Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do
mktempdir(@__DIR__) do sandbox mktempdir(@__DIR__) do sandbox
cd(sandbox) do cd(sandbox) do
# write content to inputfile # write content to inputfile
@ -1559,12 +1329,10 @@ end
) )
# Overwriting of URLs # Overwriting of URLs
withenv( withenv("TRAVIS_REPO_SLUG" => "fredrikekre/Literate.jl",
"TRAVIS_REPO_SLUG" => "fredrikekre/Literate.jl",
"TRAVIS_TAG" => "", "TRAVIS_TAG" => "",
"TRAVIS_PULL_REQUEST" => "false", "TRAVIS_PULL_REQUEST" => "false",
"HAS_JOSH_K_SEAL_OF_APPROVAL" => "true", "HAS_JOSH_K_SEAL_OF_APPROVAL" => "true") do
) do
Literate.script(inputfile, outdir; config=config) Literate.script(inputfile, outdir; config=config)
end end
script = read(joinpath(outdir, "inputfile.jl"), String) script = read(joinpath(outdir, "inputfile.jl"), String)
@ -1573,35 +1341,19 @@ end
@test occursin("Link to binder: www.example3.com/file.jl", script) @test occursin("Link to binder: www.example3.com/file.jl", script)
# Test pick_codefence function # Test pick_codefence function
default_codefence = default_codefence=pick_codefence(Literate.DefaultFlavor(),true,"testname")
pick_codefence(Literate.DefaultFlavor(), true, "testname")
@test default_codefence == ("````julia" => "````") @test default_codefence == ("````julia" => "````")
@test default_codefence == @test default_codefence == pick_codefence(Literate.FranklinFlavor(),true,"testname")
pick_codefence(Literate.FranklinFlavor(), true, "testname") @test default_codefence == pick_codefence(Literate.DocumenterFlavor(),true,"testname")
@test default_codefence ==
pick_codefence(Literate.DocumenterFlavor(), true, "testname")
documenter_codefence = ("````@example testname" => "````") documenter_codefence = ("````@example testname" => "````")
@test documenter_codefence == @test documenter_codefence == pick_codefence(Literate.DocumenterFlavor(),false,"testname")
pick_codefence(Literate.DocumenterFlavor(), false, "testname") let expected_exception=ErrorException("QuartoFlavor does not support argument execute=true!")
let expected_exception = ErrorException( @test_throws expected_exception pick_codefence(Literate.QuartoFlavor(),true,"testname")
"QuartoFlavor does not support argument execute=true!",
)
@test_throws expected_exception pick_codefence(
Literate.QuartoFlavor(),
true,
"testname",
)
end end
@test ("```{julia}" => "```") == @test ("```{julia}" => "```") == pick_codefence(Literate.QuartoFlavor(),false,"testname")
pick_codefence(Literate.QuartoFlavor(), false, "testname")
# Misc default configs # Misc default configs
create(; type, kw...) = Literate.create_configuration( create(; type, kw...) = Literate.create_configuration(inputfile; user_config=Dict(), user_kwargs=kw, type=type)
inputfile;
user_config = Dict(),
user_kwargs = kw,
type = type,
)
cfg = create(; type=:md, execute=true) cfg = create(; type=:md, execute=true)
@test cfg["execute"] @test cfg["execute"]
@test cfg["codefence"] == ("````julia" => "````") @test cfg["codefence"] == ("````julia" => "````")
@ -1610,5 +1362,4 @@ end
@test cfg["codefence"] == ("````@example inputfile" => "````") @test cfg["codefence"] == ("````@example inputfile" => "````")
end end
end end
end end end
end

Loading…
Cancel
Save