fix: exclude title heading and wikilinks from word count

countWords() was including the title line (# Heading) in the count,
inflating it by ~2-3 words. Now strips the first H1 heading and
[[wikilinks]] before counting, so only body prose is tallied.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
lucaronin
2026-02-24 23:40:08 +01:00
parent b5eb7e4098
commit f7c4e16be9
3 changed files with 44 additions and 11 deletions

View File

@@ -129,10 +129,10 @@ describe('Inspector', () => {
expect(pill).toHaveStyle({ borderRadius: '16px' })
})
it('computes word count from content minus frontmatter', () => {
it('computes word count from content minus frontmatter and title', () => {
render(<Inspector {...defaultProps} entry={mockEntry} content={mockContent} />)
// "Test Project" (# stripped) + "This is a test note with some words to count." = 12 words
expect(screen.getByText('12')).toBeInTheDocument()
// Title "# Test Project" excluded; body: "This is a test note with some words to count." = 10 words
expect(screen.getByText('10')).toBeInTheDocument()
})
it('shows "Add property" button as disabled placeholder', () => {