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 more Markdown plugins #149

Closed ilyatitovich closed 7 months ago

ilyatitovich commented 7 months ago

Fixes #140

I started working on custom plugins for remark. The first plugin I decided to make is a plugin for checking the correct capitalization of words in titles.

Additional packages have been installed: unified-lint-rule and unist-util-visit. This packages allow us to create custom rules for remark.

What does the plugin do?

Plugin formats the title, compares it with the current one and issues a warning with the expected variant and what was found.

I decided to do full formatting of the title so that the plugin shouldn't skip some strange mistakes, for example ExAmplE woRd. If user needs to leave the spelling of a word, he can add it to the exclusion list.

The formated title is saved in cache, which allow us to avoid repeated calculations if the same title is found in other documents.

Logic

To detect articles and other words that, according to the rules, should be written with a small letter, I created an object where these words will be stored. This will allow us to quickly find the desired exception by checking the key.

I added the ability to send to the plugin a list of exception words that the linter should skip. This will allow us to bypass the rules if the author believes that the word should retain its spelling.

The linter also skip words written in uppercase. It is understood that such writing is the original intention of the author.

Linter will detect if the first word in the title is capitalized (even if it is usually written in lowercase) and will suggest capitalizing it.

The result of the plugin's work currently looks like this: titles

This is the first project of this kind for me, I’m looking forward to the review! :)

Motivation

Our own plugins will allow us to find specific errors in .md files.

Checklist

ai commented 7 months ago

I am closing this since we have separated PRs