generator-latex-template 2026.10.16 → 2026.10.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +1 -0
  2. package/generators/app/CLAUDE.md +5 -0
  3. package/generators/app/index.js +197 -23
  4. package/generators/app/options.js +1 -1
  5. package/generators/app/templates/.devcontainer/devcontainer.json +18 -0
  6. package/generators/app/templates/.github/workflows/check.yml +81 -40
  7. package/generators/app/templates/.github/workflows/dictionaries.yml +25 -0
  8. package/generators/app/templates/.vscode/extensions.json +2 -1
  9. package/generators/app/templates/IEEEtranN-doi.bst +2780 -0
  10. package/generators/app/templates/IEEEtranN-doi.bst.patch +212 -0
  11. package/generators/app/templates/Makefile +67 -16
  12. package/generators/app/templates/README.de.md +4 -7
  13. package/generators/app/templates/README.en.md +132 -13
  14. package/generators/app/templates/Texlivefile +5 -6
  15. package/generators/app/templates/algorithms.preamble.en.tex +3 -1
  16. package/generators/app/templates/babel.preamble.en.tex +4 -0
  17. package/generators/app/templates/biblatex.preamble.en.tex +24 -0
  18. package/generators/app/templates/chapters.README.de.md +5 -0
  19. package/generators/app/templates/chapters.README.en.md +5 -0
  20. package/generators/app/templates/cleveref.example.en.tex +4 -4
  21. package/generators/app/templates/cleveref.preamble.de.tex +2 -4
  22. package/generators/app/templates/cleveref.preamble.en.tex +14 -4
  23. package/generators/app/templates/diagbox.example.en.tex +2 -2
  24. package/generators/app/templates/docs/latex-setup.md +74 -108
  25. package/generators/app/templates/dot.aspell.conf +4 -0
  26. package/generators/app/templates/dot.aspell.de.pws +12 -8
  27. package/generators/app/templates/dot.aspell.en.pws +12 -8
  28. package/generators/app/templates/dot.gitignore +3 -1
  29. package/generators/app/templates/dot.markdownlint.yml +31 -0
  30. package/generators/app/templates/dot.textidote +1 -1
  31. package/generators/app/templates/dot.textidote.replacements +8 -1
  32. package/generators/app/templates/dot.typos.toml +58 -0
  33. package/generators/app/templates/floatflt.preamble.en.tex +1 -1
  34. package/generators/app/templates/floats.preamble.en.tex +4 -0
  35. package/generators/app/templates/font.preamble.en.tex +9 -5
  36. package/generators/app/templates/hyperref.preamble.en.tex +2 -2
  37. package/generators/app/templates/latexmkrc +8 -0
  38. package/generators/app/templates/linebreaker.preamble.en.tex +8 -0
  39. package/generators/app/templates/listings.preamble.en.tex +1 -1
  40. package/generators/app/templates/main.de.tex +166 -90
  41. package/generators/app/templates/main.en.tex +178 -106
  42. package/generators/app/templates/markdown.chapter.de.md +35 -0
  43. package/generators/app/templates/markdown.chapter.en.md +35 -0
  44. package/generators/app/templates/markdown.content.de.md +7 -0
  45. package/generators/app/templates/markdown.content.en.md +7 -0
  46. package/generators/app/templates/markdown.example.en.tex +1 -1
  47. package/generators/app/templates/markdown.preamble.en.tex +8 -0
  48. package/generators/app/templates/minted.example.en.tex +2 -2
  49. package/generators/app/templates/minted.preamble.en.tex +24 -5
  50. package/generators/app/templates/mwe-manuscript.de.md +1 -0
  51. package/generators/app/templates/mwe-manuscript.en.md +1 -0
  52. package/generators/app/templates/natbib.preamble.en.tex +2 -6
  53. package/generators/app/templates/nowidow.preamble.en.tex +10 -3
  54. package/generators/app/templates/progress.preamble.en.tex +17 -0
  55. package/generators/app/templates/refenums.preamble.en.tex +10 -0
  56. package/generators/app/templates/refenums.sty +251 -0
  57. package/generators/app/templates/tables.example.en.tex +4 -8
  58. package/generators/app/templates/tables.preamble.en.tex +33 -0
  59. package/generators/app/templates/todos.preamble.en.tex +1 -1
  60. package/generators/app/templates/uml.example.en.tex +5 -5
  61. package/generators/app/templates/url.preamble.de.tex +5 -4
  62. package/generators/app/templates/url.preamble.en.tex +4 -4
  63. package/generators/app/templates/{xcolor.preamble.de.tex → xcolor.preamble.en.tex} +2 -2
  64. package/generators/app/templates/zref-clever.example.en.tex +4 -4
  65. package/generators/app/templates/zref-clever.preamble.en.tex +13 -0
  66. package/package.json +1 -1
  67. package/generators/app/templates/tables.preamble.de.tex +0 -33
package/README.md CHANGED
@@ -103,6 +103,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute and for development
103
103
  The code has the license [0BSD](https://choosealicense.com/licenses/0bsd/#), the snippets (both LaTeX and text) 0BSD, too.
104
104
  See [benbalter/talks#15](https://github.com/benbalter/talks/issues/15#issuecomment-599704662), for the reasoning why we cannot use [CC0](https://creativecommons.org/share-your-work/public-domain/cc0/).
105
105
 
106
+ - `generators/app/templates/IEEEtranN-doi.bst` is `IEEEtranN.bst` from the [IEEEtran package](https://ctan.org/pkg/ieeetran), modified to output DOIs (`IEEEtranN-doi.bst.patch`), and is LPPL-licensed.
106
107
  - `generators/app/templates/splncs04nat.bst` comes from [tpavlic/splncs04nat](https://github.com/tpavlic/splncs04nat) and is MIT-licensed.
107
108
  - `generators/app/templates/logos/`: This directory contains logos, which have special licenses (see [`logos/README.md`](generators/app/templates/logos/README.md)).
108
109
  - `generators/app/templates/figures/ulm-minster.jpg` is [Landappbw 79389 1820 Ulmer Münster Ulm.jpg](https://commons.wikimedia.org/w/index.php?curid=131463041) by wkrauth, dedicated to the public domain under [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/).
@@ -26,6 +26,11 @@ the feature vanishes for some switch combination without any error.
26
26
  `<% if (examples) %>`); package loads go in the preamble area. Guard each with the
27
27
  right condition (`isThesis`, a switch value, …) — and gate an example to where the
28
28
  config that makes it compile is present.
29
+ 2a. **Package choice → ADR.** When you pick one package over alternatives (e.g.
30
+ `progressbar` over `progress`), record it as a new ADR in `docs/decisions/` (MADR,
31
+ add it to `index.md`) and add or update the matching GADR in the sibling
32
+ `gadr-latex-packages` repo (see the root `CLAUDE.md`, "Repo roles"); the ADR links the GADR.
33
+ Example: ADR-0015 and `gadr-latex-packages/progress-bars.md`.
29
34
  3. **`Texlivefile`** — add the TeX Live package name, guarded (usually
30
35
  `githubpublish || <condition>`; `githubpublish` deliberately bundles everything).
31
36
  4. **Shell-escape is derived, never hardcoded.** It is the boolean
@@ -222,12 +222,26 @@ export default class extends Generator {
222
222
  2021: "2021-D",
223
223
  2023: "2023-A",
224
224
  2024: "2024-B",
225
- 2025: "2026-B",
226
- 2026: "2026-B",
225
+ 2025: "2026-C",
226
+ 2026: "2026-C",
227
227
  };
228
228
  this.props.danteImage =
229
229
  "danteev/texlive:" + (danteTags[this.props.texlive] ?? "edge");
230
230
 
231
+ // The DANTE e.V. image also contains the linters (aspell with English and German
232
+ // dictionaries, TeXtidote); CI and "make spellcheck" run them there.
233
+ // They do not depend on the TeX Live version, so the image is the first release containing aspell.
234
+ this.props.lintImage = "danteev/texlive:2026-C";
235
+ // Words of the template that aspell word lists cannot contain (see "make dictionaries")
236
+ this.props.hyphenatedWords = [
237
+ "markdown-latex-quickstart",
238
+ "pgf-umlsd",
239
+ "zref-clever",
240
+ "Zref-clever",
241
+ "zref-vario",
242
+ "Zref-vario",
243
+ ];
244
+
231
245
  // The image used to compile in Docker (README, Makefile, VS Code settings)
232
246
  this.props.dockerImage =
233
247
  this.props.docker === "dante"
@@ -339,6 +353,117 @@ export default class extends Generator {
339
353
  }
340
354
  }
341
355
 
356
+ // The main templates mark each chapter with "%%LTG-CHAPTER <name>" (Markdown
357
+ // chapters with "%%LTG-CHAPTER-MARKDOWN <name>") and the end of the last one
358
+ // with "%%LTG-CHAPTERS-END". A thesis gets each chapter as its own file
359
+ // chapters-<lang>/<nn> - <name>.tex, included by the main file; a paper keeps
360
+ // its sections in the main file. Template repositories put the main files of
361
+ // all variants of one language next to each other, so the chapter files must
362
+ // not depend on the variant: the source code example (listings or minted) goes
363
+ // into a file of its own, picked by the package that the main file loads.
364
+ _splitChapters(lines) {
365
+ const isMarker = (line) => line.startsWith("%%LTG-");
366
+ const trim = (chapterLines) => {
367
+ const first = chapterLines.findIndex((line) => line.trim() !== "");
368
+ const last = chapterLines.findLastIndex((line) => line.trim() !== "");
369
+ return first < 0 ? [] : chapterLines.slice(first, last + 1);
370
+ };
371
+ const write = (path, chapterLines) =>
372
+ this.fs.write(this.destinationPath(path), chapterLines.join("\n") + "\n");
373
+ const markdownInput = (path) => {
374
+ const input = `\\markdownInput{${path}}`;
375
+ return this.props.latexcompiler === "both"
376
+ ? ["\\ifluatex", " " + input, "\\fi"]
377
+ : [input];
378
+ };
379
+
380
+ if (!this.props.isThesis) {
381
+ // A paper keeps its sections in the main file, except the Markdown one:
382
+ // content-markdown.md (English) or content-markdown.<lang>.md
383
+ const result = [];
384
+ let markdown = null;
385
+ for (const line of lines) {
386
+ if (markdown && isMarker(line)) {
387
+ const path =
388
+ this.props.language === "en"
389
+ ? "content-markdown.md"
390
+ : `content-markdown.${this.props.language}.md`;
391
+ write(path, trim(markdown));
392
+ result.push(...markdownInput(path), "");
393
+ markdown = null;
394
+ }
395
+ if (line.startsWith("%%LTG-CHAPTER-MARKDOWN")) {
396
+ markdown = [];
397
+ } else if (markdown) {
398
+ markdown.push(line);
399
+ } else if (!isMarker(line)) {
400
+ result.push(line);
401
+ }
402
+ }
403
+ return result;
404
+ }
405
+
406
+ const start = lines.findIndex((line) => line.startsWith("%%LTG-CHAPTER"));
407
+ const end = lines.indexOf("%%LTG-CHAPTERS-END");
408
+ const chapters = [];
409
+ for (const line of lines.slice(start, end)) {
410
+ const match = line.match(/^%%LTG-CHAPTER(-MARKDOWN)? (.+)$/);
411
+ if (match) {
412
+ chapters.push({
413
+ markdown: Boolean(match[1]),
414
+ name: match[2],
415
+ lines: [],
416
+ });
417
+ } else {
418
+ chapters.at(-1).lines.push(line);
419
+ }
420
+ }
421
+
422
+ const language = this.props.language;
423
+ this.fs.copy(
424
+ this.templatePath(`chapters.README.${language}.md`),
425
+ this.destinationPath(`chapters-${language}/README.md`),
426
+ );
427
+ const includes = chapters.flatMap((chapter, index) => {
428
+ // Steps of 10 leave room to insert a chapter without renaming the others
429
+ const base = `chapters-${language}/${(index + 1) * 10} - ${chapter.name}`;
430
+ if (chapter.markdown) {
431
+ write(`${base}.md`, trim(chapter.lines));
432
+ return markdownInput(`${base}.md`);
433
+ }
434
+
435
+ const chapterLines = [];
436
+ let sourceCode = null;
437
+ for (const line of chapter.lines) {
438
+ const match = line.match(/^%%LTG-SOURCECODE (\S+)$/);
439
+ if (match) {
440
+ sourceCode = { listings: match[1], lines: [] };
441
+ } else if (line === "%%LTG-SOURCECODE-END") {
442
+ const file = (listings) => `${base} - ${listings}`;
443
+ write(file(sourceCode.listings) + ".tex", trim(sourceCode.lines));
444
+ chapterLines.push(
445
+ "% The main file loads either the minted or the listings package",
446
+ "\\ifdefined\\inputminted",
447
+ ` \\input{${file("minted")}}`,
448
+ "\\else",
449
+ ` \\input{${file("listings")}}`,
450
+ "\\fi",
451
+ "",
452
+ );
453
+ sourceCode = null;
454
+ } else if (sourceCode) {
455
+ sourceCode.lines.push(line);
456
+ } else {
457
+ chapterLines.push(line);
458
+ }
459
+ }
460
+ write(`${base}.tex`, trim(chapterLines));
461
+ return [`\\include{${base}}`];
462
+ });
463
+
464
+ return [...lines.slice(0, start), ...includes, ...lines.slice(end + 1)];
465
+ }
466
+
342
467
  writing() {
343
468
  this.props.config = this.props;
344
469
  this.fs.copyTpl(
@@ -404,9 +529,38 @@ export default class extends Generator {
404
529
  );
405
530
  }
406
531
 
532
+ // The word lists of aspell (.aspell.<lang>.pws), LTeX+ (.vscode/ltex.dictionary.<language>.txt), and
533
+ // TeXtidote (.textidote.dict) contain the same words. "make dictionaries" merges them in the generated
534
+ // repository the same way (sorted like "LC_ALL=C sort -u"), so its first run changes nothing.
535
+ // LTeX+ (VS Code extension, see .vscode/extensions.json) reads its file automatically; "Add to dictionary" writes there.
536
+ const sortedUnique = (words) => [...new Set(words)].sort();
537
+ const aspellWords = (lang) =>
538
+ this.fs
539
+ .read(this.templatePath(`dot.aspell.${lang}.pws`))
540
+ .split("\n")
541
+ .slice(1)
542
+ .filter((word) => word !== "");
543
+ const ltexWords = {};
544
+ for (const [lang, ltexLanguage] of [
545
+ ["en", "en-US"],
546
+ ["de", "de-DE"],
547
+ ]) {
548
+ if (this.props.language == lang || this.props.githubpublish) {
549
+ // aspell word lists cannot contain hyphenated words; LTeX+ and TeXtidote get them in addition
550
+ ltexWords[lang] = sortedUnique([
551
+ ...aspellWords(lang),
552
+ ...this.props.hyphenatedWords,
553
+ ]);
554
+ this.fs.write(
555
+ this.destinationPath(`.vscode/ltex.dictionary.${ltexLanguage}.txt`),
556
+ ltexWords[lang].join("\n") + "\n",
557
+ );
558
+ }
559
+ }
560
+
407
561
  // TeXtidote (spelling, grammar, and style; CI job "textidote") reads its options from .textidote.
408
- // Its dictionary contains the words of both aspell word lists (without their header lines).
409
- // Both files must not depend on the language: some templates publish both languages into one repository.
562
+ // Its dictionary contains the words of all LTeX+ word lists.
563
+ // .textidote must not depend on the language: some templates publish both languages into one repository.
410
564
  if (this.props.documentclass !== "mwe") {
411
565
  this.fs.copy(
412
566
  this.templatePath("dot.textidote"),
@@ -416,25 +570,17 @@ export default class extends Generator {
416
570
  this.templatePath("dot.textidote.replacements"),
417
571
  this.destinationPath(".textidote.replacements"),
418
572
  );
419
- const words = [
420
- ...new Set(
421
- ["en", "de"].flatMap((lang) =>
422
- this.fs
423
- .read(this.templatePath(`dot.aspell.${lang}.pws`))
424
- .split("\n")
425
- .slice(1)
426
- .filter((word) => word !== ""),
427
- ),
428
- ),
429
- ]
430
- .sort((a, b) => a.localeCompare(b, "en"))
431
- .join("\n");
432
- // aspell word lists cannot contain hyphenated words
433
- const hyphenated =
434
- "zref-clever\nZref-clever\nzref-vario\nZref-vario\npgf-umlsd\nmarkdown-latex-quickstart\n";
435
573
  this.fs.write(
436
574
  this.destinationPath(".textidote.dict"),
437
- words + "\n" + hyphenated,
575
+ sortedUnique(Object.values(ltexWords).flat()).join("\n") + "\n",
576
+ );
577
+ }
578
+
579
+ // refenums 2.0.0 (based on zref-clever) is not yet in TeX Live
580
+ if (this.props.isThesis) {
581
+ this.fs.copy(
582
+ this.templatePath("refenums.sty"),
583
+ this.destinationPath("refenums.sty"),
438
584
  );
439
585
  }
440
586
 
@@ -445,6 +591,13 @@ export default class extends Generator {
445
591
  );
446
592
  }
447
593
 
594
+ if (this.props.documentclass === "ieee") {
595
+ this.fs.copy(
596
+ this.templatePath("IEEEtranN-doi.bst"),
597
+ this.destinationPath("IEEEtranN-doi.bst"),
598
+ );
599
+ }
600
+
448
601
  // Photo for the JPEG example in floats.example.*.tex (CC0, see README)
449
602
  if (this.props.examples) {
450
603
  this.fs.copy(
@@ -483,11 +636,11 @@ export default class extends Generator {
483
636
  // rendering, so the template carries placeholders that are filled here.
484
637
  if (this.props.documentclass !== "mwe") {
485
638
  const mainPath = this.destinationPath(this.props.filenames.main + ".tex");
486
- const lines = this.fs.read(mainPath).split("\n");
639
+ const lines = this._splitChapters(this.fs.read(mainPath).split("\n"));
487
640
  const contentIndex = lines.indexOf("\\begin{document}");
488
641
  const headingIndex = lines.findIndex(
489
642
  (line, index) =>
490
- index > contentIndex && /^\\(chapter|section)\{/.test(line),
643
+ index > contentIndex && /^\\(chapter|section|include)\{/.test(line),
491
644
  );
492
645
  const heading = lines[headingIndex].replace(/\\label\{.*$/, "");
493
646
  this.fs.write(
@@ -617,6 +770,13 @@ export default class extends Generator {
617
770
  break;
618
771
  }
619
772
 
773
+ // GitHub Codespaces (and VS Code Dev Containers): work inside the image, no local LaTeX installation
774
+ this.fs.copyTpl(
775
+ this.templatePath(".devcontainer/devcontainer.json"),
776
+ this.destinationPath(".devcontainer/devcontainer.json"),
777
+ this.props,
778
+ );
779
+
620
780
  if (this.props.isThesis) {
621
781
  this.fs.copy(this.templatePath("docs/*"), this.destinationPath("docs/"));
622
782
  }
@@ -640,11 +800,25 @@ export default class extends Generator {
640
800
  this.destinationPath(".github/workflows/check.yml"),
641
801
  this.props,
642
802
  );
803
+ this.fs.copy(
804
+ this.templatePath(".github/workflows/dictionaries.yml"),
805
+ this.destinationPath(".github/workflows/dictionaries.yml"),
806
+ );
643
807
 
644
808
  this.fs.copy(
645
809
  this.templatePath(".vscode/extensions.json"),
646
810
  this.destinationPath(".vscode/extensions.json"),
647
811
  );
812
+ this.fs.copyTpl(
813
+ this.templatePath("dot.markdownlint.yml"),
814
+ this.destinationPath(".markdownlint.yml"),
815
+ this.props,
816
+ );
817
+ this.fs.copyTpl(
818
+ this.templatePath("dot.typos.toml"),
819
+ this.destinationPath(".typos.toml"),
820
+ this.props,
821
+ );
648
822
  this.fs.copyTpl(
649
823
  this.templatePath("vscode.settings.json"),
650
824
  this.destinationPath("vscode.settings.json"),
@@ -17,7 +17,7 @@ export const options = [
17
17
  value: "lncs",
18
18
  },
19
19
  {
20
- name: "Scientic Thesis",
20
+ name: "Scientific Thesis",
21
21
  value: "scientific-thesis",
22
22
  },
23
23
  {
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "LaTeX",
3
+ "image": "<%= ((uml == "plantuml") || (uml == "mermaid")) ? danteImage : dockerImage %>",
4
+ "customizations": {
5
+ "vscode": {
6
+ "extensions": [
7
+ "james-yu.latex-workshop",
8
+ "tecosaur.latex-utilities",
9
+ "ltex-plus.vscode-ltex-plus",
10
+ "jabref.jabref-4-vscode",
11
+ "davidanson.vscode-markdownlint"
12
+ ],
13
+ "settings": {
14
+ "latex-workshop.docker.enabled": false
15
+ }
16
+ }
17
+ }
18
+ }
@@ -45,7 +45,7 @@ jobs:
45
45
  - run: latexmk <%= filenames.main %>
46
46
  <% if (githubpublish || (lang == "en") && (reallatexcompiler.startsWith("lualatex"))) { -%>
47
47
 
48
- # Highlight mis-spelled words in the PDF
48
+ # Highlight misspelled words in the PDF
49
49
  - uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # v1.6.3
50
50
  with:
51
51
  packages: aspell aspell-en<% if (githubpublish || (language == 'de')) { %> aspell-de<% } %>
@@ -61,18 +61,29 @@ jobs:
61
61
  if: ${{ false }}
62
62
  <% } -%>
63
63
  run: |
64
- for tex in $(ls *.tex content/*.tex 2>/dev/null); do
65
- if [[ "<%= language %>" == "de" && "$tex" == thesis-example* ]]; then
64
+ for tex in *.tex chapters-*/*.tex content-markdown*.md chapters-*/*.md; do
65
+ [ -e "$tex" ] || continue
66
+ if [[ "<%= language %>" == "de" && ( "$tex" == thesis-example* || "$tex" == chapters-de/* ) ]]; then
66
67
  continue
67
68
  fi
68
69
 
69
70
  # The lualatex package "spelling" requires the content to be in a file ending with ".spell.bad"
70
- aspell --mode=tex\
71
- <% if (language == 'de') { %>-l de_DE --run-together<% } else { %>-l en_US<% } %>\
72
- --encoding=utf-8\
73
- --conf=./.aspell.conf\
74
- -p ./.aspell.<%= language %>.pws list\
75
- < $tex | sort | uniq >> <%= filenames.main %>.spell.bad
71
+ # Markdown files may contain LaTeX commands and references (<#id>, {#id}), which are no words.
72
+ if [[ "$tex" == *.md ]]; then
73
+ sed -E 's/\\[A-Za-z]+//g; s/<#[^>]*>//g; s/\{#[^}]*\}//g' "$tex" | aspell --mode=markdown\
74
+ <% if (language == 'de') { %>-l de_DE --run-together<% } else { %>-l en_US<% } %>\
75
+ --encoding=utf-8\
76
+ --conf=./.aspell.conf\
77
+ -p ./.aspell.<%= language %>.pws list\
78
+ | sort | uniq >> <%= filenames.main %>.spell.bad
79
+ else
80
+ aspell --mode=tex\
81
+ <% if (language == 'de') { %>-l de_DE --run-together<% } else { %>-l en_US<% } %>\
82
+ --encoding=utf-8\
83
+ --conf=./.aspell.conf\
84
+ -p ./.aspell.<%= language %>.pws list\
85
+ < "$tex" | sort | uniq >> <%= filenames.main %>.spell.bad
86
+ fi
76
87
  done
77
88
  - run: latexmk <%= filenames.main %>
78
89
 
@@ -134,28 +145,23 @@ jobs:
134
145
  if: false
135
146
  <% } -%>
136
147
  runs-on: ubuntu-latest
148
+ # The DANTE e.V. image contains aspell with English and German dictionaries
149
+ container: <%= lintImage %>
150
+ # In a container, steps run with sh by default
151
+ defaults:
152
+ run:
153
+ shell: bash
137
154
  steps:
138
155
  - name: Set up Git repository
139
156
  uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
140
-
141
- # Original action does not work well - see https://github.com/awalsh128/cache-apt-pkgs-action/pull/136
142
- # The action is not updated - and thus the dictionaries are not updated
143
- - uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # v1.6.3
144
- with:
145
- packages: aspell aspell-en<% if (githubpublish || (language == 'de')) { %> aspell-de<% } %>
146
- version: 1.0
147
- execute_install_scripts: true
148
- - name: post-setup aspell
149
- # refs https://github.com/awalsh128/cache-apt-pkgs-action/issues/157
150
- run: |
151
- sudo apt-get install -y aspell-en<% if (githubpublish || (language == 'de')) { %> aspell-de<% } %>
152
157
  - name: aspell
153
158
  run: |
154
159
  echo "| file | status |" >> $GITHUB_STEP_SUMMARY
155
160
  echo "| -- | -- |" >> $GITHUB_STEP_SUMMARY
156
161
  failure=0
157
- for tex in $(ls *.tex content/*.tex 2>/dev/null); do
158
- if [[ "<%= language %>" == "de" && "$tex" == thesis-example* ]]; then
162
+ for tex in *.tex chapters-*/*.tex content-markdown*.md chapters-*/*.md; do
163
+ [ -e "$tex" ] || continue
164
+ if [[ "<%= language %>" == "de" && ( "$tex" == thesis-example* || "$tex" == chapters-de/* ) ]]; then
159
165
  echo "$tex skipped"
160
166
  continue
161
167
  fi
@@ -164,17 +170,23 @@ jobs:
164
170
  # Pick the dictionary that matches the file's language: the "-de"
165
171
  # variants are German, everything else uses the document's language.
166
172
  case "$tex" in
167
- *-de.tex|*-de-*.tex) aspell_lang="-l de_DE --run-together"; aspell_pws=de ;;
173
+ *-de.tex|*-de-*.tex|*.de.md|chapters-de/*) aspell_lang="-l de_DE --run-together"; aspell_pws=de ;;
174
+ chapters-en/*) aspell_lang="-l en_US"; aspell_pws=en ;;
168
175
  *) aspell_lang="<% if (language == 'de') { %>-l de_DE --run-together<% } else { %>-l en_US<% } %>"; aspell_pws=<%= language %> ;;
169
176
  esac
170
177
 
171
- # Words are output in the order they appear in the document
172
- words=$(aspell --mode=tex $aspell_lang --encoding=utf-8 --conf=./.aspell.conf -p ./.aspell.$aspell_pws.pws list < $tex | tr '\n' ' ')
178
+ # Words are output in the order they appear in the document.
179
+ # Markdown files may contain LaTeX commands and references (<#id>, {#id}), which are no words.
180
+ if [[ "$tex" == *.md ]]; then
181
+ words=$(sed -E 's/\\[A-Za-z]+//g; s/<#[^>]*>//g; s/\{#[^}]*\}//g' "$tex" | aspell --mode=markdown $aspell_lang --encoding=utf-8 --conf=./.aspell.conf -p ./.aspell.$aspell_pws.pws list | tr '\n' ' ')
182
+ else
183
+ words=$(aspell --mode=tex $aspell_lang --encoding=utf-8 --conf=./.aspell.conf -p ./.aspell.$aspell_pws.pws list < "$tex" | tr '\n' ' ')
184
+ fi
173
185
  if [ -z "$words" ]; then
174
186
  echo "| $tex | ✅ |" >> $GITHUB_STEP_SUMMARY
175
187
  else
176
188
  echo "| $tex | ❌ $words |" >> $GITHUB_STEP_SUMMARY
177
- if [[ "$tex" == "<%= filenames.main %>.tex" ]]; then
189
+ if [[ "$tex" == "<%= filenames.main %>.tex" || "$tex" == chapters-<%= language %>/* || "$tex" == content-markdown<% if (language != "en") { %>.<%= language %><% } %>.md ]]; then
178
190
  failure=1
179
191
  fi
180
192
  fi
@@ -197,9 +209,19 @@ jobs:
197
209
  # Report-only: findings show up as annotations, the job does not fail.
198
210
  # Rules come from .textlintrc.json. Only English documents (marked by
199
211
  # "% !TeX spellcheck = en-US") are linted: write-good targets English.
200
- files=$(grep -l '^% !TeX spellcheck = en' *.tex || true)
201
- if [ -z "$files" ]; then
202
- echo "No English .tex files to lint." >> "$GITHUB_STEP_SUMMARY"
212
+ # The English Markdown files (content-markdown.md, chapters-en/*.md) belong to them.
213
+ <% if (isThesis) { -%>
214
+ # The English chapters (chapters-en/*.tex) belong to them.
215
+ <% } -%>
216
+ files=()
217
+ for tex in *.tex<% if (isThesis) { %> chapters-en/*.tex chapters-en/*.md<% } else { %> content-markdown.md<% } %>; do
218
+ [ -e "$tex" ] || continue
219
+ if [[ "$tex" == chapters-en/* || "$tex" == *.md ]] || grep -q '^% !TeX spellcheck = en' "$tex"; then
220
+ files+=("$tex")
221
+ fi
222
+ done
223
+ if [ ${#files[@]} -eq 0 ]; then
224
+ echo "No English files to lint." >> "$GITHUB_STEP_SUMMARY"
203
225
  exit 0
204
226
  fi
205
227
  npx --yes \
@@ -208,31 +230,50 @@ jobs:
208
230
  --package textlint-filter-rule-allowlist \
209
231
  --package textlint-rule-terminology \
210
232
  --package textlint-rule-write-good \
211
- textlint --format github $files \
233
+ textlint --format github "${files[@]}" \
212
234
  | sed "s|${GITHUB_WORKSPACE}/||g" | tee annotations.txt || true
213
235
  count=$(grep -c '^::\(error\|warning\)' annotations.txt || true)
214
- echo "textlint reported ${count} finding(s) in: ${files//$'\n'/, }" >> "$GITHUB_STEP_SUMMARY"
236
+ echo "textlint reported ${count} finding(s) in: $(IFS=,; echo "${files[*]}")" >> "$GITHUB_STEP_SUMMARY"
237
+ typos:
238
+ runs-on: ubuntu-latest
239
+ steps:
240
+ - name: Set up Git repository
241
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
242
+ # Finds common misspellings (configured in .typos.toml)
243
+ - uses: crate-ci/typos@7f9d0819ca1c008ade73f4b41fa9d258d48f605b # v1.51.1
215
244
  <%# TeXtidote checks one language; the German templates contain English template text, so only English documents are checked. -%>
216
245
  <% if (language == "en") { -%>
217
246
  textidote:
218
247
  runs-on: ubuntu-latest
248
+ # The DANTE e.V. image contains TeXtidote
249
+ container: <%= lintImage %>
250
+ # In a container, steps run with sh by default
251
+ defaults:
252
+ run:
253
+ shell: bash
219
254
  steps:
220
255
  - name: Set up Git repository
221
256
  uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
222
- - name: Download TeXtidote
223
- uses: ethanjli/cached-download-action@f1d109e4eca8d988e012ed5565366717aba90d0f # v0.1.4
224
- with:
225
- url: https://github.com/sylvainhalle/textidote/releases/download/v0.9/textidote.jar
226
- destination: ${{ runner.temp }}/textidote.jar
227
257
  - name: Check spelling, grammar, and style with TeXtidote
228
258
  run: |
229
259
  # Report-only: findings show up as annotations, the job does not fail.
230
260
  # TeXtidote (https://github.com/sylvainhalle/textidote) reads its options from .textidote.
231
- # -Djdk.xml.totalEntitySizeLimit=0: TeXtidote 0.9 fails on Java 24+ otherwise (fixed after 0.9: sylvainhalle/textidote#274)
232
- java -Djdk.xml.totalEntitySizeLimit=0 -jar "$RUNNER_TEMP/textidote.jar" --output singleline --no-color <%= filenames.main %>.tex > textidote.txt || true
261
+ textidote --output singleline --no-color <%= filenames.main %>.tex > textidote.txt || true
262
+ <% if (isThesis) { -%>
263
+ # TeXtidote mixes up the text of \include lines, so .textidote removes them and each chapter is checked on its own
264
+ for tex in chapters-en/*.tex chapters-en/*.md; do
265
+ [ -e "$tex" ] || continue
266
+ textidote --output singleline --no-color --read-all "$tex" >> textidote.txt || true
267
+ done
268
+ <% } else { -%>
269
+ # \markdownInput is removed by .textidote, so the Markdown file is checked on its own
270
+ if [ -e content-markdown.md ]; then
271
+ textidote --output singleline --no-color content-markdown.md >> textidote.txt || true
272
+ fi
273
+ <% } -%>
233
274
  # A finding looks like: file.tex(L25C1-L25C25): message "excerpt"
234
275
  perl -ne 'if (/^(.+?)\(L(\d+)C(\d+)-L(\d+)C(\d+)\): (.*)$/) { my ($f, $l, $c, $el, $ec, $m) = ($1, $2, $3, $4, $5, $6); $m =~ s/%/%25/g; print "::warning file=$f,line=$l,col=$c,endLine=$el,endColumn=$ec,title=TeXtidote::$m\n" }' textidote.txt
235
- echo "TeXtidote reported $(grep -c . textidote.txt) finding(s) in <%= filenames.main %>.tex" >> "$GITHUB_STEP_SUMMARY"
276
+ echo "TeXtidote reported $(grep -c . textidote.txt) finding(s) in <%= filenames.main %>.tex<% if (isThesis) { %> and its chapters<% } else { %> and content-markdown.md<% } %>" >> "$GITHUB_STEP_SUMMARY"
236
277
  <% } -%>
237
278
  <% } -%>
238
279
  indent:
@@ -0,0 +1,25 @@
1
+ # Keeps the word lists of the spell checkers in sync: when a push changes the aspell or the
2
+ # LTeX+ word list (e.g., a word added in VS Code), "make dictionaries" merges them and the
3
+ # merged word lists are committed (see the README FAQ on adding words).
4
+ name: Dictionaries
5
+ on:
6
+ push:
7
+ paths:
8
+ - '.aspell.*.pws'
9
+ - '.vscode/ltex.dictionary.*.txt'
10
+ workflow_dispatch:
11
+ permissions:
12
+ contents: write
13
+ jobs:
14
+ dictionaries:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - name: Set up Git repository
18
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
19
+ - name: Merge the word lists
20
+ run: make LOCAL=1 dictionaries
21
+ # Commits made with the GITHUB_TOKEN do not trigger this workflow again
22
+ - uses: EndBug/add-and-commit@cc9c08ba6c8df3b93a8f2db63e89b98368ae2ae8 # v11.1.1
23
+ with:
24
+ message: 'Merge the word lists of the spell checkers (make dictionaries)'
25
+ default_author: github_actions
@@ -3,6 +3,7 @@
3
3
  "james-yu.latex-workshop",
4
4
  "tecosaur.latex-utilities",
5
5
  "ltex-plus.vscode-ltex-plus",
6
- "jabref.jabref-4-vscode"
6
+ "jabref.jabref-4-vscode",
7
+ "davidanson.vscode-markdownlint"
7
8
  ]
8
9
  }