|
| 1 | +--- |
| 2 | +id: MDS060 |
| 3 | +name: occurrence |
| 4 | +status: ready |
| 5 | +description: >- |
| 6 | + A scope must contain each configured token or pattern between `min` and |
| 7 | + `max` times (inclusive). Counts prose only; fenced and indented code |
| 8 | + blocks are excluded. |
| 9 | +category: prose |
| 10 | +nature: content |
| 11 | +maintainability: null |
| 12 | +markdownlint: [] |
| 13 | +rumdl: [] |
| 14 | +mado: [] |
| 15 | +panache: [] |
| 16 | +obsidian-linter: [] |
| 17 | +gomarklint: [] |
| 18 | +--- |
| 19 | +# MDS060: occurrence |
| 20 | + |
| 21 | +A scope must contain each configured token or pattern between `min` and |
| 22 | +`max` times (inclusive). Counts prose only; fenced and indented code |
| 23 | +blocks are excluded. |
| 24 | + |
| 25 | +The rule walks every scope unit (file, heading-bounded section, or |
| 26 | +paragraph) and counts non-overlapping occurrences of each token or regex |
| 27 | +pattern match. Fenced and indented code blocks are never counted. |
| 28 | +A diagnostic is emitted at the scope unit's first line when the count |
| 29 | +falls below `min` or exceeds `max`. |
| 30 | + |
| 31 | +`tokens` and `pattern` are mutually exclusive. Use `lists:` to pull |
| 32 | +token sets from wordlist files without repeating them inline. |
| 33 | + |
| 34 | +## Settings |
| 35 | + |
| 36 | +| Setting | Type | Default | Description | |
| 37 | +| ---------------- | --------------- | ----------- | ------------------------------------------------------------------- | |
| 38 | +| `scope` | string | `paragraph` | `file`, `section`, or `paragraph` | |
| 39 | +| `tokens` | list of strings | `[]` | Literal substrings to count. Populated by `lists:`. Mutually | |
| 40 | +| | | | exclusive with `pattern`. | |
| 41 | +| `pattern` | string | `""` | Go RE2 regex to match. Mutually exclusive with `tokens`. | |
| 42 | +| `min` | integer | `0` | Minimum occurrences per scope unit (must be >= 0) | |
| 43 | +| `max` | integer | `-1` | Maximum occurrences per scope unit; `-1` is unbounded | |
| 44 | +| `count` | string | `each` | `each` checks each token independently; `combined` sums all matches | |
| 45 | +| `case-sensitive` | bool | `false` | When false, token matching ignores case | |
| 46 | + |
| 47 | +## Config |
| 48 | + |
| 49 | +Enable with em-dash density preset (at most two per paragraph): |
| 50 | + |
| 51 | +```yaml |
| 52 | +rules: |
| 53 | + occurrence: |
| 54 | + enabled: true |
| 55 | + pattern: "—" |
| 56 | + scope: paragraph |
| 57 | + count: combined |
| 58 | + max: 2 |
| 59 | +``` |
| 60 | +
|
| 61 | +Enable with term-density preset (buzzword list, at most twice per section): |
| 62 | +
|
| 63 | +```yaml |
| 64 | +rules: |
| 65 | + occurrence: |
| 66 | + enabled: true |
| 67 | + scope: section |
| 68 | + count: each |
| 69 | + max: 2 |
| 70 | + lists: |
| 71 | + - buzzwords |
| 72 | +``` |
| 73 | +
|
| 74 | +Disable: |
| 75 | +
|
| 76 | +```yaml |
| 77 | +rules: |
| 78 | + occurrence: false |
| 79 | +``` |
| 80 | +
|
| 81 | +## Examples |
| 82 | +
|
| 83 | +### Token exceeds max |
| 84 | +
|
| 85 | +<?include |
| 86 | +file: bad/section-scope.md |
| 87 | +wrap: markdown |
| 88 | +?> |
| 89 | +
|
| 90 | +```markdown |
| 91 | +# Title |
| 92 | + |
| 93 | +jargon jargon jargon here. |
| 94 | +``` |
| 95 | + |
| 96 | +<?/include?> |
| 97 | + |
| 98 | +### Pattern under max |
| 99 | + |
| 100 | +<?include |
| 101 | +file: good/default.md |
| 102 | +wrap: markdown |
| 103 | +?> |
| 104 | + |
| 105 | +```markdown |
| 106 | +# Title |
| 107 | + |
| 108 | +First — second — end. |
| 109 | +``` |
| 110 | + |
| 111 | +<?/include?> |
| 112 | + |
| 113 | +### Fenced code blocks excluded |
| 114 | + |
| 115 | +<?include |
| 116 | +file: good/fenced-code-excluded.md |
| 117 | +wrap: markdown |
| 118 | +?> |
| 119 | + |
| 120 | +````markdown |
| 121 | +# Title |
| 122 | + |
| 123 | +keyword keyword. |
| 124 | + |
| 125 | +```text |
| 126 | +keyword keyword keyword |
| 127 | +``` |
| 128 | +```` |
| 129 | + |
| 130 | +<?/include?> |
| 131 | + |
| 132 | +## Meta-Information |
| 133 | + |
| 134 | +- **ID**: MDS060 |
| 135 | +- **Name**: `occurrence` |
| 136 | +- **Status**: ready |
| 137 | +- **Default**: disabled |
| 138 | +- **Fixable**: no |
| 139 | +- **Implementation**: [source](./) |
| 140 | +- **Category**: prose |
0 commit comments