pythontex icon indicating copy to clipboard operation
pythontex copied to clipboard

Adding Mathematica Support

Open SdotVdot opened this issue 7 years ago • 1 comments

Is it doable to add Mathematica support to pythontex?

SdotVdot avatar Mar 10 '18 01:03 SdotVdot

It should be possible. Writing to stdout and stderr are the only things needed for basic functionality. You might use the bash support in pythontex_engines.py as a starting point, since it is the most basic setup.

bash_template = '''
    cd "{workingdir}"
    {body}
    echo "{dependencies_delim}"
    echo "{created_delim}"
    '''

bash_wrapper = '''
    echo "{stdoutdelim}"
    >&2 echo "{stderrdelim}"
    {code}
    '''

bash_sub = '''echo "{field_delim}"\necho {field}\n'''

CodeEngine('bash', 'bash', '.sh',
           '{bash} "{file}.sh"',
           bash_template, bash_wrapper, '{code}', bash_sub,
           ['error', 'Error'], ['warning', 'Warning'],
           'line {number}')

Everything in curly braces {} is a template field. You would need to swap "bash" for "mathematica" or something similar, and cd and echo and the extension .sh for their equivalents. The error and warning and line part at the end is for synchronizing error and warning messages for the LaTeX document, so it would need to be updated based on the wording used in Mathematica messages.

gpoore avatar Mar 10 '18 17:03 gpoore