Merge pull request #28128 from overleaf/mj-client-word-count-magic-comments
[web] Support some texcount magic comments in client side word count GitOrigin-RevId: 12749876edbf7940ca9adfc63fcc7e787894e727
This commit is contained in:
committed by
Copybot
parent
1625cc7848
commit
8282aa85f2
+29
-1
@@ -5,7 +5,7 @@ import { WordCountData } from '@/features/word-count-modal/components/word-count
|
||||
import { createSegmenters } from '@/features/word-count-modal/utils/segmenters'
|
||||
import { expect } from 'chai'
|
||||
|
||||
describe('word count', function () {
|
||||
describe('word-count', function () {
|
||||
beforeEach(async function () {
|
||||
this.data = {
|
||||
encode: '',
|
||||
@@ -35,6 +35,10 @@ describe('word count', function () {
|
||||
path.join(__dirname, 'word-count.tex'),
|
||||
'utf-8'
|
||||
),
|
||||
'word-count-with-ignored-sections.tex': await readFile(
|
||||
path.join(__dirname, 'word-count-with-ignored-sections.tex'),
|
||||
'utf-8'
|
||||
),
|
||||
}
|
||||
|
||||
this.projectSnapshot = {
|
||||
@@ -69,4 +73,28 @@ describe('word count', function () {
|
||||
textWords: 42,
|
||||
})
|
||||
})
|
||||
|
||||
it('skips ignored sections', function () {
|
||||
countWordsInFile(
|
||||
this.data,
|
||||
this.projectSnapshot,
|
||||
'word-count-with-ignored-sections.tex',
|
||||
this.segmenters
|
||||
)
|
||||
|
||||
expect(this.data).to.deep.include({
|
||||
abstractCharacters: 0,
|
||||
abstractWords: 0,
|
||||
captionCharacters: 0,
|
||||
captionWords: 0,
|
||||
footnoteCharacters: 0,
|
||||
footnoteWords: 0,
|
||||
headCharacters: 0,
|
||||
headWords: 0,
|
||||
otherCharacters: 0,
|
||||
otherWords: 0,
|
||||
textCharacters: 10,
|
||||
textWords: 3,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
foo
|
||||
%TC:ignore
|
||||
bar
|
||||
%TC:endignore
|
||||
baz
|
||||
%TC: ignore
|
||||
qux
|
||||
%%TC: endignore
|
||||
quux
|
||||
Reference in New Issue
Block a user