canonical / praecepta

Creative Commons Attribution Share Alike 4.0 International
12 stars 18 forks source link

Adds rule #09 - no links in headings #20

Closed SecondSkoll closed 5 months ago

SecondSkoll commented 5 months ago

Adds style rule to Canonical folder, and adds test3.md document to test rule against

Forced to operate on raw scope due to how Vale works with parsing contents.

Captures the following occurrences:

rkratky commented 5 months ago

Ugh, this is painful to read :)

Anyway, LGTM, but I'm wondering if we want to expand the RST scope to include either all possible levels/kinds of headings [1], or at least the ones we recommend [2].

1) https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#sections 2) https://canonical-documentation-with-sphinx-and-readthedocscom.readthedocs-hosted.com/style-guide/#headings

.........

Side note: Thanks to your test case, I realized the $sentence case test is broken in various places. Namely, it flags headings when they begin with an acronym ("RST heading with sentence case" causes a false positive; this can be fixed by adding '[A-Z]{3,5}' to exceptions). And conversely, it ignores all occurrences of incorrect case when only two capitalized words appear in the heading:

Not flagged: "Incorrect sentence Case used" Flagged: "Incorrect Sentence Case used"

I'll try to test it more and then pbbly file it as an issue for vale.

SecondSkoll commented 5 months ago

Anyway, LGTM, but I'm wondering if we want to expand the RST scope to include either all possible levels/kinds of headings [1], or at least the ones we recommend [2].

@rkratky - the way I've used the raw content to find the RST headings is using \n(.)\1{3,}\n' which is a new line, a capture group of a single character and then checking if that capture group (single character) is repeated until the next new line. So it should find all occurrences of RST headings. I don't see any real call for this formatting being used anywhere else.

I'll update with some MyST parser things tomorrow, as MyST parser also has <these:refs> which I also forgot about.

rkratky commented 5 months ago

Anyway, LGTM, but I'm wondering if we want to expand the RST scope to include either all possible levels/kinds of headings [1], or at least the ones we recommend [2].

using \n(.)\1{3,}\n'

Right, sorry. I misread the regex.

SecondSkoll commented 5 months ago

@rkratky I just realised that there's a case there that uses = and - as the underline, but it's for the much less used Markdown heading syntax. So you actually didn't misread it at all.