Skip to content

Commit 5aac2b8

Browse files
committed
Superscript for HTML, combined printexponent
MIME"text/html" now has superscript tags. `printexponent` had same boilerplate per MIME type
1 parent 75f9cfa commit 5aac2b8

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/show.jl

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,23 +205,18 @@ end
205205

206206

207207
## show exponent
208-
function printexponent(io,var,i, mimetype::MIME"text/latex")
209-
if i == 0
210-
return
211-
elseif i == 1
212-
print(io,var)
213-
else
214-
print(io,var,"^{$i}")
215-
end
216-
end
217208

218-
function printexponent(io,var,i, mimetype)
209+
exponent_text(i, ::MIME) = "^$(i)"
210+
exponent_text(i, ::MIME"text/html") = "<sup>$(i)</sup>"
211+
exponent_text(i, ::MIME"text/latex") = "^{$(i)}"
212+
213+
function printexponent(io, var, i, mimetype::MIME)
219214
if i == 0
220215
return
221216
elseif i == 1
222217
print(io,var)
223218
else
224-
print(io,var,"^",i)
219+
print(io, var, exponent_text(i, mimetype))
225220
end
226221
end
227222

0 commit comments

Comments
 (0)