2018-09-17 16:18:29 +00:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim:fenc=utf-8
|
|
|
|
#
|
|
|
|
# Copyright © 2017 lafrite <lafrite@Poivre>
|
|
|
|
#
|
|
|
|
# Distributed under terms of the MIT license.
|
|
|
|
|
|
|
|
"""
|
|
|
|
Expression
|
|
|
|
|
|
|
|
"""
|
|
|
|
from ..core import tree2txt, tree2tex
|
|
|
|
|
2019-05-14 04:55:56 +00:00
|
|
|
|
2018-09-17 16:18:29 +00:00
|
|
|
def _txt(mo_tree):
|
|
|
|
""" txt render for MOs or Trees"""
|
|
|
|
try:
|
|
|
|
return tree2txt(mo_tree)
|
2018-12-21 10:36:40 +00:00
|
|
|
except ValueError:
|
2018-09-20 16:38:49 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
|
|
|
return mo_tree.__txt__
|
2018-09-17 16:18:29 +00:00
|
|
|
except AttributeError:
|
|
|
|
return str(mo_tree)
|
|
|
|
|
2019-05-14 04:55:56 +00:00
|
|
|
|
2018-09-17 16:18:29 +00:00
|
|
|
def _tex(mo_tree):
|
|
|
|
""" Tex render for MOs or Trees"""
|
|
|
|
try:
|
|
|
|
return tree2tex(mo_tree)
|
2018-12-21 10:36:40 +00:00
|
|
|
except ValueError:
|
2018-09-20 16:38:49 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
|
|
|
return mo_tree.__tex__
|
2018-09-17 16:18:29 +00:00
|
|
|
except AttributeError:
|
|
|
|
return str(mo_tree)
|
|
|
|
|
2019-05-14 04:55:56 +00:00
|
|
|
|
|
|
|
renders = {"txt": _txt, "tex": _tex}
|
2018-09-17 16:18:29 +00:00
|
|
|
|
|
|
|
# -----------------------------
|
|
|
|
# Reglages pour 'vim'
|
|
|
|
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
|
|
|
# cursor: 16 del
|