Skip to content

fix: Count only readable words in post reading time - #235

Merged
HazAT merged 2 commits into
mainfrom
awad/reading-time-text-only
Oct 23, 2026
Merged

HazAT merged 2 commits into
mainfrom
awad/reading-time-text-only

Conversation

@logaretm

@logaretm logaretm commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Reading time counted raw markdown characters, so inline SVG diagrams and long URLs inflated it. Noticed it while drafting a vanguard post that got up to 50 minutes of reading time.

I added tests showing a huge inline SVG and long image/link URLs don't change the estimate, plus the minute and hour formatting.

@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
vanguard Ready Ready Preview Oct 23, 2026 9:11am UTC

Request Review

@logaretm
logaretm requested a review from HazAT October 22, 2026 18:46
@logaretm
logaretm marked this pull request as ready for review October 22, 2026 18:47

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4ce28cb. Configure here.

Comment thread app/lib/reading-time.ts Outdated
Stripping <svg>/<script>/comment blocks with regex on raw markdown paired
an opener with the next closer anywhere in the post, so tags mentioned in
code spans or fences dropped the words in between. Render with marked and
take the sanitized text content instead, mirroring summarize().

Co-Authored-By: Daniel Griesser <dgriesser@sentry.io>
@HazAT
HazAT merged commit 13ee284 into main Oct 23, 2026
15 checks passed
@HazAT
HazAT deleted the awad/reading-time-text-only branch October 23, 2026 09:12

This branch was successfully deployed

1 active deployment
Preview — 98bdef78 Deployed Oct 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants