canghe-format-markdown

Formats plain text or markdown files with frontmatter, titles, summaries, headings, bold, lists, and code blocks. Use when user asks to "format markdown", "beautify article", "add formatting", or improve article layout. Outputs to {filename}-formatted.md.

By freestylefly · 493 installs

npx skills add freestylefly/canghe-skills --skill canghe-format-markdown

Source repository · Upstream listing

Markdown Formatter Transforms plain text or markdown files into well structured markdown with proper frontmatter, formatting, and typography. Script Directory Scripts in scripts/ subdirectory. Replace ${SKILL DIR} with this SKILL.md's directory path. Script Purpose scripts/main.ts Main entry point with CLI options (uses remark cjk friendly for CJK emphasis) scripts/quotes.ts Replace ASCII quotes with fullwidth quotes scripts/autocorrect.ts Add CJK/English spacing via autocorrect Preferences (EXTEND.md) Use Bash to check EXTEND.md existence (priority order): ┌──────────────────────────────────────────────────────────┬───────────────────┐ │ Path │ Location │ ├──────────────────────────────────────────────────────────┼───────────────────┤ │ .canghe skills/canghe format markdown/EXTEND.md │ Project directory │ ├──────────────────────────────────────────────────────────┼───────────────────┤ │ $HOME/.canghe skills/canghe format markdown/EXTEND.md │ User home │ └──────────────────────────────────────────────────────────┴───────────────────┘ ┌───────────┬───────────────────────────────────────────────────────────────────────────┐ │ Result │ Action │ ├───────────┼───────────────────────────────────────────────────────────────────────────┤ │ Found │ Read, parse, apply settings │ ├───────────┼───────────────────────────────────────────────────────────────────────────┤ │ Not found │ Use defaults │ └───────────┴───────────────────────────────────────────────────────────────────────────┘ EXTEND.md Supports : Default formatting options Summary length preferences Usage Claude performs content analysis and formatting (Steps 1 6), then runs the script for typography fixes (Step 7). Workflow Step 1: Read Source File Read the user specified markdown or plain text file. Step 1.5: Detect Content Type & Confirm Content Type Detection: Indicator Classification Has YAML frontmatter Markdown Has , , headings Markdown Has bold , italic Markdown Has or 1. lists Markdown Has Detected existing markdown formatting. What would you like to do? 1. Optimize formatting (Recommended) Add/improve frontmatter, headings, bold, lists Run typography script (spacing, emphasis fixes) Output: {filename} formatted.md 2. Keep original formatting Preserve existing markdown structure Run typography script (spacing, emphasis fixes) Output: {filename} formatted.md 3. Typography fixes only Run typography script on original file in place No copy created, modifies original file directly Select a title: 1. [Title A] (Recommended) 2. [Title B] 3. [Title C] block bash Check if formatted file exists if [ f "{filename} formatted.md" ]; then Backup with timestamp mv "{filename} formatted.md" "{filename} formatted.backup $(date +%Y%m%d %H%M%S).md" fi bash npx y bun ${SKILL DIR}/scripts/main.ts {output file path} [options] bash Default: spacing + emphasis enabled, quotes disabled npx y bun ${SKILL DIR}/scripts/main.ts article.md Enable all features including quote replacement npx y bun ${SKILL DIR}/scripts/main.ts article.md quotes Only fix emphasis issues, skip spacing npx y bun ${SKILL DIR}/scripts/main.ts article.md no spacing Disable all processing except frontmatter formatting npx y bun ${SKILL DIR}/scripts/main.ts article.md no spacing no emphasis Formatting complete File: posts/2026/01/09/example/final formatted.md Changes: Added title: [title content] Added X bold markers Added X lists Added X code blocks This is plain text. First point is efficiency improvement. Second point is cost reduction. Third point is experience optimization. Use npm install to install dependencies. markdown title: Three Core Advantages slug: three core advantages summary: Discover the three key benefits that drive success in modern projects. This is plain text. Main advantages: Efficiency improvement Cost reduction Experience optimization Use npm install to install dependencies. Notes Preserve original writing style and tone Specify correct language for code blocks (e.g., python , javascript ) Maintain CJK/English spacing standards Do not add content not present in original Extension Support Custom configurations via EXTEND.md. See Preferences section for paths and supported options.