From 419f2600bbb24c1c6ad3312b8236068609a6d877 Mon Sep 17 00:00:00 2001 From: co1emi11er2 Date: Sun, 1 Dec 2024 15:08:10 -0600 Subject: [PATCH] added logic for if statement (not done) --- src/handcalcs_macro.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/handcalcs_macro.jl b/src/handcalcs_macro.jl index ed3da9e..15f50f4 100644 --- a/src/handcalcs_macro.jl +++ b/src/handcalcs_macro.jl @@ -114,6 +114,15 @@ end function clean_expr(expr, len, spa) expr = expr[2:end-1] # remove the $ from end and beginning of string expr = expr[end] == " " ? expr : expr * " " # add trailing space if there isn't one + pattern = r"\\begin\{cases\}(.*?)\\end\{cases\}"s # if format pattern + m = match(pattern, expr) + if !isnothing(m) # expr is an if statement, do something different + expr = split(expr, "=") |> unique |> x -> join(x, "=")[1:end-1] # removes any redundant parts, and removes space at the end + expr = replace(expr, "="=>"&=", count=1) # add alignment + expr = len == :long ? replace(expr, " ="=>"\n\\\\[$spa" *"pt]\n&=", count=2) : expr + return expr + end + # TODO the line below breaks if statements in edge cases expr = split(expr, "=") |> unique |> x -> join(x, "=")[1:end-1] # removes any redundant parts, and removes space at the end expr = replace(expr, "="=>"&=", count=1) # add alignment expr = len == :long ? replace(expr, " ="=>"\n\\\\[$spa" *"pt]\n&=", count=2) : expr