Markdown Processing Pipeline
Relevant source files
The following files were used as context for generating this wiki page:
The Markdown Processing Pipeline in the WHK project is a sophisticated system designed to transform raw Markdown notes into a highly optimized, SEO-friendly, and mathematically accurate static website. The pipeline integrates AI-assisted metadata generation, automated linting for typography, and server-side rendering for complex mathematical and chemical formulas.
The architecture transitions from an older MkDocs/Properdocs setup to a high-performance mkpandocs (Pandoc) system. It leverages a custom tech stack including KaTeX SSR for formula rendering and Puppeteer for high-quality PDF exports.
Sources: README.md:16-24, README.md:104-123
Pipeline Overview and Data Flow
The processing pipeline follows a multi-stage lifecycle: content creation, metadata enrichment, quality assurance (linting), and final build optimization.
The diagram shows the sequential flow from raw Markdown input to final distribution channels.
Sources: README.md:129-145, scripts/frontmatter/generate_frontmatter.js:15-30
Metadata Enrichment (Frontmatter)
Every Markdown document undergoes an AI-driven enrichment process. The system uses a dedicated script to generate YAML frontmatter that includes SEO-optimized titles, descriptions, and technical tags.
Key Components
- AI Model: Utilizes
nvidia/nemotron-3-nano-30b-a3bfor deep analysis. - Scanning Modes: Supports processing specific files, recent Git changes, or the entire directory.
- Atomic Tagging: Generates tags across five dimensions: Discipline, Core Term, Detail Term, Application Scenario, and Target Audience.
| Field | Requirement | Purpose |
|---|---|---|
title | 20-25 characters | SEO creativity and technical clarity |
description | 100-200 characters | Reveals technical route or mechanism |
summary | 50-100 characters | Used for card previews |
tags | 15-25 items | Multi-dimensional indexing |
Sources: scripts/frontmatter/generate_frontmatter.js:132-175, scripts/frontmatter/generate_frontmatter.js:180-195
AI Review and Typography Quality Control
To maintain professional academic standards, the pipeline includes a specialized review skill. This stage ensures that Markdown files adhere to strict Chinese-English mixed typesetting rules.
Linting Rules
The review.js tool executes a linting process that identifies and fixes common formatting issues:
- Spacing: Mandatory spaces between Chinese characters and English/numbers.
- Punctuation: Enforcement of full-width Chinese punctuation for text and half-width for numbers.
- Indentation: Strict 4-space indentation for lists and nested blocks.
- KaTeX Integrity: Prevention of Chinese characters inside math environments to ensure rendering stability.
Sources: scripts/review/SKILL.md:10-35, REVIEW.md:50-65, AGENTS.md:51-60
This sequence illustrates the iterative feedback loop used to ensure document quality before publication.
Sources: scripts/review/SKILL.md:10-25, REVIEW.md:20-35
Build and Post-Optimization Pipeline
Once the Markdown is converted to HTML, a secondary optimization pipeline (build.ts) processes the static assets to ensure maximum performance and SEO performance.
HTML Optimization Techniques
- Head Reordering: Sorts
<head>elements by priority (Charset > Viewport > Title > Meta > CSS > Scripts). - Deduplication: Automatically removes duplicate meta tags, canonical links, and structured data.
- Asset Minification: Deeply minifies HTML, CSS, and JS using PostCSS, Terser, and HTML-Minifier-Terser.
Formula Rendering
The project uses a custom katex-ssr plugin. While standard LaTeX is supported, the pipeline includes extensive compatibility definitions for chemical equations (mhchem) and academic shorthand.
| Macro | LaTeX Definition | Usage |
|---|---|---|
\ce | mhchem | Chemical formulas (e.g., $\ce{2H2 + O2}$) |
\pu | Physical Units | Standardized units (e.g., $\pu{1kg}$) |
\poly | \ce{-[ #1 ]_n-} | Organic chemistry polymers |
\vec | \bm | Bold notation for vectors |
Sources: build.ts:16-45, build.ts:169-234, scripts/template.serve.yml:32-75, README.md:104-110
Conclusion
The WHK Markdown Processing Pipeline is a specialized workflow tailored for technical and academic content. By combining AI for metadata generation, rigorous linting for typographical accuracy, and a multi-layered build optimization process, the system ensures that complex scientific notes are both accessible on the web and ready for high-quality professional distribution.
Sources: README.md:129-145, build.ts:545-565