Skip to content

Instantly share code, notes, and snippets.

@adityawagh114
Last active December 14, 2023 16:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adityawagh114/09dde04ed58dc15615b5d453a15f9474 to your computer and use it in GitHub Desktop.
Save adityawagh114/09dde04ed58dc15615b5d453a15f9474 to your computer and use it in GitHub Desktop.

wxmx2texi - WxMaxima Worksheet to TexInfo Converter

Introduction

Google Summer of Code 2021.

This blog describes my work during the Google Summer of Code 2021 with Maxima under INCF Organization. All my codes can be seen on GitHub here.

Package wxmx2texi, is a loadable package in Maxima provides WxMaxima Worksheet to TexInfo conversion functionality. It was developed under the mentorship of Dimiter Prodanov and Robert Dodier as an INCF project during Google Summer of Code 2021 by Aditya Sandeep Wagh of National Institute of Technology Karnataka Surathkal.

Maxima is a system for the manipulation of symbolic and numerical expressions with more than 40-year history. WxMaxima is a widely used user interface for Maxima. Texinfo is a documentation system that uses a single source file to produce both online information and printed output. It is primarily designed for writing software manuals. Moreover, Maxima provides the support for scientists without a strictly technical background (does not require programming skills to use Maxima). The idea behind this project is to convert the wxMaxima worksheet to Texinfo.

The project proposal for Google Summer of Code is available here. wxmx2texi is written in Common Lisp and Maxima.

Usage

wxmx2texi can be loaded in a Maxima instance for use, by executing load(wxmx2texi);

Required dependencies

  • QuickLisp to Load the XML Parser and Zip file Manager.

How to install Quicklisp in Maxima.

  • Download quicklisp.lisp and save it in maxima.
  • Load the file in maxima by executing load("quicklisp.lisp").
  • Install quicklisp by executing :lisp (quicklisp-quickstart:install)

Steps to run

  • Download this package and save in the maxima directory such that maxima can find this package.
  • Load the package by executing the command load(wxmx2texi) in maxima.
  • Pass the location of the wxmx file as an argument to wxmx2texi() function.
  • To save the output in the texinfo file, pass second argument as location of the folder to wxmx2texi() function.

Example run

Example:
In maxima:

(%i1) load (wxmx2texi)$
(%i1) load(wxmx2texi);
To load "plump":
  Load 1 ASDF system:
    plump
; Loading "plump"

To load "zip":
  Load 1 ASDF system:
    zip
; Loading "zip"

To load "zip":
  Load 1 ASDF system:
    zip
; Loading "zip"

Provide the Location of the wxmx and texi folder inside the function wxmx2texi\
(<location>,<location>)  
(%o1)         /usr/local/share/maxima/5.45.1/share/wxmx2texi.mac
(%i2) wxmx2texi("sample.wxmx","test_folder");
/home/aditya/Desktop/sample_project/sample.wxmx 
                              /home/aditya/Desktop/sample_project/test_folder/ 
The texi file is saved in : 
       /home/aditya/Desktop/sample_project/test_folder/tmpGHU3ALSV/sample.texi 
(%o2) /home/aditya/Desktop/sample_project/test_folder/tmpGHU3ALSV/sample.texi

Generated Texinfo Output from Tests :

Output1

Output2

Output3

Supported XML tags in <output>

Tag Significance
"v" Variable Name
"mo" Operator Name
"t" Misc Text
"n" Number
"p" Parenthesis
"f" Fraction
"e" Superscript
"i" Subscript
"fn" Function
"g" Greek Symbols
"s" Special Constant
"fnm" Function Name
"q" Square Root
"d" Diff
"sm" Summation
"in" Int
"at" At
"a" Abs
"cj" Conjugate
"ie" SubSup
"mmultiscripts" Mmultiscripts
"lm" Lim
"r" Row
"tb" Table
"mth" Mth
"lbl" Output Label
"st" String
"hl" Highlight
"h" Hidden Operator
"ascii" Char Code;
"mtd" Mtd

Files in wxmx2texi

Working of wxmx2texi

The Working of the wxmx2texi package consists of the following steps-

  1. The .wxmx file is unzipped and its contents are stored in a folder. The folder contain the content.xml file and images.

  2. The location of the content.xml file is passed to $xmlparser function located in wxmx2texi/wxmx2texi.lisp and the function parses the xml and stores the content of the xml in lisp objects created as per the structure of the xml.

  3. The xml file contains multiple cells and each cell has <input> and <output> tag. The contents of the <input> tag are directly stored in the texi file using the function printobject.

  4. The contents of the <output> tag contains WxMaxima specific MathML and it needs to be converted to Maxima expressions.

  5. The generated maxima expressions are converted to 2-D ,Latex output which are then stored in the .texi file.

  6. Various rules for each XML tag are defined in wxmx2texi/expressions_from_xml.mac and the pattern of the xml is matched and then it gets converted to its equivalent maxima tokens.

Future Scope

Maxima, being a vast language, wxmx2texi supports a core subset of its main features. Future work in wxmx2texi would extend it to support a broader base. This work can include:

  • Output XML tag whose rule isn't defined currently can be easily defined in expressions_from_xml.mac by defining a rule in apply1 and creating a xml tag pattern equivalent rule in the file.

  • Further, wxmx2texi can be extended to convert the texi output to pdf, info files by integrating directly with makeinfo.

Student Developer Information

Name Aditya Sandeep Wagh
GitHub adityawagh114
LinkedIn adityawagh114
E-Mail adityawagh114@gmail.com

Thoughts on GSoC:

My experience in working on this GSoC’21 project with INCF was simply awesome. It was one of the best experiences I’ve ever had. Not only did I get a chance of contributing to such a big real-world project, but also I got to learn a lot throughout the program.

I would really like to thank Robert and Dimiter who always supported me and guided me through the project and helped me a lot in resolving the blockers I faced.

Also, I would like to thank the entire maxima community which has always been so supportive. Be it solving issues, suggesting improvements or even finding issues with the implementation, the maxima community has always been there for help. I would definitely say that it is one of the most active and supportive open source communities, and that I take pride in being its member.

Finally, I would like to thank Google for conducting GSoC and providing this great opportunity for working in such a great open source community on such a big, real-world project.

Take-Aways

  • The working environment was completely new to me when I first started and I got to learn a lot during this period of time.

  • A new paradigm of programming with Lisp language was revealed to me as I progressed.

  • Got acquainted with Git, Lisp, Maxima language , MathML, Latex and awesome development tools and softwares.

  • Improved coding practices, debugging and testing.

  • At last but not the least, I got an opportunity to get involved with a really great community of people, and got to be a part of Maxima.

I look forward to contributing and learning more from the organization.

Commits

Commit Description
[0c48992] Fixed error due to attribute in lbl tag
[8562554] Fixed label with attributes error
[638797c] Removed multiple occurrences of with-open-file
[005688d] Included fractions and variables in matrix
[a1f0df3] Included Matrix representation
[73827d2] Included multiple inputs in same cell
[7f1f7f0] Included abs and conjugate cells.
[14ce513] Included Multiple differential equations,strings and square roots.
[4c19241] Formatted the Lisp Code
[afadc67] Removed files which are no more required.
[047b4d4] Added functionality for relative path location.
[44d77bb] Fixed unable to create folder error.
[60ae5f0] Created temp folder to avoid same folder name
[892ad92] Changed the format of texinfo representation.
[a2de8e5] Included 2D output
[99ea664] Modified version created by merging wxmx2texi and expressions_from_xml
[818422e] Integrated .wxmx to .xml converter.
[b3b9498] Added the converter .wxmx --> .xml
[df9d4e4] Parsed Output of the XML test file.
[c7586fe] Implementation of XML parser
[415167d] Classes to store the parsed XML data.
[2141715] Initial Commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment