| GitHub Repo | Collection of rendered codes
To support syntax highlighting of the MMT Surface Syntax from the MMT project this package is a Pygments plugin including
- a Pygments lexer (
mmt
) - a recommended Pygments style for it (
mmtdefault
) - and experimentally a Pygments lexer for MMT relational data (
mmtrel
).
Tested on 15k lines of MMT code: see collection
See readme in ./examples/latex.
-
pipenv install pygments mmtpygments
in your project directory -
pipenv run pygmentize -f html -l mmt -O full,style=mmtdefault -o test.html test.mmt
This tells Pygments to use the HTML formatter (
-f
), the MMT lexer (-l
) and to output a full HTML file using themmtdefault
style (-O
) rendered oftest.mmt
intotest.html
(-o
).
- Install pipenv, which provides a consistent Python, pip and package environment locked in the committed
Pipfile
andPipfile.lock
files. pipenv install
git submodule init
git submodule update
cd mmtpygments && pipenv run python ./mmt_lexer.py convert codemirror ../exports/codemirror/mode/mmt/mmt.js
TODO: document this better
-
cd mmtpygments && pipenv run python ./mmt_lexer.py convert rouge ../exports/rouge/lib/rouge/lexers/mmt.rb
. -
On the GitLab server:
- Copy the generated Rouge lexer
mmt.rb
to/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rouge-3.[XX].0/lib/rouge/lexers
. - Restart GitLab:
gitlab-ctl restart
(might be required multiple times due to some overaggressive caches).
- Copy the generated Rouge lexer
cd mmtpygments/test
pipenv run python test.py ./
(returns non-zero exit code on failure)- Open
index.html
in a browser to see failures visually (red rectangles).
This test.py
runs the lexer on large MMT archives containing a lot of MMT surface syntax. It recursively searches for MMT files in mmtpygments/test/data
, on which it then runs the provided lexer and Pygment's HtmlFormatter. The rendered versions are written next to the original *.mmt
files with an .html
extension. Furthermore, index.html
and amalgamation.html
are generated to link and display the results, respectively.
The Travis build automatically runs test.py
and deploys the results on the gh-pages
branch, see https://comfreek.github.io/mmtpygments/ and especially https://comfreek.github.io/mmtpygments/mmtpygments/test/index.html.
For 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.py
actually 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 run test.py
and look at the index.html
locally in your browser to see any errors.
Publishing is done automatically via .travis.yml upon tagged commits on the master branch. For that do
- Locally 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 withv
and a digit for Travis CI to pick it up, see.travis.yml
) - Push the commit and the tag:
git push && git push --tags
Not recommended: If you really have to publish a version manually for whatever reason, do the following:
# Packaging
$ pipenv run python setup.py sdist bdist_wheel
# Checking if packages are okay (PyPi server will do the same)
$ pipenv run twine check dist/*
# Upload to Test PyPi repository
$ pipenv run twine upload --repository-url https://test.pypi.org/legacy/ dist/*
# Upload to real PyPi repository
$ pipenv run twine upload dist/*
In 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/mmtpygments
to the URI where you deploy your things..travis.yml
:- Change the base path with which
python test.py
is 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.
- Change the base path with which