Content Review & Linting Tools
Relevant source files
The following files were used as context for generating this wiki page:
The Content Review & Linting system in the whk project is a suite of automated and semi-automated tools designed to ensure Markdown articles adhere to specific typographic and structural standards. These tools handle tasks ranging from automated linting and formatting to AI-assisted content auditing, focusing on technical accuracy, KaTeX formula correctness, and Chinese-English mixed typesetting.
Sources: REVIEW.md:1-5, AGENTS.md:38-45, scripts/review/SKILL.md:1-5
System Architecture and Command Execution
The review system is orchestrated through a central entry point, scripts/review/review.js. This script acts as a command dispatcher that identifies available sub-commands by scanning the directory and executes them within the context of the project's root directory.
Command Dispatch Logic
The review.js script performs the following steps to execute a tool:
- Validates the command arguments.
- Locates the specific script file (e.g.,
lint.jsordiff.js) within thescripts/review/directory. - Identifies the git project root using
git rev-parse --show-toplevel. - Spawns a child process to run the command with inherited standard I/O.
Sources: scripts/review/review.js:5-38
The diagram above illustrates the command execution flow from the user to specific review sub-tools. Sources: scripts/review/review.js:18-35
Linting and Automated Formatting
The lint command is the primary tool for identifying typographical errors and style violations. It targets Markdown files and generates a detailed log file containing the audit results.
Core Review Rules
The system enforces a specific set of rules for Chinese and technical content:
- Spacing: Mandatory spaces between Chinese and English characters, and between Chinese characters and numbers.
- Punctuation: Full-width characters must be used for Chinese punctuation; numbers must use half-width characters.
- Indentation: Strict 4-space indentation for unordered/ordered lists (tabs are forbidden).
- Formulas: Formulas must be separated from surrounding text by empty lines.
- Structure: Only one H1 header is allowed per document, with a maximum depth of H3 for TOC generation.
Sources: REVIEW.md:40-52, AGENTS.md:58-65, scripts/review/SKILL.md:34-40
Automated Processing Tools
| Tool | Path | Description |
|---|---|---|
| Review Dispatcher | scripts/review/review.js | Main entry point for all review commands. |
| Lint Tool | scripts/review/lint.js | Scans files for formatting errors and outputs to .md.log. |
| Diff Viewer | scripts/review/diff.js | Reviews pending changes for potential typography issues before commit. |
| Frontmatter Gen | scripts/frontmatter/generate_frontmatter.js | Uses AI to generate SEO-optimized titles, tags, and summaries. |
Sources: scripts/review/review.js:10-15, AGENTS.md:46-56, scripts/frontmatter/generate_frontmatter.js:12-25
AI-Assisted Review Workflow
The project defines a multi-stage workflow for human or AI agents to ensure high-quality content integration, particularly when merging supplemental notes into the main documentation.
The Review Process
- Initial Lint: Execute
linton the target file and read the generated.logfile. - Manual/AI Correction: Repair errors identified in the log, ignoring intentional drafts or complex formatting.
- Content Audit: Read the full article to fix typos, grammatical errors, and logical fallacies (e.g., calculation errors).
- Verification: Re-run the
lintcommand to ensure corrections did not introduce new formatting violations.
Sources: REVIEW.md:12-23, scripts/review/SKILL.md:10-21, scripts/workflows/supplement-integration-v2.md:145-160
This sequence shows the iterative nature of the content review process. Sources: REVIEW.md:12-23, scripts/review/SKILL.md:10-21
Read and Analysis Skills
Supporting the review tools is a set of "Read Skills" used to analyze document structures before performing edits.
dir_h1.js: Scans thedocs/directory to list the primary H1 title of every file.file_headings.js: Extracts all headers (lines starting with#) along with their line numbers to visualize document hierarchy.file_prelimit.js: Previews the first 1000 characters of a file (excluding frontmatter) to verify metadata and compliance.file_split.js: Segments large files (20,000+ characters) into temporary.tmpchunks for easier processing by AI agents.
Sources: AGENTS.md:17-37, scripts/skills/read/SKILL.md:10-55
SEO and Metadata Enrichment
The generate_frontmatter.js script integrates with NVIDIA NIM API to provide expert-level metadata generation. It analyzes the document body and headings to produce a JSON object containing:
- Title: 20-25 character SEO-optimized title.
- Description: 100-200 character technical summary.
- Tags: 15-25 atomic tags covering disciplines, core terms, and application scenarios.
Sources: scripts/frontmatter/generate_frontmatter.js:125-160
Conclusion
The Content Review & Linting system provides a robust framework for maintaining the high standards of the whk blog. By combining strict programmatic linting with AI-driven metadata generation and a structured review workflow, the project ensures that its technical documentation remains professional, readable, and SEO-friendly.
Sources: README.md:145-155, scripts/workflows/supplement-integration-v2.md:215-230