GitHub Action
TeXtidote Action
GitHub Action to lint, spell- and grammar-check LaTeX documents using TeXtidote.
Required - The root LaTeX file to be linted.
Optional - Working directory to execute TeXtidote in.
Optional - The type of TeXtidote report to generate (referring to TeXtidote's --output
option). Default: html
Optional - The file path of the TeXtidote report. Default: report.html
Optional - Extra arguments to be passed to TeXtidote.
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.
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;'
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
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
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.
The Docker image created for this action is reusable as a general TeXtidote container and is available on Docker Hub.
Please raise an issue if you encounter any troubles related to this action. Pull requests are always welcome. Remember, this is a hobby project.
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.
SPDX: MIT