From f3cf594f30f3990aa0f4e76557af64371a1e1e83 Mon Sep 17 00:00:00 2001 From: Willy Date: Wed, 11 Aug 2021 08:04:14 +0000 Subject: [PATCH 1/4] add additional arguments to diff-pdf * -v: be verbose * -m: mark differences on the side * -s: skip empty pages --- compile.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compile.sh b/compile.sh index 5798f20..15a3886 100644 --- a/compile.sh +++ b/compile.sh @@ -45,7 +45,7 @@ if [ "$DISABLE_SYNCTEX" = "" ]; then cp -u "$TARGET.synctex" "$BIND_PATH/$TARGET.synctex" fi if [ -f "$TARGET-old.pdf" ]; then - xvfb-run diff-pdf --output-diff="$TARGET-diff.pdf" "$TARGET-old.pdf" "$TARGET.pdf" + xvfb-run diff-pdf -v -m -s --output-diff="$TARGET-diff.pdf" "$TARGET-old.pdf" "$TARGET.pdf" rm "$TARGET-old.pdf" cp -u "$TARGET-diff.pdf" "$BIND_PATH/$TARGET-diff.pdf" fi From 44f6a684b491b2e42ff218d9c6b8b3c7c369fe53 Mon Sep 17 00:00:00 2001 From: Willy Date: Fri, 27 Aug 2021 10:50:18 +0200 Subject: [PATCH 2/4] Support for custom pygments lexers (#28) * checkin of custom regex lexer by @TheColin21 * add custom lexer support to dockerfile Co-authored-by: Colin P --- Dockerfile | 5 +++++ pygments-lexers/custom_regex_lexer.py | 32 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 pygments-lexers/custom_regex_lexer.py diff --git a/Dockerfile b/Dockerfile index f16aa6f..ef2ac72 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,6 +47,11 @@ RUN apt-get update &&\ && \ rm -rf /var/lib/apt/lists/* +# install custom pygments lexers +WORKDIR /usr/local/lib/python3.8/dist-packages/pygments/lexers +COPY pygments-lexers/* . +RUN python3 _mapping.py + # minted expects "python" in PATH (not "python3") # without this, things like autogobble with \inputminted break # https://github.com/alexpovel/latex-extras-docker/blob/5429a82ef415c2e9eda0c20f71e7df63b51621e9/Dockerfile#L80-L87 diff --git a/pygments-lexers/custom_regex_lexer.py b/pygments-lexers/custom_regex_lexer.py new file mode 100644 index 0000000..d18fd92 --- /dev/null +++ b/pygments-lexers/custom_regex_lexer.py @@ -0,0 +1,32 @@ +# Custom lexer for regex snippets +# This file is based on a blog entry by Lukas Matt. +# https://blog.matt.wf/regex-lexer-for-pygments/ +# It has been modified to be more versatile +from pygments.lexer import RegexLexer, bygroups +from pygments.token import * + +__all__ = ['regexLexer'] + +class regexLexer(RegexLexer): + name = 'regex' + aliases = ['regex'] + filenames = [] + + tokens = { + 'root': [ + (r'=', Text), + (r'\w+', Name), + (r'\d+', Number), + (r'[\s\,\:\-\"\']+', Text), + (r'[\$\^]', Token), + (r'[\+\*\.\?]', Operator), + (r'(\()([\?\<\>\!\=\:]{2,3}.+?)(\))', bygroups(Keyword.Namespace, Name.Function, Keyword.Namespace)), + (r'(\()(\?\#.+?)(\))', bygroups(Comment, Comment, Comment)), + (r'[\(\)]', Keyword.Namespace), + (r'[\[\]]', Name.Class), + (r'\\\w', Keyword), + (r'[\{\}]', Operator), + (r'\\\.', Text), + (r'\|', Operator), + ], + } From 2f4d1f736c0493c937afc4fed5a24533c8c02621 Mon Sep 17 00:00:00 2001 From: Willy Date: Fri, 27 Aug 2021 12:38:03 +0200 Subject: [PATCH 3/4] hotfix: rename lexer class and name (regex -> custom-regex) this avoids collisions in the future in case pygments has its own "regex" lexer at some point Signed-off-by: Willy --- pygments-lexers/custom_regex_lexer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygments-lexers/custom_regex_lexer.py b/pygments-lexers/custom_regex_lexer.py index d18fd92..80769c5 100644 --- a/pygments-lexers/custom_regex_lexer.py +++ b/pygments-lexers/custom_regex_lexer.py @@ -5,11 +5,11 @@ from pygments.lexer import RegexLexer, bygroups from pygments.token import * -__all__ = ['regexLexer'] +__all__ = ['CustomRegexLexer'] -class regexLexer(RegexLexer): - name = 'regex' - aliases = ['regex'] +class CustomRegexLexer(RegexLexer): + name = 'custom-regex' + aliases = ['custom-regex'] filenames = [] tokens = { From a601f50b85d48eae8242cf6bf02fb5b3f477b835 Mon Sep 17 00:00:00 2001 From: Willy Date: Fri, 27 Aug 2021 10:52:14 +0000 Subject: [PATCH 4/4] [skip ci] add a list of lexers to readme.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 50cc3a2..6de5454 100644 --- a/README.md +++ b/README.md @@ -68,5 +68,11 @@ This container can generate a `synctex.gz` file for you. Because all of the path In order to use this feature, you need to set the environment variable `HOST_PATH` to the same folder you bound `/latex` to. (the part before the colon). If you don't set this variable, a synctex file will still be generated but it won't be usable by your editor (wrong contents/paths. You can use the option specified above disable synctex generation completely. +### Custom pygments lexers +This repo supports registering additional pygments lexers (the "renderers" for the LaTeX package `minted`) at build time. These can be refered to by any one of their aliases listed below. (e.g. `\begin{minted}{custom-regex}`) +| name | description | aliases | +| -------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------- | +| `custom-regex` | A lexer for highlighting regular expressions. (ps: don't confuse this with the `RegexLexer` base class for all pygments lexers.) | `custom-regex` | + ## Contributing If you have any questions, feature requests or LaTeX package suggestions, feel free to open an issue here on GitHub.