Markdown unwrap

From brycewang-stanford/Auto-Empirical-Research-Skills · View interactive version

Markdown unwrap is an AI agent skill from the GitHub repository brycewang-stanford/Auto-Empirical-Research-Skills. 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

How to use this skill

Skill file

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:
  1. 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).
  1. Flushing — when a pass-through line (or end-of-file) is encountered, flush the buffer:
  1. Write the result to the output path (or overwrite the input if no output path was given).

What Is Preserved

What Changes

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:

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

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.