Analyze & Extract from Markdown: Word Counts, Excerpts & Slugs (2026)
A tutorial on pulling insight out of Markdown — accurate word and readability counts, clean plain-text excerpts for meta descriptions, and GitHub-compatible heading slugs for anchors and TOCs.
Markdown isn't just for writing — it's structured data you can measure and mine. This tutorial covers the analyze & extract tool group: counting words and readability with the word counter, generating clean excerpts with Markdown to plain text, and producing GitHub-compatible anchors with the slug generator.
These three jobs power editorial workflows, SEO, and in-page navigation — and each maps to an API endpoint for automation.
The three jobs
| Job | Tool | Used for |
|---|---|---|
| Measure | Word counter | Editorial limits, readability |
| Excerpt | Markdown to plain text | Meta descriptions, previews |
| Anchor | Slug generator | TOCs, deep links |
Part 1: Counting words and readability
The word counter gives instant counts for words, characters, headings, links, and images — plus a readability score and a copy-paste summary for editors.
Why Markdown-aware counting matters
A naive word count includes syntax noise — **, [](), fence markers, table pipes. The word counter understands Markdown, so it counts the prose, not the punctuation. That makes it accurate for:
- Editorial limits — "keep it under 1,200 words."
- Readability targets — grade level and sentence length.
- Content audits — heading/link/image density across a piece.
For a Medium-style "X min read" badge, the dedicated reading time estimator adds per-image and per-code-line weights — see the author & publish tutorial.
Part 2: Clean excerpts for SEO
A meta description should be plain prose — no #, no **, no link syntax. The Markdown to plain text tool strips all formatting and collapses the document into a single clean paragraph, perfect for:
- Meta descriptions (aim for ~150–160 characters).
- Social card text (Open Graph / Twitter descriptions).
- Email previews and newsletter snippets.
- Search result snippets in your own app.
Workflow
- Paste your intro (or whole post) into Markdown to plain text.
- Take the first ~155 characters as your meta description.
- Trim to a complete sentence.
This is the exact step recommended in the WordPress, Medium, and Substack publishing guides.
Part 3: Heading slugs and anchors
The slug generator reads your Markdown and produces GitHub-compatible slug IDs for every heading, plus a ready-to-paste nested table of contents.
Why slugs matter
Every heading on GitHub (and most static site generators) gets an auto-generated ID so you can deep-link to it:
https://example.com/docs#installation-steps
The slug generator shows you exactly what those IDs will be — essential when:
- Building a manual TOC with working anchors.
- Cross-linking between sections or documents.
- Avoiding broken
#anchorlinks.
Collision check
When you merge documents or build a single-page site, duplicate headings produce duplicate slugs (GitHub appends -1, -2). The slug collision simulator shows where IDs would clash across files before you ship broken links.
A real editorial workflow
Publishing a post end to end:
- Write in the editor.
- Measure with the word counter — hit your length and readability targets.
- Excerpt with Markdown to plain text — generate the meta description.
- Anchor with the slug generator — build the TOC and verify deep links.
- Verify anchors resolve with the link checker.
Automating analysis
Every step maps to an endpoint for content pipelines:
| Job | Endpoint |
|---|---|
| Counts & stats | /api/v1/analyze |
| Plain-text excerpt | /api/v1/convert/markdown-to-text |
| Heading slugs | /api/v1/generate/slugs |
| Reading time | /api/v1/reading-time |
| Outline | /api/v1/extract/outline |
Example — auto-generate a meta description at build time:
curl -sf -X POST https://trymarkdownviewer.com/api/v1/convert/markdown-to-text \
-H "Authorization: Bearer $MDV_API_KEY" \
-H "Content-Type: application/json" \
-d "$(jq -Rs '{markdown: .}' < post.md)"
Common mistakes
1. Counting syntax as words. Use a Markdown-aware counter, not a raw character count.
2. Meta descriptions with Markdown in them. Strip formatting first — **bold** in a <meta> tag is broken.
3. Guessing slugs. Generate them; GitHub's slug rules (lowercase, hyphens, stripped punctuation) are easy to get wrong by hand.
4. Ignoring slug collisions. Merged docs create duplicate IDs and broken anchors — check first.
5. One excerpt for everything. Tune length per channel (meta ~155 chars, social shorter).
Related articles
- Format & clean up tutorial — the cleanup step
- Author & publish tutorial — TOCs and reading time
- Markdown links guide — anchor link syntax
- Audit & quality tutorial — verifying links and images
- Edit & preview tutorial
Quick reference
| Need | Tool / endpoint |
|---|---|
| Word/readability count | word counter · /analyze |
| Meta description | plain text |
| Heading slugs/TOC | slug generator |
| Collision check | slug collision |
Treat your Markdown as data: measure it, excerpt it, and index it. The analyze & extract tools turn a document into word counts, clean snippets, and working anchors — by hand for one post, or via API for a whole content pipeline.
Written by Markdown Viewer Team. Found this useful? Try the editor →
Keep reading
Hand-picked articles related to this one.
A tutorial on bridging Markdown to and from other markup formats — Atlassian Confluence/Jira wiki markup, forum BBCode, AsciiDoc, and reStructuredText — with migration tips and gotchas.
A tutorial on Markdown as a data format — convert JSON to tables or lists, sort and transpose tables, extract every code block as a file, and track task-list progress for content pipelines.
A tutorial on adding diagrams and equations to Markdown using ready-made libraries — browse and copy Mermaid templates and KaTeX/LaTeX equations, then validate them before you commit.