Skip to content

GitHub Action to lint, spell- and grammar-check LaTeX documents using TeXtidote.

License

Notifications You must be signed in to change notification settings

ChiefGokhlayeh/textidote-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

TeXtidote Action

Gitpod ready-to-code

pre-commit.ci status Test on Documents Push Image Version Tag

GitHub Action to lint, spell- and grammar-check LaTeX documents using TeXtidote.

Inputs

root_file

Required - The root LaTeX file to be linted.

working_directory

Optional - Working directory to execute TeXtidote in.

report_type

Optional - The type of TeXtidote report to generate (referring to TeXtidote's --output option). Default: html

report_file

Optional - The file path of the TeXtidote report. Default: report.html

args

Optional - Extra arguments to be passed to TeXtidote.

Outputs

num_warnings

Integer value representing the number of warnings TeXtidote found while linting the document. Value is parsed from TeXtidote stderr. If parsing fails, num_warnings is set to -1 and an error is logged.

Example usage

name: Lint LaTeX document
on: [push]
jobs:
    lint_latex:
        runs-on: ubuntu-latest
        steps:
            - name: Set up Git repository
              uses: actions/checkout@v2
            - name: Lint LaTeX document
              uses: ChiefGokhlayeh/textidote-action@v5
              id: lint
              with:
                  root_file: main.tex

                  ## Implied defaults:
                  # working_directory:
                  # report_type: html
                  # report_file: report.html

                  ## Use this setting to pass custom arguments options to
                  ## TeXtidote (such as what grammar checker to use).
                  # args:
            - name: Upload TeXtidote report
              uses: actions/upload-artifact@v2
              with:
                  name: textidote_report
                  path: report.html
            - name: Throw error if linter warnings exist
              if: ${{ steps.lint.outputs.num_warnings != 0 }}
              run: 'echo "::error file=main.tex::num_warnings: ${{ steps.lint.outputs.num_warnings }}"; exit 1;'

Spell Check

TeXtidote is able to perform spell- and grammar-checking using LanguageTool. To activate it for CI build, add option --check <language> to args, where <language> is any language code supported by LanguageTool (examples: en - English, de - German, es - Spanish). Custom dictionaries can be added via option --dict <path-to-dict-file-in-repo>.

Example: Using English spell check & dictionary

name: Lint & Spell Check LaTeX document
on: [push]
jobs:
    lint_and_spell_check_latex:
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v2
            - uses: ChiefGokhlayeh/textidote-action@v5
              with:
                  root_file: main.tex
                  args: --check en --dict en_US.dict

Ignoring False-Positives

If you're struggling with false-positives, you can disable certain rules using TeXtidote's --ignore option.

Example: Ignoring rules sh:001 and sh:d:001

name: Lint document with some exemptions
on: [push]
jobs:
    lint_latex_with_some_exemptions:
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v2
            - uses: ChiefGokhlayeh/textidote-action@5
              with:
                  root_file: main.tex
                  args: --ignore sh:001,sh:d:001

More Options

Please refer to the official TeXtidote README for more options. Use args to add custom options. For long lists of additional arguments consider using a .textidote configuration file.

Docker Hub

The Docker image created for this action is reusable as a general TeXtidote container and is available on Docker Hub.

Contributing

Please raise an issue if you encounter any troubles related to this action. Pull requests are always welcome. Remember, this is a hobby project.

Alternatives

If you want continuous spell and grammar checking as you type, I recommend the excellent LTeX Language Server, also available as VS Code extension. LTeX has a greater understanding of LaTeX commands and a more intuitive mechanism of adding new unknown commands. TeXtidote may then be used like a linter in the classical sense.

License

SPDX: MIT