@@ -131,10 +131,13 @@ const TRAILING_PUNCTUATION = /[.,;:!]+$/
131131const LINK_TARGET_OPENER = / (?: \] \( \s * | h r e f = \{ ? [ " ' ` ] ) $ /
132132const MARKDOWN_LINK = / \[ [ ^ \] \n ] * \] \( [ ^ ) \n ] * \) /
133133const FAQ_HEADING = / ^ # { 1 , 6 } \s + F A Q s ? \s * : ? \s * $ / i
134- const CODE_FENCE = / ^ \s * ( ` ` ` | ~ ~ ~ ) /
134+ /** An opening or closing code fence: three or more backticks or tildes. */
135+ const CODE_FENCE = / ^ \s * ( ` { 3 , } | ~ { 3 , } ) /
135136const ROUTE_FILES = [ 'page.tsx' , 'page.ts' , 'route.tsx' , 'route.ts' ]
136137/** A catalog count such as "1,000+ integrations": group 1 is the number, group 2 the unit. */
137- const COUNT_CLAIM = / \b ( \d { 1 , 3 } (?: , \d { 3 } ) + | \d + ) \+ ? \s + ( i n t e g r a t i o n s | a c t i o n s | t r i g g e r s ) \b / g
138+ const COUNT_CLAIM = / \b ( \d { 1 , 3 } (?: , \d { 3 } ) + | \d + ) \+ ? \s + ( i n t e g r a t i o n s | a c t i o n s | t r i g g e r s ) \b / gi
139+ /** Inline emphasis and code markers, which would otherwise split "**1,000+** integrations". */
140+ const INLINE_MARKERS = / \* \* | _ _ | [ * ` ] / g
138141const SIM_NAME = / \b S i m \b / g
139142const SIM_CLAIM_MAX_WORDS = 12
140143/** A Sim count below this share of the catalog total is left from an older catalog. */
@@ -144,8 +147,9 @@ const SIM_COUNT_FLOOR = 0.9
144147 * The counts on one line of text that belong to Sim, with the claim as written. A sentence or
145148 * clause that moves on to another product starts with a capitalized word, which ends Sim's claim.
146149 */
147- function simCountClaims ( text : string ) : { claim : string ; count : number ; unit : SimCountUnit } [ ] {
150+ function simCountClaims ( line : string ) : { claim : string ; count : number ; unit : SimCountUnit } [ ] {
148151 const claims : { claim : string ; count : number ; unit : SimCountUnit } [ ] = [ ]
152+ const text = line . replace ( INLINE_MARKERS , '' )
149153 for ( const match of text . matchAll ( COUNT_CLAIM ) ) {
150154 const before = text . slice ( 0 , match . index )
151155 const lastSim = [ ...before . matchAll ( SIM_NAME ) ] . at ( - 1 )
@@ -159,7 +163,7 @@ function simCountClaims(text: string): { claim: string; count: number; unit: Sim
159163 claims . push ( {
160164 claim : match [ 0 ] ,
161165 count : Number . parseInt ( match [ 1 ] . replaceAll ( ',' , '' ) , 10 ) ,
162- unit : match [ 2 ] as SimCountUnit ,
166+ unit : match [ 2 ] . toLowerCase ( ) as SimCountUnit ,
163167 } )
164168 }
165169 return claims
@@ -598,7 +602,7 @@ export async function checkPost(
598602 const fenceMatch = CODE_FENCE . exec ( text )
599603 if ( fenceMatch ) {
600604 if ( fence === null ) fence = fenceMatch [ 1 ]
601- else if ( fenceMatch [ 1 ] === fence ) fence = null
605+ else if ( fenceMatch [ 1 ] [ 0 ] === fence [ 0 ] && fenceMatch [ 1 ] . length >= fence . length ) fence = null
602606 return
603607 }
604608 if ( fence !== null ) return
0 commit comments