mirror of https://github.com/mpastell/Weave.jl
update test
parent
872f7c7153
commit
092adb6805
|
@ -32,6 +32,8 @@ end
|
|||
take2string!(io) = String(take!(io))
|
||||
joinlines(lines) = join(lines, '\n')
|
||||
|
||||
get_format(doctype::AbstractString) = FORMATS[doctype]
|
||||
|
||||
"""
|
||||
list_out_formats()
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ const UNICODE2LATEX = let
|
|||
s
|
||||
end
|
||||
end
|
||||
return Dict(unicode => texify(sym) for (sym, unicode) in REPL.REPLCompletions.latex_symbols)
|
||||
Dict(unicode => texify(sym) for (sym, unicode) in REPL.REPLCompletions.latex_symbols)
|
||||
end
|
||||
|
||||
function unicode2latex(docformat::TexFormat, s, escape = false)
|
||||
|
|
|
@ -17,7 +17,7 @@ function run_doc(
|
|||
# cache :all, :user, :off, :refresh
|
||||
|
||||
doc.doctype = isnothing(doctype) ? (doctype = detect_doctype(doc.source)) : doctype
|
||||
doc.format = deepcopy(FORMATS[doctype])
|
||||
doc.format = deepcopy(get_format(doctype))
|
||||
|
||||
cwd = doc.cwd = get_cwd(doc, out_path)
|
||||
isdir(cwd) || mkdir(cwd)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
test_formatfigures(chunk, format) = Weave.formatfigures(chunk, Weave.FORMATS[format])
|
||||
test_formatfigures(chunk, format) = Weave.formatfigures(chunk, get_format(format))
|
||||
|
||||
|
||||
# Make a dummy codehunk with figure
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
# Test disable escaping of unicode
|
||||
@testset "escape/unescape unicode characters" begin
|
||||
|
||||
content = """
|
||||
# Test chunk
|
||||
α
|
||||
"""
|
||||
chunk = Weave.DocChunk(content, 1, 1)
|
||||
fmt = deepcopy(Weave.FORMATS["md2tex"])
|
||||
|
||||
f = Weave.format_chunk(chunk, fmt)
|
||||
@test f == "\\section{Test chunk}\n\\ensuremath{\\alpha}\n\n"
|
||||
|
||||
fmt.keep_unicode = true
|
||||
f = Weave.format_chunk(chunk, fmt)
|
||||
@test f == "\\section{Test chunk}\nα\n\n"
|
||||
|
||||
|
||||
str = """
|
||||
```julia
|
||||
α = 10
|
||||
```
|
||||
"""
|
||||
doc = mock_run(str; doctype = "md2tex")
|
||||
Weave.set_rendering_options!(doc.format)
|
||||
doc = Weave.render_doc(doc)
|
||||
@test occursin(Weave.uc2tex("α"), doc)
|
||||
@test !occursin("α", doc)
|
||||
|
||||
doc = mock_run(str; doctype = "md2tex")
|
||||
Weave.set_rendering_options!(doc.format; keep_unicode = true)
|
||||
doc = Weave.render_doc(doc)
|
||||
@test occursin("α", doc)
|
||||
@test !occursin(Weave.uc2tex("α"), doc)
|
||||
|
||||
end
|
|
@ -0,0 +1,30 @@
|
|||
@testset "unicode to latex conversion" begin
|
||||
unicode2latex(args...) = Weave.unicode2latex(get_format("md2tex"), args...)
|
||||
|
||||
# unit test
|
||||
let
|
||||
s = unicode2latex("α = 10")
|
||||
@test !occursin("α", s)
|
||||
@test occursin("alpha", s)
|
||||
end
|
||||
|
||||
# end2end
|
||||
let
|
||||
str = """
|
||||
```julia
|
||||
α = 10
|
||||
```
|
||||
"""
|
||||
doc = mock_run(str; doctype = "md2tex")
|
||||
Weave.set_rendering_options!(doc.format)
|
||||
rendered = Weave.render_doc(doc)
|
||||
@test occursin("alpha", rendered)
|
||||
@test !occursin("α", rendered)
|
||||
|
||||
doc = mock_run(str; doctype = "md2tex")
|
||||
Weave.set_rendering_options!(doc.format; keep_unicode = true)
|
||||
rendered = Weave.render_doc(doc)
|
||||
@test !occursin("alpha", rendered)
|
||||
@test occursin("α", rendered)
|
||||
end
|
||||
end # @testset "rendering tex formats"
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
# %%
|
||||
using Weave, Test
|
||||
using Weave: WeaveDoc, run_doc
|
||||
using Weave: WeaveDoc, run_doc, get_format
|
||||
|
||||
|
||||
function mock_doc(str, informat = "markdown")
|
||||
|
@ -49,6 +49,10 @@ end
|
|||
include("run/test_error.jl")
|
||||
end
|
||||
|
||||
@testset "render" begin
|
||||
include("render/texformats.jl")
|
||||
end
|
||||
|
||||
@testset "conversions" begin
|
||||
include("test_converter.jl")
|
||||
end
|
||||
|
@ -58,7 +62,6 @@ end
|
|||
end
|
||||
|
||||
@testset "legacy" begin
|
||||
include("formatter_test.jl")
|
||||
include("markdown_test.jl")
|
||||
include("figureformatter_test.jl")
|
||||
include("cache_test.jl")
|
||||
|
|
Loading…
Reference in New Issue