New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a primitive lexer for Typst #2596
Conversation
You have tox 3.21.4; you need a more recent version (latest is 4.11.3). |
I've tried to add tests with a more recent version of tox, but: $ tox -- --update-goldens ~/cv_jvoisin.typ
.pkg: _optional_hooks> python /home/jvoisin/dev/pygments/.venv/lib/python3.9/site-packages/pyproject_api/_backend.py True hatchling.build
.pkg: get_requires_for_build_editable> python /home/jvoisin/dev/pygments/.venv/lib/python3.9/site-packages/pyproject_api/_backend.py True hatchling.build
.pkg: build_editable> python /home/jvoisin/dev/pygments/.venv/lib/python3.9/site-packages/pyproject_api/_backend.py True hatchling.build
py: install_package> python -I -m pip install --force-reinstall --no-deps /home/jvoisin/dev/pygments/.tox/.tmp/package/5/pygments-2.17.1-py3-none-any.whl
py: commands[0]> pytest --update-goldens /home/jvoisin/test.typ
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --update-goldens
inifile: None
rootdir: /home/jvoisin
py: exit 4 (0.14 seconds) /home/jvoisin/dev/pygments> pytest --update-goldens /home/jvoisin/test.typ pid=27838
.pkg: _exit> python /home/jvoisin/dev/pygments/.venv/lib/python3.9/site-packages/pyproject_api/_backend.py True hatchling.build
py: FAIL code 4 (0.59=setup[0.44]+cmd[0.14] seconds)
evaluation failed :( (0.66 seconds)
[4]
$``` |
You can see that pytest uses your homedir as the rootdir because the file you're pointing to is there. (Why?) It needs to be in the pygments test hierarchy for pytest to pick up our customizations. |
The main reason is because I'm an idiot who didn't read the well written documentation :/ Things should be working now :) |
See https://typst.app/docs/reference/syntax/ for details. Co-authored-by: Jean Abou-Samra <jean@abou-samra.fr>
I've applied a few fixes that I missed on the initial review. The rule for
in the example. AFAICS, If you don't want to fix it now, we can always merge the PR without |
The rules are outlined here: https://typst.app/docs/reference/syntax/ Feel free to merge it as is, I'll try to improve it afterwards :) |
Thank you @jvoisin! |
Thanks! The test file isn't valid Typst code though. You can check it on either https://typst.app (official web editor), https://pandoc.org/try/ or use the cli program. This is what typst-lsp in vscode gives me: Feel free to use the following code instead: #show link: set text(navy)
#set text(font: "Comic Sans MS", hyphenate: true, lang: "en")
#set page(
margin: (top: 16pt, bottom: 24pt),
numbering: "1 / 1",
)
= Title
#table(
columns: (auto, 50%, 1fr),
[1], [2], [
#let x = 123 + 123
#{
x *= 5
}
#x
],
)
This is an example link: https://example.org
#set text(fill: purple)
$ A = pi r^2 $ |
This should close #2558.
I tried to add tests but:
Also, while the lexer is working ~ok, there is still a lot of space for improvements.