hplush / slowreader

Web app to combine feeds from social networks and RSS and to help read more meaningful and deep content
https://dev.slowreader.app
GNU Affero General Public License v3.0
161 stars 37 forks source link

Add Markdown linter #129

Closed ilyatitovich closed 7 months ago

ilyatitovich commented 8 months ago

Fixes #97

When searching for a Markdown linter, I settled on remark. The linter has an extensive collection of plugins and presets for processing Markdown files, allowing us to check only the necessary rules. It is possible to write custom rules to perform specific tasks.

I added 4 packages:

We may also need the remark-toc plugin, which allows us to generate TOC for *.md files.

Additionally, a .remarkrc.js file has been added, in which the necessary plugins are connected.

Using this linter, we can check whether links in a document are alive. For other tasks we need to write our own rules.

If this linter suits us, then I’ll start to work with GitHub Actions to add .github/workflows/docs.yml to run linter on */.md files changes.

And I'm a little confused by the task: Find way to avoid calling in .github/workflows/root.yml, because I don't see this file in the workflows directory.

Motivation

Add to the project a good, flexible linter for checking *.md files for mistakes.

Checklist

ai commented 8 months ago

We may also need the remark-toc plugin, which allows us to generate TOC for *.md files.

We may need to write custom rule here too, since we need not generate TOC but to test current TOC (i am not sure how this plugin works to be honest, maybe it checks).

And I'm a little confused by the task: Find way to avoid calling in .github/workflows/root.yml, because I don't see this file in the workflows directory.

Oops. I renamed this file to test.yml since I created an issue.

Here is a problem. We run test.yml on non-md changes because it runs a lot of expensive test (like staging deploy).

We need to keep separation between “just test docs quickly on spellchecking PR” and “change a code”. But test.yml now runs all tests which started from test:. So we need to change test.yml to not run test:markdown (but run it on pnpm test which should test everything).

ilyatitovich commented 7 months ago

In order to exclude the running of the "test:markdown" script from GitHub Actions, I suggest adding the grep -v "test:markdown" filter. It will skip and run all scripts starting with "test:" except "test:markdown".

Added docs.yml file to run tests specifically for .md files.

I removed the remark-lint-code-block-style package, because it really doesn’t do what we need. I have not yet discovered a plugin that checks indentation inside a list element.

Added --frail to the script: "test:markdown": "remark . --frail". Now linter displays a warning and returns an error:

links

Added the remark tool to the Tools section in README.md.

ilyatitovich commented 7 months ago

Updated the docs.yml file, adding PR bypass and standard installation of the environment and packages.

Updated the script in the test.yml file for running tests by adding the regular expression '/^test:(?!markdown\b)/'. It will allow us to run all tests except the "test:markdown". Checked locally - it works.

ai commented 7 months ago
  1. When you will fix issues, press Resolve conversation
  2. We need also to resolve conflicts

But I think it is the last code review. We are very close to merging.

ilyatitovich commented 7 months ago

Corrected logical mistakes in docs.yml. Resolved conflicts.

Interesting task! I learned a lot of new things :)

ai commented 7 months ago

Thanks! I created an issue for next step https://github.com/hplush/slowreader/issues/140