From d799b382f1760a16f3a6c39e7aad65115183f3c6 Mon Sep 17 00:00:00 2001 From: Jacobus Geluk Date: Tue, 27 Jan 2026 15:48:29 +0000 Subject: [PATCH] chore: add formatting and linting configuration - Add .markdownlint.json for markdown line length rules - Add .prettierrc.json with 70 char width and prose wrapping - Add custom prettier plugin to strip non-breaking spaces from markdown - Update .vscode/settings.json to trim trailing whitespace Co-Authored-By: Claude Opus 4.5 --- .markdownlint.json | 10 ++++++++ .prettierrc.json | 18 +++++++++++++++ .scripts/prettier-plugin-strip-nbsp.js | 32 ++++++++++++++++++++++++++ .vscode/settings.json | 8 ++++--- 4 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 .markdownlint.json create mode 100644 .prettierrc.json create mode 100644 .scripts/prettier-plugin-strip-nbsp.js diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..e73a514 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,10 @@ +{ + "MD013": { + "line_length": 70, + "heading_line_length": 70, + "code_block_line_length": 9999 + }, + "MD025": { + "front_matter_title": "" + } +} diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..d4aab2d --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,18 @@ +{ + "printWidth": 70, + "proseWrap": "always", + "overrides": [ + { + "files": "*.md", + "options": { + "printWidth": 70, + "proseWrap": "always", + "endOfLine": "lf" + } + } + ], + "plugins": [ + "./.scripts/prettier-plugin-strip-nbsp.js" + ], + "endOfLine": "lf" +} diff --git a/.scripts/prettier-plugin-strip-nbsp.js b/.scripts/prettier-plugin-strip-nbsp.js new file mode 100644 index 0000000..db4fa04 --- /dev/null +++ b/.scripts/prettier-plugin-strip-nbsp.js @@ -0,0 +1,32 @@ +// Prettier plugin to strip trailing non-breaking spaces from markdown files +const markdown = require('prettier/parser-markdown'); + +module.exports = { + parsers: { + markdown: { + ...markdown.parsers.markdown, + parse(text, parsers, options) { + // Remove trailing non-breaking spaces (U+00A0) and other Unicode whitespace at end of lines + // This handles both lines that end with non-breaking spaces and lines that are entirely non-breaking spaces + let cleaned = text + // Remove trailing Unicode whitespace (non-breaking spaces, etc.) at end of lines + .replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000]+$/gm, '') + // Also remove lines that are entirely Unicode whitespace (non-breaking spaces) + .replace(/^[\u00A0\u2000-\u200B\u202F\u205F\u3000]+\n/gm, '\n'); + + // Convert leading non-breaking spaces to regular spaces + // This fixes formatting issues where NBSP at the start of lines prevents proper paragraph/list formatting + cleaned = cleaned.replace(/^([\u00A0\u2000-\u200B\u202F\u205F\u3000]+)/gm, (match) => ' '.repeat(match.length)); + + // Convert non-breaking spaces before markdown list markers to regular spaces + // This fixes formatting issues where NBSP prevents proper list item recognition + cleaned = cleaned.replace(/([\s]*)[\u00A0\u2000-\u200B\u202F\u205F\u3000]+([-*+]\s)/gm, '$1$2'); + + // Use the original markdown parser + return markdown.parsers.markdown.parse(cleaned, parsers, options); + }, + }, + }, + printers: markdown.printers, + languages: markdown.languages, +}; diff --git a/.vscode/settings.json b/.vscode/settings.json index 5adb9ef..2efac0e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,8 @@ { "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python", - "makefile.configureOnOpen": false + "makefile.configureOnOpen": false, + "files.trimTrailingWhitespace": true, + "[markdown]": { + "files.trimTrailingWhitespace": false + } } - -