Check type ID#

kind: text_forbids

Purpose#

Forbid a regular expression from appearing in the body text.

Configuration keys#

FieldRequiredDefaultMeaning
patternyes-Go regular expression, matched unanchored.
targetnobodySpan selector: body, line, first-line, or matched-lines.
selectno-Line-filter regex; required for and only valid with target matched-lines.
fixno-Optional replacement template (regexp capture syntax) applied to the matched text by the fix command.

Example#

collections:
  notes:
    path: notes
    checks:
      - kind: text_forbids
        target: line
        pattern: '\bTODO\b'

Worked example#

The text_forbids check forbids a trailing period on the first line; its fix template strips it. Only the matched text changes; the later keep this. line is untouched.

Input#

notes/doc.md

---
t: 1
---
# Title.
keep this.

.katalyst/bases/my_directory.yaml

type: filesystem
root: .
collections:
  notes:
    path: notes
    checks:
      - kind: text_forbids
        target: first-line
        pattern: '\.(\s*)$'
        fix: '$1'

Command#

$ katalyst fix notes/doc
<project>/notes/doc.md

Result#

notes/doc.md after katalyst fix notes/doc:

---
t: 1
---
# Title
keep this.