@@ -149,7 +149,8 @@ const LINE_PREFIX = /^\s*(?:(?:[-*+>]|\d+[.)]|#{1,6})\s+)*(?:\w+:\s*["'])?/
149149const SIM_NAME = / \b S i m \b /
150150/** Words that turn a sentence toward another product: "while Zapier lists ...", "unlike Zapier". */
151151const CONTRAST = String . raw `(?:while|whereas|but|unlike|compared (?:with|to)|versus|vs\.?)`
152- const SENTENCE_END = / (?< = [ . ! ? ; ] ) \s + /
152+ /** Sentence punctuation, with any closing quote or bracket, before whitespace. */
153+ const SENTENCE_END = / (?< = [ . ! ? ; ] [ ' " ” ’ ) \] ] * ) \s + /
153154/**
154155 * Where a comparison clause starts: a contrast word, or "like" when it opens the sentence or
155156 * follows a comma ("Like Sim, ...", "Zapier, like Sim, ..."), but not "tools like Slack".
@@ -159,10 +160,13 @@ const COMPARISON_START = new RegExp(
159160 'i'
160161)
161162/**
162- * Where a comparison clause ends: the first comma that is neither a thousands separator nor the
163- * start of a relative clause continuing it ("unlike Zapier, which has 9,000+ integrations").
163+ * Where a comparison clause ends: the first comma that is not a thousands separator, not the
164+ * start of a relative clause continuing it ("unlike Zapier, which has 9,000+ integrations"), and
165+ * not the next item in a list of counts ("280+ integrations, 9,000+ actions, and 530+ triggers").
164166 */
165- const COMPARISON_END = / , (? ! \d ) (? ! \s * (?: w h i c h | t h a t | w h o ) \b ) /
167+ const COMPARISON_END = / , (? ! \d ) (? ! \s * (?: w h i c h | t h a t | w h o ) \b ) (? ! \s * (?: a n d \s + ) ? \d ) /
168+ /** A contrast inside a comparison clause, which starts a clause of its own ("..., but Zapier"). */
169+ const INNER_CONTRAST = new RegExp ( String . raw `,?\s+(?=${ CONTRAST } \b)` , 'i' )
166170/** The product whose possessive directly precedes a count, as in "Zapier's 9,000+". */
167171const POSSESSIVE_OWNER = / ( [ \w . - ] + ) [ ' ’ ] s \s * $ /
168172/** A Sim count below this share of the catalog total is left from an older catalog. */
@@ -188,7 +192,7 @@ function sentenceClauses(sentence: string): string[] {
188192 main . push ( rest . slice ( 0 , start . index ) )
189193 const comparison = rest . slice ( start . index + start [ 0 ] . length )
190194 const end = COMPARISON_END . exec ( comparison )
191- comparisons . push ( end ? comparison . slice ( 0 , end . index ) : comparison )
195+ comparisons . push ( ... ( end ? comparison . slice ( 0 , end . index ) : comparison ) . split ( INNER_CONTRAST ) )
192196 rest = end ? comparison . slice ( end . index + 1 ) : ''
193197 }
194198 return [ [ ...main , rest ] . join ( ' ' ) , ...comparisons ]
0 commit comments