Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/TreeView.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ end

add_numbered_vertex!(g) = (add_vertex!(g); top = nv(g)) # returns the number of the new vertex

# latex treats # as a special character, so we have to escape it. See:
# https://github.com/sisl/TikzGraphs.jl/issues/12
latex_escape(s::String) = replace(s, "#", "\\#")

"Convert the current node into a label"
function label(sym)
sym == :(^) && return "\\textasciicircum" # TikzGraphs chokes on ^

return string("\\texttt{", sym, "}")
return latex_escape(string("\\texttt{", sym, "}"))
end


Expand Down
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ using Base.Test
t = @tree x^2 + y^2
@test length(t.labels) == 7
end

@testset "latex special characters" begin
# Test for issues with the characters present in julia's generated symbols
expr = Expr(Symbol("##271"))
t = walk_tree(expr)
@test t.labels[1] == "\\texttt{\\#\\#271}"
end