Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spell checkers as optional #238

Open
martinthomson opened this issue Aug 27, 2020 · 1 comment
Open

Add spell checkers as optional #238

martinthomson opened this issue Aug 27, 2020 · 1 comment

Comments

@martinthomson
Copy link
Owner

@larseggert shared this neat hack:

diff --git a/main.mk b/main.mk
index d49ec88..c50c2a4 100644
--- a/main.mk
+++ b/main.mk
@@ -77,7 +77,18 @@ endif
      cat $< $(MD_PRE) | $(mmark) -xml2 -page $(MD_POST) $@; \
    else \
      ! echo "Unable to detect '%%%' or '---' in markdown file" 1>&2; \
-   fi && [ -e $@ ]
+   fi && [ -e $@ ]; \
+   codespell $<; \
+   sed -e "s/MAY/may/g" -e "s/MUST NOT/must not/g" -e "s/MUST/must/g" \
+       -e "s/NOT RECOMMENDED/not recommended/g" \
+       -e "s/OPTIONAL/optional/g" -e "s/RECOMMENDED/recommended/g" \
+       -e "s/REQUIRED/required/g" -e "s/SHALL NOT/shall not/g" \
+       -e "s/SHALL/shall/g" -e "s/SHOULD NOT/should not/g" \
+       -e "s/SHOULD/should/g" $@ | \
+   languagetool --disable WORD_CONTAINS_UNDERSCORE \
+       --disablecategories PUNCTUATION,TYPOGRAPHY --xmlfilter - || exit 0
+
+# --language en-US 

 ifdef REFCACHEDIR
 %.xml: .refcache

I think that the right place to put something like that is under a new target, as this is likely to produce a ton of chaff. People can then make spell checking mandatory by adding to their Makefile as follows:

lint:: spellcheck

This is a general pattern I'm considering for lints. I want to pull in the column-length checks that we use in QUIC in a similar way. I'm certain that most people won't want those, but they are generally useful as a discretionary feature.

@martinthomson
Copy link
Owner Author

Took a look at this and while codespell is fairly simple, languagetool installation requirements are... epic. This means standing up services or something like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant