feat: Markdown-Hook mit Custom-Rule "no-hr"

Erzwingt Struktur über Überschriften statt horizontaler Trennlinien.

- Custom Rule hooks/markdownlint-rules/no-hr.js erkennt --- / *** / ___
  über das markdown-it-Token "hr" und liefert fixInfo zum Entfernen.
- .markdownlint-cli2.jsonc aktiviert no-hr und deaktiviert MD013/MD040/MD041/MD060
  (Begründung jeweils inline kommentiert).
- hooks/auto-format.sh erweitert um md|markdown-Zweig mit zwei --fix-Pässen
  (zweiter Pass räumt MD012-Doppel-Leerzeilen auf, die nach HR-Entfernung entstehen).
- bootstrap.sh installiert markdownlint-cli2 idempotent via npm -g.

Verifiziert:
- Custom Rule meldet --- und *** als Verstoß.
- Zwei --fix-Pässe entfernen Trennlinien und überflüssige Leerzeilen, Endzustand 0 Fehler.
- Bestehende README in /home/martin/Darktable/README.md ist nach Konfig-Anpassung 0 Fehler.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-22 10:10:17 +02:00
co-authored by Claude Opus 4.7
parent ab736c2466
commit 6aecff2eea
4 changed files with 60 additions and 0 deletions
+11
View File
@@ -33,6 +33,17 @@ case "$EXT" in
shellcheck "$FILE" || true
fi
;;
md|markdown)
if command -v markdownlint-cli2 &>/dev/null; then
# Erster Pass: entfernt Trennlinien und sonstige fixbare Verstöße.
# Zweiter Pass: räumt die nun verwaisten Mehrfach-Leerzeilen auf (MD012).
for _ in 1 2; do
markdownlint-cli2 \
--config /mnt/projekte/claude-workflow/.markdownlint-cli2.jsonc \
--fix "$FILE" >/dev/null 2>&1 || true
done
fi
;;
esac
exit 0
+19
View File
@@ -0,0 +1,19 @@
/** @type {import("markdownlint").Rule} */
module.exports = {
names: ["no-hr", "no-horizontal-rules"],
description: "Horizontale Trennlinien sind nicht erlaubt",
tags: ["style"],
parser: "markdownit",
function: (params, onError) => {
for (const token of params.parsers.markdownit.tokens) {
if (token.type !== "hr") continue;
const startLine = token.map[0] + 1;
onError({
lineNumber: startLine,
detail: "Struktur über Überschriften, nicht über Trennlinien.",
context: token.line,
fixInfo: { lineNumber: startLine, deleteCount: -1 }
});
}
}
};