Skip to content
All posts
4 min read
markdown
tutorial
analyze
seo
extract

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

JobToolUsed for
MeasureWord counterEditorial limits, readability
ExcerptMarkdown to plain textMeta descriptions, previews
AnchorSlug generatorTOCs, 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

  1. Paste your intro (or whole post) into Markdown to plain text.
  2. Take the first ~155 characters as your meta description.
  3. 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 #anchor links.

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:

  1. Write in the editor.
  2. Measure with the word counter — hit your length and readability targets.
  3. Excerpt with Markdown to plain text — generate the meta description.
  4. Anchor with the slug generator — build the TOC and verify deep links.
  5. Verify anchors resolve with the link checker.

Automating analysis

Every step maps to an endpoint for content pipelines:

JobEndpoint
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).

Quick reference

NeedTool / endpoint
Word/readability countword counter · /analyze
Meta descriptionplain text
Heading slugs/TOCslug generator
Collision checkslug 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.