Merge pull request 'feat: Markdown-Hook mit Custom-Rule "no-hr"' (#11) from feat/markdown-no-hr-hook into main
This commit was merged in pull request #11.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"config": {
|
||||
"default": true,
|
||||
// Zeilenlänge: keine harte Grenze in Markdown.
|
||||
"MD013": false,
|
||||
// Sprache im Fenced Code Block: oft sinnvoll leer (ASCII-Diagramme, Pfade).
|
||||
"MD040": false,
|
||||
// Erste Zeile muss kein H1 sein.
|
||||
"MD041": false,
|
||||
// Tabellen-Spacing-Style: Geschmackssache, nicht auto-fixbar.
|
||||
"MD060": false,
|
||||
// Eigene Regel: keine horizontalen Trennlinien (Struktur über Überschriften).
|
||||
"no-hr": true
|
||||
},
|
||||
"customRules": [
|
||||
"./hooks/markdownlint-rules/no-hr.js"
|
||||
]
|
||||
}
|
||||
@@ -75,6 +75,18 @@ else
|
||||
echo "✓ shellcheck installiert"
|
||||
fi
|
||||
|
||||
# --- markdownlint-cli2 (Markdown-Lint-Hook, custom rule no-hr) ---
|
||||
if command -v markdownlint-cli2 &>/dev/null; then
|
||||
echo "✓ markdownlint-cli2 $(markdownlint-cli2 --version 2>/dev/null | head -1)"
|
||||
else
|
||||
echo " markdownlint-cli2 fehlt – installiere via npm..."
|
||||
if ! command -v npm &>/dev/null; then
|
||||
sudo apt-get install -y npm
|
||||
fi
|
||||
sudo npm install -g markdownlint-cli2
|
||||
echo "✓ markdownlint-cli2 installiert"
|
||||
fi
|
||||
|
||||
# --- gitea-mcp Binary ---
|
||||
if [[ -x ~/go/bin/gitea-mcp ]]; then
|
||||
echo "✓ gitea-mcp vorhanden"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 }
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user