Skip to content

Commit 422c166

Browse files
committed
Clean up to_superscript
1 parent 3864f62 commit 422c166

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/utils.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,16 @@ pretty_print_exponent(io::IO, x) = print(io, to_superscript(string_rational(x)))
117117
const SUPERSCRIPT_MAPPING = ('', '¹', '²', '³', '', '', '', '', '', '')
118118
const INTCHARS = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')
119119
to_superscript(s::AbstractString) = join(
120-
map(replace(replace(s, "-" => ""), r"//" => "")) do c
121-
c INTCHARS ? SUPERSCRIPT_MAPPING[parse(Int, c)+1] : c
120+
map(s) do c
121+
if c INTCHARS
122+
SUPERSCRIPT_MAPPING[parse(Int, c)+1]
123+
elseif c == "-"
124+
''
125+
elseif c == "/"
126+
''
127+
else
128+
c
129+
end
122130
end
123131
)
124132

0 commit comments

Comments
 (0)