@@ -1117,18 +1117,6 @@ Content
11171117 }
11181118}
11191119
1120- func TestWordCountWithAllCJKRunesWithoutHasCJKLanguage (t * testing.T ) {
1121- t .Parallel ()
1122- assertFunc := func (t * testing.T , ext string , pages page.Pages ) {
1123- p := pages [0 ]
1124- if p .WordCount () != 8 {
1125- t .Fatalf ("[%s] incorrect word count. expected %v, got %v" , ext , 8 , p .WordCount ())
1126- }
1127- }
1128-
1129- testAllMarkdownEnginesForPages (t , assertFunc , nil , simplePageWithAllCJKRunes )
1130- }
1131-
11321120func TestWordCountWithAllCJKRunesHasCJKLanguage (t * testing.T ) {
11331121 t .Parallel ()
11341122 settings := map [string ]any {"hasCJKLanguage" : true }
@@ -1161,18 +1149,38 @@ func TestWordCountWithMainEnglishWithCJKRunes(t *testing.T) {
11611149 testAllMarkdownEnginesForPages (t , assertFunc , settings , simplePageWithMainEnglishWithCJKRunes )
11621150}
11631151
1164- func TestWordCountWithIsCJKLanguageFalse (t * testing.T ) {
1152+ func TestReadingTimeCJKMixed (t * testing.T ) {
1153+ t .Parallel ()
1154+
1155+ simplePage := fmt .Sprintf (`---
1156+ title: Simple
1157+ ---
1158+
1159+ %s
1160+
1161+ %s
1162+
1163+ ` , strings .Repeat ("hello 你好 " , 2130 ), strings .Repeat ("好" , 750 ))
1164+ // 2130 * 2 + 750 = 10 * 501 -> 10 minutes of reading
1165+
1166+ assertFunc := func (t * testing.T , ext string , pages page.Pages ) {
1167+ p := pages [0 ]
1168+ if p .ReadingTime () != 20 {
1169+ t .Fatalf ("[%s] incorrect min read. expected %v, got %v" , ext , 20 , p .ReadingTime ())
1170+ }
1171+ }
1172+
1173+ testAllMarkdownEnginesForPages (t , assertFunc , nil , simplePage )
1174+ }
1175+
1176+ func TestSummaryWithIsCJKLanguageFalse (t * testing.T ) {
11651177 t .Parallel ()
11661178 settings := map [string ]any {
11671179 "hasCJKLanguage" : true ,
11681180 }
11691181
11701182 assertFunc := func (t * testing.T , ext string , pages page.Pages ) {
11711183 p := pages [0 ]
1172- if p .WordCount () != 75 {
1173- t .Fatalf ("[%s] incorrect word count for content '%s'. expected %v, got %v" , ext , p .Plain (), 74 , p .WordCount ())
1174- }
1175-
11761184 if p .Summary () != simplePageWithIsCJKLanguageFalseSummary {
11771185 t .Fatalf ("[%s] incorrect Summary for content '%s'. expected %v, got %v" , ext , p .Plain (),
11781186 simplePageWithIsCJKLanguageFalseSummary , p .Summary ())
@@ -1781,9 +1789,9 @@ Summary: In Chinese, 好 means good.
17811789 b .AssertFileContent ("public/p2/index.html" , "WordCount: 314\n FuzzyWordCount: 400\n ReadingTime: 2\n Len Plain: 1569\n Len PlainWords: 314\n Truncated: true\n Len Summary: 25\n Len Content: 1582" )
17821790
17831791 b .AssertFileContent ("public/p3/index.html" , "WordCount: 206\n FuzzyWordCount: 300\n ReadingTime: 1\n Len Plain: 638\n Len PlainWords: 7\n Truncated: true\n Len Summary: 43\n Len Content: 651" )
1784- b .AssertFileContent ("public/p4/index.html" , "WordCount: 7 \n FuzzyWordCount: 100 \n ReadingTime: 1\n Len Plain: 638\n Len PlainWords: 7\n Truncated: true\n Len Summary: 43\n Len Content: 651" )
1792+ b .AssertFileContent ("public/p4/index.html" , "WordCount: 206 \n FuzzyWordCount: 300 \n ReadingTime: 1\n Len Plain: 638\n Len PlainWords: 7\n Truncated: true\n Len Summary: 43\n Len Content: 651" )
17851793 b .AssertFileContent ("public/p5/index.html" , "WordCount: 206\n FuzzyWordCount: 300\n ReadingTime: 1\n Len Plain: 638\n Len PlainWords: 7\n Truncated: true\n Len Summary: 229\n Len Content: 652" )
1786- b .AssertFileContent ("public/p6/index.html" , "WordCount: 7 \n FuzzyWordCount: 100 \n ReadingTime: 1\n Len Plain: 638\n Len PlainWords: 7\n Truncated: false\n Len Summary: 637\n Len Content: 652" )
1794+ b .AssertFileContent ("public/p6/index.html" , "WordCount: 206 \n FuzzyWordCount: 300 \n ReadingTime: 1\n Len Plain: 638\n Len PlainWords: 7\n Truncated: false\n Len Summary: 637\n Len Content: 652" )
17871795}
17881796
17891797func TestScratch (t * testing.T ) {
0 commit comments