From cef05943725524c21713d7ac1224fac91953a562 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 3 Feb 2024 10:10:18 +0100 Subject: [PATCH 1/2] Syntax: Add support for LaTeX in fenced code blocks --- messages/next.md | 2 ++ syntaxes/Markdown.sublime-syntax | 21 +++++++++++++++++++++ tests/syntax_test_markdown.md | 12 ++++++++++++ 3 files changed, 35 insertions(+) diff --git a/messages/next.md b/messages/next.md index 3187f290..b6173b75 100644 --- a/messages/next.md +++ b/messages/next.md @@ -10,6 +10,8 @@ feedback you can use [GitHub issues][issues]. ## New Features +- syntax highlighting for LaTeX in fenced code blocks + ## Changes [issues]: https://github.com/SublimeText-Markdown/MarkdownEditing/issues diff --git a/syntaxes/Markdown.sublime-syntax b/syntaxes/Markdown.sublime-syntax index aa1906ef..a7c590a9 100644 --- a/syntaxes/Markdown.sublime-syntax +++ b/syntaxes/Markdown.sublime-syntax @@ -1040,6 +1040,7 @@ contexts: - include: fenced-jsonc - include: fenced-jspx - include: fenced-jsx + - include: fenced-latex - include: fenced-lisp - include: fenced-lua - include: fenced-makefile @@ -1496,6 +1497,26 @@ contexts: 1: punctuation.definition.raw.code-fence.end.markdown 2: meta.fold.code-fence.end.markdown + fenced-latex: + - match: |- + (?x) + {{fenced_code_block_start}} + (?i:\s*(latex|tex)) + {{fenced_code_block_trailing_infostring_characters}} + captures: + 0: meta.code-fence.definition.begin.latex.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 5: constant.other.language-name.markdown + 6: comment.line.infostring.markdown + 7: meta.fold.code-fence.begin.markdown + embed: scope:text.tex.latex + embed_scope: markup.raw.code-fence.latex.markdown-gfm + escape: '{{fenced_code_block_escape}}' + escape_captures: + 0: meta.code-fence.definition.end.latex.markdown-gfm + 1: punctuation.definition.raw.code-fence.end.markdown + 2: meta.fold.code-fence.end.markdown + fenced-lisp: - match: |- (?x) diff --git a/tests/syntax_test_markdown.md b/tests/syntax_test_markdown.md index d0077b4a..139b54d9 100644 --- a/tests/syntax_test_markdown.md +++ b/tests/syntax_test_markdown.md @@ -1668,6 +1668,18 @@ for (var i = 0; i < 10; i++) { |^^ meta.code-fence.definition.end.jsx.markdown-gfm punctuation.definition.raw.code-fence.end.markdown | ^ meta.code-fence.definition.end.jsx.markdown-gfm meta.fold.code-fence.end - punctuation +```latex +| <- meta.code-fence.definition.begin.latex.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown +|^^ meta.code-fence.definition.begin.latex.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown +| ^^^^^ meta.code-fence.definition.begin.latex.markdown-gfm constant.other.language-name.markdown +| ^ meta.code-fence.definition.begin.latex.markdown-gfm meta.fold.code-fence.begin.markdown - punctuation + +| <- markup.raw.code-fence.latex.markdown-gfm text.tex.latex +``` +| <- meta.code-fence.definition.end.latex.markdown-gfm punctuation.definition.raw.code-fence.end.markdown +|^^ meta.code-fence.definition.end.latex.markdown-gfm punctuation.definition.raw.code-fence.end.markdown +| ^ meta.code-fence.definition.end.latex.markdown-gfm meta.fold.code-fence.end.markdown - punctuation + ```lisp |^^^^^^ meta.code-fence.definition.begin - meta.fold | ^ meta.code-fence.definition.begin meta.fold.code-fence.begin From 2278c5c157a2c721c841b29b48e6a20c8f9a612a Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 17 Mar 2024 23:28:11 +0100 Subject: [PATCH 2/2] CI: Upgrade unittest actions --- .coveragerc | 2 ++ .github/workflows/ci-lint.yml | 6 +++--- .github/workflows/ci-syntax-tests.yml | 4 +--- .github/workflows/ci-unit-tests.yml | 4 ++-- .github/workflows/deploy-gh-pages.yml | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..321e5ca0 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[run] +omit = */tests/* diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml index 1e408434..28f120ab 100644 --- a/.github/workflows/ci-lint.yml +++ b/.github/workflows/ci-lint.yml @@ -21,7 +21,7 @@ on: jobs: lint: name: Python ${{ matrix.python }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: matrix: python: @@ -30,9 +30,9 @@ jobs: - 'x64' steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: ${{ matrix.arch }} diff --git a/.github/workflows/ci-syntax-tests.yml b/.github/workflows/ci-syntax-tests.yml index 3150bae0..5081d478 100644 --- a/.github/workflows/ci-syntax-tests.yml +++ b/.github/workflows/ci-syntax-tests.yml @@ -32,10 +32,8 @@ jobs: default_packages: st3 - build: 4107 default_packages: v4107 - - build: latest - default_packages: master steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: SublimeText/syntax-test-action@v2 with: build: ${{ matrix.build }} diff --git a/.github/workflows/ci-unit-tests.yml b/.github/workflows/ci-unit-tests.yml index c80431b9..138ad587 100644 --- a/.github/workflows/ci-unit-tests.yml +++ b/.github/workflows/ci-unit-tests.yml @@ -28,11 +28,11 @@ jobs: matrix: st-version: [3, 4] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: SublimeText/UnitTesting/actions/setup@v1 with: sublime-text-version: ${{ matrix.st-version }} - uses: SublimeText/UnitTesting/actions/run-tests@v1 with: coverage: true - codecov-upload: true + - uses: codecov/codecov-action@v4 diff --git a/.github/workflows/deploy-gh-pages.yml b/.github/workflows/deploy-gh-pages.yml index 24a3c5cc..d59b0d2f 100644 --- a/.github/workflows/deploy-gh-pages.yml +++ b/.github/workflows/deploy-gh-pages.yml @@ -14,11 +14,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: '3.8' - name: Install MkDocs