Fix/324 apostrophe word count - #338
Open
b-camphart wants to merge 3 commits into
Open
Conversation
added 3 commits
July 6, 2026 10:25
- Export countWords function for testability - Add comprehensive test suite for current countWords behavior - Add vitest config alias for obsidian module (test-only) - Add obsidian module stub for test resolution All 20 baseline tests pass.
Markdown's '> ' replacement strips '>' from '-->', breaking HTML comment removal. Swap the blocks so comments are removed before markdown syntax is stripped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two bugs in the countWords function:
1. Apostrophes split contractions into multiple words
Words like
can't,don't,it's,o'clockwere counted as 2 words because'was not in theWORD_COUNT_REGEXcharacter class. The regex only matched[\-A-Za-z\u00AA...], socan'ttokenized ascan+t.fix #324
2. HTML comments not fully stripped when both flags active
With the default
removeMarkdown=true, removeComments=true, the markdown syntax regex ran first. Its>pattern stripped the>from-->(the HTML comment closing tag), soHello <!-- comment --> worldbecameHello <!-- comment -- world. The HTML comment regex then couldn't find-->and left fragments behind.Fix: Swapped the execution order so comments (
<!--...-->,%%...%%) are removed before markdown syntax is stripped. This prevents>from interfering with HTML comment delimiters.Testing