Skip to content

Commit 4ec0132

Browse files
committed
fix(library): match bold and title-cased sim counts, and track code fences by length
1 parent eda076e commit 4ec0132

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎scripts/check-library-content.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ describe('check-library-content', () => {
328328
],
329329
['Sim ships 9,000+ actions across its catalog.', '9,000+ actions', 'overstates'],
330330
['Sim listens for events with 300+ triggers.', '300+ triggers', 'stale'],
331+
['Sim has **1,000+** integrations.', '1,000+ integrations', 'overstates'],
332+
['Sim has 1,000+ Integrations.', '1,000+ Integrations', 'overstates'],
331333
])('rejects a Sim count the catalog does not support: %s', async (body, claim, verdict) => {
332334
writePost('library', 'post', body)
333335
expect(await findingsFor('library', 'post')).toEqual([
@@ -361,6 +363,7 @@ describe('check-library-content', () => {
361363
'Sim is open source. Workato cites 14,000+ integrations.',
362364
'Sim can call any tool that the connector marketplaces built on open protocols expose, often 1,000+ integrations.',
363365
'```text\nSim has 1,000+ integrations\n```',
366+
'````md\n```text\nSim has 1,000+ integrations\n````',
364367
].join('\n\n')
365368
)
366369
expect(await findingsFor('library', 'post')).toEqual([])

‎scripts/check-library-content.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,13 @@ const TRAILING_PUNCTUATION = /[.,;:!]+$/
131131
const LINK_TARGET_OPENER = /(?:\]\(\s*|href=\{?["'`])$/
132132
const MARKDOWN_LINK = /\[[^\]\n]*\]\([^)\n]*\)/
133133
const FAQ_HEADING = /^#{1,6}\s+FAQs?\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,})/
135136
const 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+(integrations|actions|triggers)\b/g
138+
const COUNT_CLAIM = /\b(\d{1,3}(?:,\d{3})+|\d+)\+?\s+(integrations|actions|triggers)\b/gi
139+
/** Inline emphasis and code markers, which would otherwise split "**1,000+** integrations". */
140+
const INLINE_MARKERS = /\*\*|__|[*`]/g
138141
const SIM_NAME = /\bSim\b/g
139142
const 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

Comments
 (0)