Add filter and create setup function
This commit is contained in:
parent
c0f2882310
commit
c3474d4f17
@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
"""
|
||||
Custom filter for Bopytex
|
||||
"""
|
||||
|
||||
def do_calculus(steps, name="A", sep="=", end="", joining=" \\\\ \n"):
|
||||
"""Display properly the calculus
|
||||
|
||||
Generate this form string:
|
||||
"name & sep & a_step end joining"
|
||||
|
||||
:param steps: list of steps
|
||||
:returns: latex string ready to be endbeded
|
||||
|
||||
|
||||
"""
|
||||
|
||||
ans = joining.join([
|
||||
name + " & "
|
||||
+ sep + " & "
|
||||
+ str(s) + end for s in steps
|
||||
])
|
||||
return ans
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
@ -13,6 +13,7 @@ import sys
|
||||
from path import Path
|
||||
import pytex
|
||||
import pymath
|
||||
import opytex.filters as filters
|
||||
|
||||
formatter = logging.Formatter('%(name)s :: %(levelname)s :: %(message)s')
|
||||
steam_handler = logging.StreamHandler()
|
||||
@ -25,7 +26,8 @@ logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
logger.addHandler(steam_handler)
|
||||
|
||||
MAPYTEX_TOOLS = {
|
||||
def setup():
|
||||
mapytex_tools = {
|
||||
"Expression": pymath.Expression,
|
||||
"Polynom": pymath.Polynom,
|
||||
"Fraction": pymath.Fraction,
|
||||
@ -35,8 +37,9 @@ MAPYTEX_TOOLS = {
|
||||
"Dataset": pymath.Dataset,
|
||||
"WeightedDataset": pymath.WeightedDataset,
|
||||
}
|
||||
pytex.update_export_dict(mapytex_tools)
|
||||
|
||||
pytex.update_export_dict(MAPYTEX_TOOLS)
|
||||
pytex.add_filter("do_calculus", filters.do_calculus)
|
||||
|
||||
|
||||
def get_working_dir(options):
|
||||
@ -168,6 +171,8 @@ def produce_and_compile(options):
|
||||
|
||||
|
||||
def main():
|
||||
setup()
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option(
|
||||
"-t",
|
||||
|
Loading…
Reference in New Issue
Block a user