Skip to content

Commit 5d956db

Browse files
committed
init languagetool
Signed-off-by: DanRoscigno <[email protected]>
1 parent 8815b3c commit 5d956db

File tree

3 files changed

+103
-10
lines changed

3 files changed

+103
-10
lines changed

.vscode/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"asciidoc.antora.enableAntoraSupport": true
2+
"asciidoc.antora.enableAntoraSupport": true,
3+
"languageToolLinter.languageTool.ignoredWordsInWorkspace": [
4+
"langtool",
5+
"languagemodel",
6+
"ngrams",
7+
"yaml"
8+
]
39
}

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,40 @@ help:
55

66
# antora.build: @ Builds documentation production output (to build/site)
77
antora.build:
8-
docker-compose run -u $$(id -u) antora antora generate --clean antora-playbook.yml
8+
docker compose run -u $$(id -u) antora antora generate --clean antora-playbook.yml
99

1010
# antora.run: @ Serves documentation output (on port 8051)
1111
antora.run:
12-
docker-compose run --service-ports antora http-server build/site -c-1
12+
docker compose run --service-ports antora http-server build/site -c-1
1313

1414
# antora.watch: @ Watches for documentation changes and rebuilds (to build/site)
1515
antora.watch:
16-
docker-compose run -u $$(id -u) -T antora onchange \
16+
docker compose run -u $$(id -u) -T antora onchange \
1717
-i antora-playbook.yml 'content/**' \
1818
-- antora generate antora-playbook.yml
1919

2020
# antora.shell: @ Opens bash shell in antora container
2121
antora.shell: CMD ?= /bin/sh
2222
antora.shell:
23-
docker-compose run -u $$(id -u) antora $(CMD)
23+
docker compose run -u $$(id -u) antora $(CMD)
2424

2525
# node_modules: @ Runs initial ui npm install
2626
node_modules:
27-
docker-compose run ui npm install
27+
docker compose run ui npm install
2828

2929
# ui.build: @ Builds ui production output (to build/ui-bundle.zip)
3030
ui.build: node_modules
31-
docker-compose run -u $$(id -u) ui node_modules/.bin/gulp bundle
31+
docker compose run -u $$(id -u) ui node_modules/.bin/gulp bundle
3232

3333
# ui.lint: @ Runs ui linting
3434
ui.lint: node_modules
35-
docker-compose run -u $$(id -u) ui node_modules/.bin/gulp lint
35+
docker compose run -u $$(id -u) ui node_modules/.bin/gulp lint
3636

3737
# ui.run: @ Runs ui server in preview mode (port 8052)
3838
ui.run: node_modules
39-
docker-compose run -u $$(id -u) --service-ports ui node_modules/.bin/gulp preview
39+
docker compose run -u $$(id -u) --service-ports ui node_modules/.bin/gulp preview
4040

4141
# ui.shell: @ Opens bash shell in ui container
4242
ui.shell: CMD ?= /bin/bash
4343
ui.shell:
44-
docker-compose run -u $$(id -u) ui $(CMD)
44+
docker compose run -u $$(id -u) ui $(CMD)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
= Tools for writers
2+
3+
== LanguageTool
4+
5+
Grammar, style, and spell checking with https://marketplace.visualstudio.com/items?itemName=davidlday.languagetool-linter[LanguageTool Linter].
6+
7+
I switched from Grammarly to LanguageTool to more easily control my settings. I can now
8+
add custom spelling entries to my dictionary from VS Code easily. I am running the server
9+
on my laptop using Docker.
10+
11+
I find the https://dev.languagetool.org/finding-errors-using-n-gram-data.html[ngram support] to be helpful
12+
13+
I run LanguageTool in Docker. Erick van Leeuwen provides information for running https://github.com/Erikvl87/docker-languagetool[LanguageTool with Docker Compose].
14+
15+
The VS Code extension to use is [LanguageTool](https://marketplace.visualstudio.com/items?itemName=davidlday.languagetool-linter)
16+
17+
Here are the config entries for VS Code:
18+
19+
```json
20+
"editor.formatOnType": true,
21+
"languageToolLinter.languageTool.language": "en-US",
22+
"languageToolLinter.languageTool.motherTongue": "en-US",
23+
"languageToolLinter.lintOnChange": true,
24+
"languageToolLinter.lintOnOpen": true,
25+
```
26+
27+
At the end of this README is the `docker-compose.yml` that I use, it is based on Eric van Leeuwen's (linked above). I added some configuration for my preferences. These are described below.
28+
29+
The compose file passes the environment to `start.sh` (maintained
30+
by https://github.com/Erikvl87/docker-languagetool[erikvl87]), and any env vars that begin with `langtool_` are
31+
considered to be entries for a configuration file that will be
32+
passed to the `langtool` server.
33+
34+
If you see in the LanguageTool docs "Add `disabledRuleIds= a comma separated list
35+
of Rule IDs to ignore`, then the entry in the docker compose file
36+
to disable the WHITESPACE_RULE and the EN_UNPAIRED_BRACKETS rule would be:
37+
38+
.Disable Whitespace and unpaired bracket rules
39+
[source, yaml]
40+
----
41+
- langtool_disabledRuleIds=WHITESPACE_RULE,EN_UNPAIRED_BRACKETS
42+
----
43+
44+
I disable the WHITESPACE_RULE as it marks every line of a Markdown
45+
table as a problem if you use more than one space to pad entries
46+
(I like to line the `|` symbols up on each row with the longest
47+
entry in a column).
48+
49+
I disable the EN_UNPAIRED_BRACKETS as it complains unpaired square brackets used for Asciidoc URLs (spaces in the link text trigger the rule).
50+
51+
The rule IDs can be found in VS Code in the problems view.
52+
53+
Similarly, the env line to specify the location of the ngrams is:
54+
55+
.Enable ngrams support
56+
[source, yaml]
57+
----
58+
- langtool_languageModel=/ngrams/
59+
----
60+
61+
This assumes that you mount the ngrams from your host machine to
62+
`/ngrams` in the container. I do so like this:
63+
64+
.Mount the ngrams volume
65+
[source, yaml]
66+
----
67+
volumes:
68+
- /Users/droscign/ngrams:/ngrams
69+
----
70+
71+
.docker-compose.yaml
72+
[source, yaml]
73+
----
74+
services:
75+
languagetool:
76+
image: erikvl87/languagetool
77+
container_name: languagetool
78+
ports:
79+
- 8081:8010 # Using default port from the image
80+
environment:
81+
- langtool_languageModel=/ngrams/
82+
- langtool_disabledRuleIds=WHITESPACE_RULE,EN_UNPAIRED_BRACKETS
83+
- Java_Xms=512m # OPTIONAL: Setting a minimal Java heap size of 512 mib
84+
- Java_Xmx=1g # OPTIONAL: Setting a maximum Java heap size of 1 Gib
85+
volumes:
86+
- /Users/droscign/ngrams:/ngrams
87+
----

0 commit comments

Comments
 (0)