Skip to content

Commit f1bc226

Browse files
committed
fix depwarns
1 parent 1e1485f commit f1bc226

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

src/latex.jl

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,31 @@ end
2323
Base findnext doesn't handle utf8 strings correctly
2424
"""
2525
function utf8_findnext(A::AbstractString, v::Char, idx::Integer)
26-
while !done(A, idx)
26+
while true
2727
lastidx = idx
28-
elem, idx = next(A, idx)
28+
elem_idx = iterate(A, idx)
29+
elem_idx === nothing && break
30+
elem, idx = elem_idx
2931
elem == v && return lastidx
3032
end
3133
0
3234
end
3335

3436
function to_latex(text)
3537
io = IOBuffer()
36-
idx = start(text)
37-
while !done(text, idx)
38-
char, idx = next(text, idx)
38+
charidx = iterate(text)
39+
charidx === nothing && return ""
40+
char, idx = charidx
41+
started = true
42+
while true
43+
started || (charidx = iterate(text, idx))
44+
started = false
45+
charidx === nothing && break
46+
char, idx = charidx
3947
if char in ('^', '_', '\\')
4048
mod = string(char)
4149
if mod == "\\"
42-
ss = SubString(text, idx, endof(text))
50+
ss = SubString(text, idx, lastindex(text))
4351
for mod_candidate in ("bb", "bf", "it", "cal", "frak", "mono")
4452
if startswith(ss, mod_candidate)
4553
mod = mod_candidate
@@ -64,14 +72,14 @@ function to_latex(text)
6472
end
6573
end
6674
end
67-
char, idx = next(text, idx)
75+
char, idx = iterate(text, idx)
6876
if char == '{'
6977
i = utf8_findnext(text, '}', idx)
7078
if i == 0
7179
error("Invalid latex. Couldn't find matching } in $(text[idx:end])")
7280
end
7381
print_modifier(io, mod, SubString(text, idx, prevind(text, i)))
74-
char, idx = next(text, i)
82+
char, idx = iterate(text, i)
7583
else
7684
print_modifier(io, mod, char)
7785
end

src/sub_super_scripts.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ let subscript_map = Dict(
5858
'φ' => '',
5959
'χ' => '',
6060
)
61+
global to_subscript
6162
function to_subscript(x::Char)
6263
haskey(subscript_map, x) || error("Char $x doesn't have a unicode superscript")
6364
subscript_map[x]
@@ -153,6 +154,7 @@ let superscript_map = Dict(
153154
'φ' => '',
154155
'χ' => ''
155156
)
157+
global to_superscript
156158
function to_superscript(x::Char)
157159
haskey(superscript_map, x) || error("Char $x doesn't have a unicode superscript")
158160
superscript_map[x]

test/runtests.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using UnicodeFun
2-
using Base.Test
2+
using Test
33

44
# write your own tests here
55
@test UnicodeFun.to_superscript(-1234567890) == "⁻¹²³⁴⁵⁶⁷⁸⁹⁰"
@@ -25,4 +25,3 @@ latexstring = "\\bf{boldface} \\it{italic} \\bb{blackboard} \\cal{calligraphic}
2525
@test to_root(3,"542") == "∛5̅4̅2̅"
2626
@test to_root(4,"542") == "∜5̅4̅2̅"
2727
@test to_root(17,"542") == "¹⁷√5̅4̅2̅"
28-

0 commit comments

Comments
 (0)