cameron / squirt

Speed read the web.
http://www.squirt.io
Apache License 2.0
1.22k stars 206 forks source link

Pause with decimal numbers, thousand separators etc. #122

Closed rsbondi closed 6 years ago

rsbondi commented 10 years ago

26.2 is read [26. - pause - 2], it would be better imo to preserve it as a word. Same with 1,000,000 as a single word with no pause.

the following appears to give the pauses

.replace(/[\,\.\!\:\;](?![\"\'\)\]\}])/g, "$& ") 

I am not sure I understand the intention of the lookahead but

.replace(/[\,\.\!\:\;](?![\"\'\)\]\}])[\s\n]/g, "$& ") 

would only pause when followed by whitespace or newline, which better represents a pause point.

dsernst commented 10 years ago

I agree with your premise: it would improve readability to preserve numbers with comma or decimal separators.

It seems the lookahead is intended to condition against inserting a pause when the punctuation is followed by ", ', ), ], or }, such as at the end of a quotation or parenthetical phrase.

And \n may be redundant in that character class, because \s includes  , \t, \r, and \n.

dsernst commented 10 years ago

And perhaps #43 would fix this. :smiley: