Skip to content

Commit 18ec4bd

Browse files
authored
Merge pull request #12 from SimonDanisch/sd/1
1.0 support
2 parents 1e1485f + 8b70e40 commit 18ec4bd

File tree

5 files changed

+33
-27
lines changed

5 files changed

+33
-27
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.6
7+
- 0.7
8+
- 1.0
89
- nightly
910
notifications:
1011
email: false

appveyor.yml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
5-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
3+
- julia_version: 0.7
4+
- julia_version: 1
5+
- julia_version: nightly
6+
7+
platform:
8+
- x86 # 32-bit
9+
- x64 # 64-bit
710

811
branches:
912
only:
@@ -17,19 +20,12 @@ notifications:
1720
on_build_status_changed: false
1821

1922
install:
20-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
21-
# Download most recent Julia Windows binary
22-
- ps: (new-object net.webclient).DownloadFile(
23-
$env:JULIA_URL,
24-
"C:\projects\julia-binary.exe")
25-
# Run installer silently, output to C:\projects\julia
26-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
23+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
2724

2825
build_script:
29-
# Need to convert from shallow to complete for Pkg.clone to work
30-
- IF EXIST .git\shallow (git fetch --unshallow)
31-
- C:\projects\julia\bin\julia -e "versioninfo();
32-
Pkg.clone(pwd(), \"UnicodeFun\"); Pkg.build(\"UnicodeFun\")"
26+
- echo "%JL_BUILD_SCRIPT%"
27+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
3328

3429
test_script:
35-
- C:\projects\julia\bin\julia -e "Pkg.test(\"UnicodeFun\")"
30+
- echo "%JL_TEST_SCRIPT%"
31+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

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)