Skip to content

Commit

Permalink
fix printing when symbols involve utf8 wide chars
Browse files Browse the repository at this point in the history
  • Loading branch information
kalmarek committed Jun 21, 2021
1 parent f854e4a commit 10b3e47
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "KnuthBendix"
uuid = "c2604015-7b3d-4a30-8a26-9074551ec60a"
authors = ["Marek Kaluba <[email protected]>", "Mikołaj Pabiszczak <[email protected]>"]
version = "0.2.0"
version = "0.2.1"

[deps]
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Expand Down
2 changes: 1 addition & 1 deletion src/alphabets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ Base.inv(A::Alphabet{T}, a::T) where {T} = A[-A[a]]
function _print_syllable(io, symbol, pow)
str = string(symbol)
if length(str) > 3 && endswith(str, "^-1")
print(io, str[1:end-3], "^-", pow)
print(io, first(str, length(str)-3), "^-", pow)
else
if pow == 1
print(io, str)
Expand Down
4 changes: 4 additions & 0 deletions test/alphabets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
@test sprint(show, MIME"text/plain"(), A) isa String

@test A[A[1]] == 1

A = Alphabet(["a₁", "a₁^-1"], [2, 1])
w = Word([1,2,2])
@test sprint(KnuthBendix.print_repr, w, A) == "a₁*a₁^-2"
end

@testset "Inverting using Alphabet" begin
Expand Down

0 comments on commit 10b3e47

Please sign in to comment.