mirror of https://github.com/mpastell/Weave.jl
Fix line wrapping (#180)
* Fix line wrapping * Don't chop from tail * Test wrapping unicodepull/185/merge
parent
cb791e8b69
commit
7587b4f9cf
|
@ -317,12 +317,12 @@ function wraplines(text, line_width=75)
|
||||||
end
|
end
|
||||||
|
|
||||||
function wrapline(text, line_width=75)
|
function wrapline(text, line_width=75)
|
||||||
result = ""
|
result = ""
|
||||||
while length(text) > line_width
|
while length(text) > line_width
|
||||||
result*= text[1:line_width] * "\n"
|
result*= first(text, line_width) * "\n"
|
||||||
text = text[(line_width+1):end]
|
text = chop(text, head=line_width, tail=0)
|
||||||
end
|
end
|
||||||
result *= text
|
result *= text
|
||||||
end
|
end
|
||||||
|
|
||||||
function latex(io::IO, tex::Markdown.LaTeX)
|
function latex(io::IO, tex::Markdown.LaTeX)
|
||||||
|
|
|
@ -80,3 +80,17 @@ and some text
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@test htext.content[1].content == h_ref
|
@test htext.content[1].content == h_ref
|
||||||
|
|
||||||
|
|
||||||
|
# Test wrapping
|
||||||
|
|
||||||
|
cows = repeat("🐄", 100)
|
||||||
|
testcows = """
|
||||||
|
🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄
|
||||||
|
🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄🐄"""
|
||||||
|
|
||||||
|
wcows = Weave.wrapline(cows)
|
||||||
|
|
||||||
|
@test wcows == testcows
|
||||||
|
@test length(split(wcows, "\n")[1]) == 75
|
||||||
|
@test length(split(wcows, "\n")[2]) == 25
|
||||||
|
|
Loading…
Reference in New Issue