From 1685c730511ed8bfbec9d757328e69e1169bb2c1 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Tue, 16 Jul 2019 09:09:39 +0200 Subject: [PATCH] Feat: Allow pure string rendering --- mapytex/calculus/core/renders/tree2tex.py | 5 ++++- mapytex/calculus/core/renders/tree2txt.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mapytex/calculus/core/renders/tree2tex.py b/mapytex/calculus/core/renders/tree2tex.py index 840fd81..3b24f18 100644 --- a/mapytex/calculus/core/renders/tree2tex.py +++ b/mapytex/calculus/core/renders/tree2tex.py @@ -196,7 +196,10 @@ def render_with_parenthesis(subtree, operator): subtree_need_parenthesis = True except (AttributeError, KeyError): pass - subtree_ = subtree.__tex__ + try: + subtree_ = subtree.__txt__ + except AttributeError: + subtree_ = subtree else: if OPERATORS[subtree.node]["precedence"] < OPERATORS[operator]["precedence"]: subtree_need_parenthesis = True diff --git a/mapytex/calculus/core/renders/tree2txt.py b/mapytex/calculus/core/renders/tree2txt.py index a58cc62..d6c36c3 100644 --- a/mapytex/calculus/core/renders/tree2txt.py +++ b/mapytex/calculus/core/renders/tree2txt.py @@ -200,7 +200,10 @@ def render_with_parenthesis(subtree, operator): subtree_need_parenthesis = True except (AttributeError, KeyError): pass - subtree_ = subtree.__txt__ + try: + subtree_ = subtree.__txt__ + except AttributeError: + subtree_ = subtree else: if OPERATORS[subtree.node]["precedence"] < OPERATORS[operator]["precedence"]: subtree_need_parenthesis = True