Package: mmtpygments
|GitHub Repo|Collection of rendered codesmmtpygments: Pygments plugin for MMT surface syntaxTo support syntax highlighting of theMMT Surface Syntaxfrom theMMT projectthis package is a Pygments plugin includinga Pygments lexer (mmt)a recommended Pygments style for it (mmtdefault)and experimentally a Pygments lexer for MMT relational data (mmtrel).Collection of rendered codes:click hereScreenshot:(click for live version)Installationvia Pip (easy)pip install Pygments mmtpygmentsviapipenvor other Python package managers superior to Pip:Runpipenv install pygments mmtpygmentsin your project directory, e.g. containing the LaTeX files in which you'd like to use thisRemember to usemmtpygmentsfrom now on always in that virtual environment context: run your intended command withinpipenv shellFor example, if you'd like to use this in LaTeX and use TeXStudio as an IDE, start TeXStudio from within that shell.This way, you don't clutter your whole PC with the Pip packagesandmore importantly, you document the Pip package versions in thePipfile.lockfile generated in step (2.1).UsageCLIpygmentize -f html -l mmt -O full,style=mmtdefault -o test.html test.mmtThis tells Pygments to use the HTML formatter (-f), the MMT lexer (-l) and to output a full HTML file using themmtdefaultstyle (-O) rendered oftest.mmtintotest.html(-o).LaTeX (with minted)mintedis a LaTeX package rendering codes with Pygments as the backend.% !TeX encoding = UTF-8% !TEX TS-program = latexmk -xelatex -shell-escape -silent -latexoption="-synctex=1 -8bit" %%% ^^^ This is the build command. Install latexmk if you don't have it already.%     You may choose an alternative LaTeX derivative, e.g. LuaLaTeX, but be warned that it must support Unicode!\documentclass{article}\usepackage{fontspec}% Download GNU Unifont from http://unifoundry.com/unifont/index.html% And save it, say, as "fonts/unifont-12.1.03.ttf"\newfontfamily\unifont{unifont-12.1.03.ttf}[Path=./fonts/,NFSSFamily=unifont]% Disable caching for debugging purposes (increases compilation times!)\usepackage[cache=false]{minted}\setminted{fontfamily=unifont,tabsize=2,breaklines=true}\newminted[mmtcode]{mmt}{}\newmintinline[mmtinline]{mmt}{}\newmintedfile[mmtfile]{mmt}{}\begin{document}% Variant 1: Code given in LaTeX, rendered in display mode\begin{mmtcode}theory MyTheory = c : type ❘ # abc ❙❚\end{mmtcode}% Variant 2: Code given in LaTeX, rendered inline% You can use any delimiter you like, here we use /\mmtinline/theory MyTheory = c : type ❘ # abc ❙❚/% Variant 3: Code given externally in file, rendered in display mode% \mmtfile{your-mmt-file.mmt}\end{document}LaTeX Beamer: Use thefragileoption for frames embedding codes:\begin{frame}[fragile] ... \end{frame}See theminted manualfor more information on how to customize it.Common Error: Rendered PDF shows tab characters of sourceIf you tab characters in the MMT source being highlighted and they are shown in the PDF rendered by XeLaTeX, you face a known bug of XeLaTeX ([1],[2]). It can be solved by passing-8bitto XeLaTeX.DevelopmentInstallpipenv, which provides a consistent Python, pip and package environment locked in the committedPipfileandPipfile.lockfiles.pipenv installgit submodule initgit submodule updateTestingcd mmtpygments/testpipenv run python test.py ./(returns non-zero exit code on failure)Openindex.htmlin a browser to see failures visually (red rectangles).Thistest.pyruns the lexer on large MMT archives containing a lot of MMT surface syntax. It recursively searches for MMT files inmmtpygments/test/data, on which it then runs the provided lexer and Pygment's HtmlFormatter. The rendered versions are written next to the original*.mmtfiles with an.htmlextension. Furthermore,index.htmlandamalgamation.htmlare generated to link and display the results, respectively.The Travis build automatically runstest.pyand deploys the results on thegh-pagesbranch, seehttps://comfreek.github.io/mmtpygments/and especiallyhttps://comfreek.github.io/mmtpygments/mmtpygments/test/index.html.Dev WorkflowFor tinkering and testing the lexer, it is recommended to employ the same testing infrastructure as described above. Even though the Travis build fails on lexing error,test.pyactually doesn't -- it just returns a non-zero exit code. In fact, it even generates the HTML renderings with red rectangles around lexing errors. Hence, while tinkering with the lexer, just regularly runtest.pyand look at theindex.htmllocally in your browser to see any errors.PublishingPublishing is done automatically via.travis.ymlupon tagged commits on the master branch. For that doLocally commit all your changes.Create a new version tag:git tag -a vx.y.z -m "Version x.y.z, see CHANGELOG.md"(the tag name needs to start withvand a digit for Travis CI to pick it up, see.travis.yml)Push the commit and the tag:git push && git push --tagsNot recommended:If you really have to publish a version manually for whatever reason, do the following:# Packaging$pipenvrunpythonsetup.pysdistbdist_wheel# Checking if packages are okay (PyPi server will do the same)$pipenvruntwinecheckdist/*# Upload to Test PyPi repository$pipenvruntwineupload--repository-urlhttps://test.pypi.org/legacy/dist/*# Upload to real PyPi repository$pipenvruntwineuploaddist/*For future maintainers: necessary changes in case of repository movementIn case you wish to host this repository or a fork thereof somewhere else, these are the places where you have to make changes:README.md: Change all links referencing anything underhttps://ComFreek.github.io/mmtpygmentsto the URI where you deploy your things..travis.yml:Change the base path with whichpython test.pyis run to your hosting URI.Change the secret value in under deploy/pypi to another PyPI token under which you are able to publish PyPI packages.