Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cdot bug for complicated expressions #187

Merged
merged 1 commit into from
Oct 18, 2021
Merged
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
11 changes: 9 additions & 2 deletions src/latexoperation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ This uses the information about the previous operations to decide if
a parenthesis is needed.

"""
function latexoperation(ex::Expr, prevOp::AbstractArray; cdot=true, index=:bracket, kwargs...)::String
function latexoperation(ex::Expr, prevOp::AbstractArray; kwargs...)::String
# If we used `cdot` and `index` as keyword arguments before `kwargs...`
# and they are indeed contained in `kwargs`, they would get lost when
# passing `kwargs...` to `latexraw`below. Thus, we need to set default
# values as follows.
cdot = get(kwargs, :cdot, true)
index = get(kwargs, :index, :bracket)

op = ex.args[1]
filter!(x -> !(x isa LineNumberNode), ex.args)
args = map(i -> typeof(i) ∉ (String, LineNumberNode) ? latexraw(i; kwargs...) : i, ex.args)
Expand Down Expand Up @@ -143,7 +150,7 @@ function latexoperation(ex::Expr, prevOp::AbstractArray; cdot=true, index=:brack
return string(ex.args[end])
end

if ex.head == :macrocall
if ex.head == :macrocall
ex.head = :call
end

Expand Down