Skip to content
Automation
Skill

/markdown-unwrap

Unwraps hard-wrapped markdown files so that each sentence ends with a newline instead of mid-sentence line breaks. Joins continuation lines within a paragraph into single lines, then re-breaks at sentence boundaries (period, question mark, exclamation point). Preserves blank

From plugin
auto-empirical-research-skills
4.9k200 skills

Claude Code

$ npx -y skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill markdown-unwrap --agent claude-code

SKILL.md

markdown-unwrap.SKILL.md
name: markdown-unwrap
description: 'Unwraps hard-wrapped markdown files so that each sentence ends with a newline instead of mid-sentence line breaks. Joins continuation lines within a paragraph into single lines, then re-breaks at sentence boundaries (period, question mark, exclamation point). Preserves blank lines, headings, fenced code blocks, block quotes, and list items. Use when asked to unwrap text, fix line breaks, reflow sentences, or clean up hard-wrapped markdown or .qmd files.'
metadata:
  author: Christopher T. Kenny
  version: 1.0

Markdown Unwrap

Reflow a markdown (or `.qmd`) file so that each **sentence** occupies its own line. This is the inverse of hard-wrapping: mid-sentence newlines are removed and the text is re-broken only at sentence endings.

Input Arguments

| Position | Required | Description | |----------|----------|-------------| | 1 | **Yes** | Path to the input `.md` or `.qmd` file | | 2 | No | Output path. Defaults to overwriting the input file in-place |

**Example invocations:**

/markdown-unwrap paper/paper.qmd
/markdown-unwrap README.md README-unwrapped.md

Algorithm

Process the file line-by-line, maintaining a **current paragraph buffer**:

1. **Pass-through lines** — output immediately, do not buffer:

  • Blank lines (flush the buffer first, then emit the blank line)
  • ATX headings (`#`, `##`, …)
  • Fenced code block delimiters (` ``` ` or `~~~`); toggle a *in-code-block* flag and pass all lines through until the closing fence
  • Block-quote lines starting with `>`
  • List item lines starting with `-`, `*`, `+`, or a digit followed by `.`/`)`
  • YAML front-matter delimiters `---` / `...` (pass the entire front-matter block through unchanged)

2. **Buffering** — for all other lines, append the line's text to the current buffer (joining with a single space, trimming leading/trailing whitespace from each line).

3. **Flushing** — when a pass-through line (or end-of-file) is encountered, flush the buffer:

  • Split the accumulated text into sentences at `(?<=[.!?])\s+` — i.e., after a sentence-ending punctuation mark followed by whitespace.
  • Emit each sentence on its own line.
  • Clear the buffer.

4. Write the result to the output path (or overwrite the input if no output path was given).

What Is Preserved

  • Blank lines (paragraph separators)
  • Fenced code blocks (contents unchanged)
  • YAML front matter
  • Headings, list items, and block quotes (each kept on its own line)
  • All text content — only whitespace between words is affected

What Changes

  • Mid-sentence hard-wrap newlines are removed
  • Each sentence ends with exactly one newline
  • Trailing spaces within paragraphs are removed

Implementation Notes

Implement the algorithm directly in your response — read the file, process it line-by-line following the rules above, and write the result. No external script is needed.

The sentence-split heuristic: a period followed by whitespace and an uppercase letter is a sentence boundary **unless** the word immediately before the period is a known abbreviation. Maintain a blocklist of common abbreviations that should never trigger a split:

  • Titles: `Mr`, `Mrs`, `Ms`, `Dr`, `Prof`, `Sr`, `Jr`, `Rev`, `Gov`
  • Latin: `e.g`, `i.e`, `et al`, `vs`, `etc`
  • Academic: `Fig`, `Eq`, `Sec`, `Ch`, `Vol`, `No`, `pp`

When the token before the period matches one of these (case-insensitively), do not split. For `?` and `!` there is no abbreviation concern — always split.

Read more
@brycewang-stanford
Ships withauto-empirical-research-skills

## 🔥 力荐 · StatsPAI — Stata 与 R 的 Python 平替,为 AI Agent 而生 🔁 Stata / R 平替:reghdfe、csdid、rdrobust、synth、fixest、did 等常用命令在 Python 中一站式替代,一个 import statspai as sp 搞定 DID / RD / IV / SCM / DML / matching 🤖 面向 Agent 设计:结构化结果对象 + 内置 MCP Server,Claude / Codex

4.9k200 skills
Get the whole plugin

Stars on GitHub

Momentum

stars in total
4.9k
Star history of brycewang-stanford/Auto-Empirical-Research-Skills on GitHub, a chart by star-history.com

More skills from other plugins.

agent-builder

agent-builder

Load immediately after an Agent intent, before the first agent_builder_* call. Governs how you create, configure, test, and…

n8n12d209k
@n8n-io@n8n-ioInstall Skill
browser-use

browser-use

Direct browser control via CDP for web interaction: automation, scraping, testing, screenshots, and site/app work. Also covers…

@browser-use@browser-useInstall Skill
agent-browser

agent-browser

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling…

@vercel-labs-2@vercel-labs-2Install Skill
add-anydoc

add-anydoc

Add local office-document-to-Markdown conversion to NanoClaw agent containers with the pinned Firecrawl AnyDoc CLI. Use when…

@nanocoai@nanocoaiInstall Skill

Questions about markdown-unwrap.

Which coding agents can use markdown-unwrap?
markdown-unwrap installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.