@wix/web5-core 1.63.31 → 1.63.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/cjs/component/componentDefinitions/ComparisonSectionDefinition.js +20 -3
  2. package/dist/cjs/component/componentDefinitions/ComparisonSectionDefinition.js.map +1 -1
  3. package/dist/cjs/component/componentDefinitions/FeatureCardsSectionDefinition.js +13 -2
  4. package/dist/cjs/component/componentDefinitions/FeatureCardsSectionDefinition.js.map +1 -1
  5. package/dist/cjs/component/componentDefinitions/HeroSectionDefinition.js +6 -2
  6. package/dist/cjs/component/componentDefinitions/HeroSectionDefinition.js.map +1 -1
  7. package/dist/cjs/component/componentDefinitions/NextStepsSectionDefinition.js +17 -2
  8. package/dist/cjs/component/componentDefinitions/NextStepsSectionDefinition.js.map +1 -1
  9. package/dist/cjs/component/componentDefinitions/parse-utils.js +61 -18
  10. package/dist/cjs/component/componentDefinitions/parse-utils.js.map +1 -1
  11. package/dist/esm/component/componentDefinitions/ComparisonSectionDefinition.js +20 -3
  12. package/dist/esm/component/componentDefinitions/ComparisonSectionDefinition.js.map +1 -1
  13. package/dist/esm/component/componentDefinitions/FeatureCardsSectionDefinition.js +14 -3
  14. package/dist/esm/component/componentDefinitions/FeatureCardsSectionDefinition.js.map +1 -1
  15. package/dist/esm/component/componentDefinitions/HeroSectionDefinition.js +8 -4
  16. package/dist/esm/component/componentDefinitions/HeroSectionDefinition.js.map +1 -1
  17. package/dist/esm/component/componentDefinitions/NextStepsSectionDefinition.js +17 -2
  18. package/dist/esm/component/componentDefinitions/NextStepsSectionDefinition.js.map +1 -1
  19. package/dist/esm/component/componentDefinitions/parse-utils.js +60 -18
  20. package/dist/esm/component/componentDefinitions/parse-utils.js.map +1 -1
  21. package/dist/types/component/componentDefinitions/ComparisonSectionDefinition.d.ts.map +1 -1
  22. package/dist/types/component/componentDefinitions/FeatureCardsSectionDefinition.d.ts.map +1 -1
  23. package/dist/types/component/componentDefinitions/HeroSectionDefinition.d.ts.map +1 -1
  24. package/dist/types/component/componentDefinitions/NextStepsSectionDefinition.d.ts.map +1 -1
  25. package/dist/types/component/componentDefinitions/parse-utils.d.ts +41 -17
  26. package/dist/types/component/componentDefinitions/parse-utils.d.ts.map +1 -1
  27. package/package.json +2 -2
@@ -25,7 +25,21 @@ function isBlankCell(raw) {
25
25
  class ComparisonSectionDefinition {
26
26
  constructor() {
27
27
  (0, _defineProperty2.default)(this, "sectionType", 'comparison');
28
- (0, _defineProperty2.default)(this, "patterns", ['html_comment[section^="comparison"] > (h2 | h3 | h4 | t) > html_comment? > t* > table > (t | link)?']);
28
+ // The pre-table slot is the description paragraph, so it has to admit
29
+ // `link`: `convertToBlockElements` unwraps a paragraph into its inline
30
+ // nodes, so `Questions? Email support@shop.example for help.` arrives as
31
+ // `t link t` — GFM autolinks a bare email, no author required — and an
32
+ // authored `[men's shoes](web5://ask/…)` does the same. With `t*` the run
33
+ // ended at that `link`, the whole pattern failed, and the section never
34
+ // reached `parse()`: the heading and prose were claimed by `textBlock` and
35
+ // the TABLE fell to `FallbackSectionDefinition`, whose `partsToMarkdown`
36
+ // has no `table` branch — so it rendered as an empty section and the
37
+ // comparison silently vanished.
38
+ //
39
+ // The trailing slot stays `(t | link)?`: it is the CTA, and `parse()` reads
40
+ // it positionally (see `ctaText` below). Widening it would let the section
41
+ // swallow a paragraph belonging to whatever follows.
42
+ (0, _defineProperty2.default)(this, "patterns", ['html_comment[section^="comparison"] > (h2 | h3 | h4 | t) > html_comment? > (t | link)* > table > (t | link)?']);
29
43
  (0, _defineProperty2.default)(this, "defaults", {
30
44
  title: 'Comparison',
31
45
  columnLabels: ['Option A', 'Option B'],
@@ -133,8 +147,11 @@ See how our platform stacks up against the competition.
133
147
  }));
134
148
  }
135
149
 
136
- // Extract CTA from link parts
137
- const link = (0, _parseUtils.firstLink)(parts);
150
+ // The CTA is the link AFTER the table, not merely the first link in the
151
+ // section the description may now carry its own inline links, and
152
+ // `firstLink(parts)` would promote one of those to the CTA button.
153
+ const lastTableIndex = parts.map(p => p.type).lastIndexOf('table');
154
+ const link = (0, _parseUtils.firstLink)(lastTableIndex >= 0 ? parts.slice(lastTableIndex + 1) : parts);
138
155
  const ctaText = (link == null ? void 0 : link.text) || undefined;
139
156
  const ctaHref = (link == null ? void 0 : link.href) || undefined;
140
157
 
@@ -1 +1 @@
1
- {"version":3,"names":["_parseUtils","require","_parts","_sectionDefinition","_diagnosticTypes","isBlankCell","raw","v","trim","toLowerCase","test","ComparisonSectionDefinition","constructor","_defineProperty2","default","title","columnLabels","rows","feature","values","markdown","expected","featureColumnLabel","description","ctaText","ctaHref","parse","parts","context","_tableParts$","headingText","proseBodyMarkdown","undefined","tableParts","getPartsByType","tableMeta","meta","columns","rawValueRows","map","row","iconHint","parseTableValue","allHeaders","headers","rawRows","slice","label","link","firstLink","text","href","keptRow","some","filteredRows","filter","_","i","filteredRawRows","droppedCount","length","reportDiagnostic","DIAGNOSTIC_TYPES","ITEMS_DROPPED","blankColumns","col","every","SECTION_REJECTED","c","join","DROP_SECTION","exports"],"sources":["../../../../src/component/componentDefinitions/ComparisonSectionDefinition.ts"],"sourcesContent":["import {\n headingText,\n proseBodyMarkdown,\n firstLink,\n parseTableValue,\n} from './parse-utils';\nimport { getPartsByType, type Part } from '../../parts/parts';\nimport type {\n ComparisonColumn,\n ComparisonCompProps,\n ComparisonRow,\n ComparisonSectionComponent,\n SectionFixture,\n} from '../types';\nimport type {\n SectionDefinition,\n ParseContext,\n DropSection,\n} from '../section-definition';\nimport { DROP_SECTION } from '../section-definition';\nimport { DIAGNOSTIC_TYPES } from '../diagnosticTypes';\n\n/**\n * A cell the writer left blank: empty, or a dash / \"n/a\" placeholder standing in\n * for \"we have no fact here\".\n *\n * This has to be judged on the RAW cell text, before `parseTableValue`, because\n * that maps an empty cell to `false` — the very same value a deliberate \"No\"\n * produces. After parsing, \"no data\" and \"no, it does not have that\" are\n * indistinguishable.\n */\nfunction isBlankCell(raw: string | undefined): boolean {\n const v = (raw ?? '').trim().toLowerCase();\n // U+2010–U+2015 are the hyphen/dash family; U+2212 is minus.\n return v === '' || v === 'n/a' || /^[-‐-―−]+$/.test(v);\n}\n\nexport class ComparisonSectionDefinition\n implements SectionDefinition<ComparisonSectionComponent>\n{\n sectionType = 'comparison' as const;\n patterns = [\n 'html_comment[section^=\"comparison\"] > (h2 | h3 | h4 | t) > html_comment? > t* > table > (t | link)?',\n ];\n\n defaults: ComparisonCompProps = {\n title: 'Comparison',\n columnLabels: ['Option A', 'Option B'],\n rows: [\n { feature: 'Price', values: ['$10', '$20'] },\n { feature: 'Storage', values: ['100GB', '1TB'] },\n ],\n };\n\n fixtures: SectionFixture<ComparisonCompProps>[] = [\n {\n markdown: `<!-- section: comparison -->\n## Compare Plans\n\n| Feature | Basic | Pro |\n|---------|-------|-----|\n| Users | 5 | Unlimited |\n| Storage | 100GB | 1TB |`,\n expected: {\n title: 'Compare Plans',\n featureColumnLabel: 'Feature',\n columnLabels: ['Basic', 'Pro'],\n rows: [\n { feature: 'Users', values: ['5', 'Unlimited'] },\n { feature: 'Storage', values: ['100GB', '1TB'] },\n ],\n },\n },\n {\n markdown: `<!-- section: comparison -->\n## Platform Comparison\n\nSee how our platform stacks up against the competition.\n\n| Feature | Our Platform | Competitor |\n|---------|--------------|------------|\n| Storage | 1TB | 100GB |\n| Users | Unlimited | 5 |\n| Support | 24/7 Priority | Email Only |\n\n[Get started](#signup)`,\n expected: {\n title: 'Platform Comparison',\n description: 'See how our platform stacks up against the competition.',\n featureColumnLabel: 'Feature',\n columnLabels: ['Our Platform', 'Competitor'],\n rows: [\n { feature: 'Storage', values: ['1TB', '100GB'] },\n { feature: 'Users', values: ['Unlimited', '5'] },\n { feature: 'Support', values: ['24/7 Priority', 'Email Only'] },\n ],\n ctaText: 'Get started',\n ctaHref: '#signup',\n },\n },\n ];\n\n parse(\n parts: Part[],\n context?: ParseContext,\n ): ComparisonCompProps | DropSection {\n const title =\n headingText(parts, 2) ||\n headingText(parts, 3) ||\n headingText(parts, 4) ||\n 'Comparison';\n const description = proseBodyMarkdown(parts) || undefined;\n\n // Table meta from nodesToParts: { columnLabels, featureColumnLabel, rows: { feature, values }[] }\n const tableParts = getPartsByType<Part>(parts, 'table');\n const tableMeta = tableParts[0]?.meta as\n | {\n columnLabels?: string[];\n columns?: ComparisonColumn[];\n featureColumnLabel?: string;\n rows?: { feature: string; iconHint?: string; values: string[] }[];\n // Legacy format from partsConverter\n headers?: string[];\n }\n | undefined;\n\n let columnLabels: string[];\n let columns: ComparisonColumn[] | undefined;\n let featureColumnLabel: string | undefined;\n let rows: ComparisonRow[];\n /** The cells exactly as written, index-aligned with `rows`. */\n let rawValueRows: string[][];\n\n if (tableMeta?.columnLabels !== undefined) {\n // SDK nodesToParts format\n columnLabels = tableMeta.columnLabels;\n columns = tableMeta.columns;\n featureColumnLabel = tableMeta.featureColumnLabel || undefined;\n rawValueRows = (tableMeta.rows ?? []).map((row) => row.values);\n rows = (tableMeta.rows ?? []).map((row) => ({\n feature: row.feature,\n ...(row.iconHint ? { iconHint: row.iconHint } : {}),\n values: row.values.map(parseTableValue),\n }));\n } else {\n // Legacy partsConverter format: { headers: string[], rows: string[][] }\n const allHeaders = tableMeta?.headers ?? [];\n const rawRows = (tableMeta as any)?.rows ?? [];\n featureColumnLabel = allHeaders[0] || undefined;\n columnLabels = allHeaders.slice(1);\n columns = columnLabels.map((label) => ({ label }));\n rawValueRows = rawRows.map((row: string[]) => row.slice(1));\n rows = rawRows.map((row: string[]) => ({\n feature: row[0] ?? '',\n values: row.slice(1).map(parseTableValue),\n }));\n }\n\n // Extract CTA from link parts\n const link = firstLink(parts);\n const ctaText = link?.text || undefined;\n const ctaHref = link?.href || undefined;\n\n // Filter out rows where all values are empty (e.g. trailing non-table text parsed as a row)\n const keptRow = rawValueRows.map((raw) => raw.some((v) => !isBlankCell(v)));\n const filteredRows = rows.filter((_, i) => keptRow[i]);\n const filteredRawRows = rawValueRows.filter((_, i) => keptRow[i]);\n const droppedCount = rows.length - filteredRows.length;\n if (droppedCount > 0) {\n context?.reportDiagnostic?.(\n DIAGNOSTIC_TYPES.ITEMS_DROPPED,\n `comparison: ${droppedCount} row(s) dropped (all values empty)`,\n );\n }\n\n // A column blank in every row is a side of the comparison the writer had no\n // facts for — it renders as a full column of dashes next to a populated one,\n // which reads as a real answer and is not one. Half a comparison is worse\n // than none, so drop the whole section. (No rows left at all lands here too:\n // every column is vacuously blank.)\n const blankColumns = columnLabels\n .map((_, col) => col)\n .filter((col) =>\n filteredRawRows.every((raw) => isBlankCell(raw[col])),\n );\n if (columnLabels.length > 0 && blankColumns.length > 0) {\n context?.reportDiagnostic?.(\n DIAGNOSTIC_TYPES.SECTION_REJECTED,\n `comparison: column(s) ${blankColumns\n .map((c) => columnLabels[c] || `#${c + 1}`)\n .join(', ')} blank across all ${filteredRawRows.length} row(s) — section dropped`,\n );\n return DROP_SECTION;\n }\n\n return {\n title,\n description,\n columnLabels,\n columns,\n rows: filteredRows,\n featureColumnLabel,\n ctaText,\n ctaHref,\n };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AAaA,IAAAE,kBAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,WAAWA,CAACC,GAAuB,EAAW;EACrD,MAAMC,CAAC,GAAG,CAACD,GAAG,IAAI,EAAE,EAAEE,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;EAC1C;EACA,OAAOF,CAAC,KAAK,EAAE,IAAIA,CAAC,KAAK,KAAK,IAAI,YAAY,CAACG,IAAI,CAACH,CAAC,CAAC;AACxD;AAEO,MAAMI,2BAA2B,CAExC;EAAAC,YAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,uBACgB,YAAY;IAAA,IAAAD,gBAAA,CAAAC,O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AAOU,+BAAY;IACrB;IAEA,OAAO;MACLvD,KAAK;MACLQ,WAAW;MACXP,YAAY;MACZqB,OAAO;MACPpB,IAAI,EAAEqC,YAAY;MAClBhC,kBAAkB;MAClBE,OAAO;MACPC;IACF,CAAC;EACH;AACF;AAAC8C,OAAA,CAAA5D,2BAAA,GAAAA,2BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_parseUtils","require","_parts","_sectionDefinition","_diagnosticTypes","isBlankCell","raw","v","trim","toLowerCase","test","ComparisonSectionDefinition","constructor","_defineProperty2","default","title","columnLabels","rows","feature","values","markdown","expected","featureColumnLabel","description","ctaText","ctaHref","parse","parts","context","_tableParts$","headingText","proseBodyMarkdown","undefined","tableParts","getPartsByType","tableMeta","meta","columns","rawValueRows","map","row","iconHint","parseTableValue","allHeaders","headers","rawRows","slice","label","lastTableIndex","p","type","lastIndexOf","link","firstLink","text","href","keptRow","some","filteredRows","filter","_","i","filteredRawRows","droppedCount","length","reportDiagnostic","DIAGNOSTIC_TYPES","ITEMS_DROPPED","blankColumns","col","every","SECTION_REJECTED","c","join","DROP_SECTION","exports"],"sources":["../../../../src/component/componentDefinitions/ComparisonSectionDefinition.ts"],"sourcesContent":["import {\n headingText,\n proseBodyMarkdown,\n firstLink,\n parseTableValue,\n} from './parse-utils';\nimport { getPartsByType, type Part } from '../../parts/parts';\nimport type {\n ComparisonColumn,\n ComparisonCompProps,\n ComparisonRow,\n ComparisonSectionComponent,\n SectionFixture,\n} from '../types';\nimport type {\n SectionDefinition,\n ParseContext,\n DropSection,\n} from '../section-definition';\nimport { DROP_SECTION } from '../section-definition';\nimport { DIAGNOSTIC_TYPES } from '../diagnosticTypes';\n\n/**\n * A cell the writer left blank: empty, or a dash / \"n/a\" placeholder standing in\n * for \"we have no fact here\".\n *\n * This has to be judged on the RAW cell text, before `parseTableValue`, because\n * that maps an empty cell to `false` — the very same value a deliberate \"No\"\n * produces. After parsing, \"no data\" and \"no, it does not have that\" are\n * indistinguishable.\n */\nfunction isBlankCell(raw: string | undefined): boolean {\n const v = (raw ?? '').trim().toLowerCase();\n // U+2010–U+2015 are the hyphen/dash family; U+2212 is minus.\n return v === '' || v === 'n/a' || /^[-‐-―−]+$/.test(v);\n}\n\nexport class ComparisonSectionDefinition\n implements SectionDefinition<ComparisonSectionComponent>\n{\n sectionType = 'comparison' as const;\n // The pre-table slot is the description paragraph, so it has to admit\n // `link`: `convertToBlockElements` unwraps a paragraph into its inline\n // nodes, so `Questions? Email support@shop.example for help.` arrives as\n // `t link t` — GFM autolinks a bare email, no author required — and an\n // authored `[men's shoes](web5://ask/…)` does the same. With `t*` the run\n // ended at that `link`, the whole pattern failed, and the section never\n // reached `parse()`: the heading and prose were claimed by `textBlock` and\n // the TABLE fell to `FallbackSectionDefinition`, whose `partsToMarkdown`\n // has no `table` branch — so it rendered as an empty section and the\n // comparison silently vanished.\n //\n // The trailing slot stays `(t | link)?`: it is the CTA, and `parse()` reads\n // it positionally (see `ctaText` below). Widening it would let the section\n // swallow a paragraph belonging to whatever follows.\n patterns = [\n 'html_comment[section^=\"comparison\"] > (h2 | h3 | h4 | t) > html_comment? > (t | link)* > table > (t | link)?',\n ];\n\n defaults: ComparisonCompProps = {\n title: 'Comparison',\n columnLabels: ['Option A', 'Option B'],\n rows: [\n { feature: 'Price', values: ['$10', '$20'] },\n { feature: 'Storage', values: ['100GB', '1TB'] },\n ],\n };\n\n fixtures: SectionFixture<ComparisonCompProps>[] = [\n {\n markdown: `<!-- section: comparison -->\n## Compare Plans\n\n| Feature | Basic | Pro |\n|---------|-------|-----|\n| Users | 5 | Unlimited |\n| Storage | 100GB | 1TB |`,\n expected: {\n title: 'Compare Plans',\n featureColumnLabel: 'Feature',\n columnLabels: ['Basic', 'Pro'],\n rows: [\n { feature: 'Users', values: ['5', 'Unlimited'] },\n { feature: 'Storage', values: ['100GB', '1TB'] },\n ],\n },\n },\n {\n markdown: `<!-- section: comparison -->\n## Platform Comparison\n\nSee how our platform stacks up against the competition.\n\n| Feature | Our Platform | Competitor |\n|---------|--------------|------------|\n| Storage | 1TB | 100GB |\n| Users | Unlimited | 5 |\n| Support | 24/7 Priority | Email Only |\n\n[Get started](#signup)`,\n expected: {\n title: 'Platform Comparison',\n description: 'See how our platform stacks up against the competition.',\n featureColumnLabel: 'Feature',\n columnLabels: ['Our Platform', 'Competitor'],\n rows: [\n { feature: 'Storage', values: ['1TB', '100GB'] },\n { feature: 'Users', values: ['Unlimited', '5'] },\n { feature: 'Support', values: ['24/7 Priority', 'Email Only'] },\n ],\n ctaText: 'Get started',\n ctaHref: '#signup',\n },\n },\n ];\n\n parse(\n parts: Part[],\n context?: ParseContext,\n ): ComparisonCompProps | DropSection {\n const title =\n headingText(parts, 2) ||\n headingText(parts, 3) ||\n headingText(parts, 4) ||\n 'Comparison';\n const description = proseBodyMarkdown(parts) || undefined;\n\n // Table meta from nodesToParts: { columnLabels, featureColumnLabel, rows: { feature, values }[] }\n const tableParts = getPartsByType<Part>(parts, 'table');\n const tableMeta = tableParts[0]?.meta as\n | {\n columnLabels?: string[];\n columns?: ComparisonColumn[];\n featureColumnLabel?: string;\n rows?: { feature: string; iconHint?: string; values: string[] }[];\n // Legacy format from partsConverter\n headers?: string[];\n }\n | undefined;\n\n let columnLabels: string[];\n let columns: ComparisonColumn[] | undefined;\n let featureColumnLabel: string | undefined;\n let rows: ComparisonRow[];\n /** The cells exactly as written, index-aligned with `rows`. */\n let rawValueRows: string[][];\n\n if (tableMeta?.columnLabels !== undefined) {\n // SDK nodesToParts format\n columnLabels = tableMeta.columnLabels;\n columns = tableMeta.columns;\n featureColumnLabel = tableMeta.featureColumnLabel || undefined;\n rawValueRows = (tableMeta.rows ?? []).map((row) => row.values);\n rows = (tableMeta.rows ?? []).map((row) => ({\n feature: row.feature,\n ...(row.iconHint ? { iconHint: row.iconHint } : {}),\n values: row.values.map(parseTableValue),\n }));\n } else {\n // Legacy partsConverter format: { headers: string[], rows: string[][] }\n const allHeaders = tableMeta?.headers ?? [];\n const rawRows = (tableMeta as any)?.rows ?? [];\n featureColumnLabel = allHeaders[0] || undefined;\n columnLabels = allHeaders.slice(1);\n columns = columnLabels.map((label) => ({ label }));\n rawValueRows = rawRows.map((row: string[]) => row.slice(1));\n rows = rawRows.map((row: string[]) => ({\n feature: row[0] ?? '',\n values: row.slice(1).map(parseTableValue),\n }));\n }\n\n // The CTA is the link AFTER the table, not merely the first link in the\n // section — the description may now carry its own inline links, and\n // `firstLink(parts)` would promote one of those to the CTA button.\n const lastTableIndex = parts.map((p) => p.type).lastIndexOf('table');\n const link = firstLink(\n lastTableIndex >= 0 ? parts.slice(lastTableIndex + 1) : parts,\n );\n const ctaText = link?.text || undefined;\n const ctaHref = link?.href || undefined;\n\n // Filter out rows where all values are empty (e.g. trailing non-table text parsed as a row)\n const keptRow = rawValueRows.map((raw) => raw.some((v) => !isBlankCell(v)));\n const filteredRows = rows.filter((_, i) => keptRow[i]);\n const filteredRawRows = rawValueRows.filter((_, i) => keptRow[i]);\n const droppedCount = rows.length - filteredRows.length;\n if (droppedCount > 0) {\n context?.reportDiagnostic?.(\n DIAGNOSTIC_TYPES.ITEMS_DROPPED,\n `comparison: ${droppedCount} row(s) dropped (all values empty)`,\n );\n }\n\n // A column blank in every row is a side of the comparison the writer had no\n // facts for — it renders as a full column of dashes next to a populated one,\n // which reads as a real answer and is not one. Half a comparison is worse\n // than none, so drop the whole section. (No rows left at all lands here too:\n // every column is vacuously blank.)\n const blankColumns = columnLabels\n .map((_, col) => col)\n .filter((col) =>\n filteredRawRows.every((raw) => isBlankCell(raw[col])),\n );\n if (columnLabels.length > 0 && blankColumns.length > 0) {\n context?.reportDiagnostic?.(\n DIAGNOSTIC_TYPES.SECTION_REJECTED,\n `comparison: column(s) ${blankColumns\n .map((c) => columnLabels[c] || `#${c + 1}`)\n .join(', ')} blank across all ${filteredRawRows.length} row(s) — section dropped`,\n );\n return DROP_SECTION;\n }\n\n return {\n title,\n description,\n columnLabels,\n columns,\n rows: filteredRows,\n featureColumnLabel,\n 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GAAGN,YAAY,CAACM,MAAM;IACtD,IAAID,YAAY,GAAG,CAAC,EAAE;MACpBnC,OAAO,YAAPA,OAAO,CAAEqC,gBAAgB,YAAzBrC,OAAO,CAAEqC,gBAAgB,CACvBC,iCAAgB,CAACC,aAAa,EAC9B,eAAeJ,YAAY,oCAC7B,CAAC;IACH;;IAEA;IACA;IACA;IACA;IACA;IACA,MAAMK,YAAY,GAAGpD,YAAY,CAC9BuB,GAAG,CAAC,CAACqB,CAAC,EAAES,GAAG,KAAKA,GAAG,CAAC,CACpBV,MAAM,CAAEU,GAAG,IACVP,eAAe,CAACQ,KAAK,CAAEhE,GAAG,IAAKD,WAAW,CAACC,GAAG,CAAC+D,GAAG,CAAC,CAAC,CACtD,CAAC;IACH,IAAIrD,YAAY,CAACgD,MAAM,GAAG,CAAC,IAAII,YAAY,CAACJ,MAAM,GAAG,CAAC,EAAE;MACtDpC,OAAO,YAAPA,OAAO,CAAEqC,gBAAgB,YAAzBrC,OAAO,CAAEqC,gBAAgB,CACvBC,iCAAgB,CAACK,gBAAgB,EACjC,yBAAyBH,YAAY,CAClC7B,GAAG,CAAEiC,CAAC,IAAKxD,YAAY,CAACwD,CAAC,CAAC,IAAI,IAAIA,CAAC,GAAG,CAAC,EAAE,CAAC,CAC1CC,IAAI,CAAC,IAAI,CAAC,qBAAqBX,eAAe,CAACE,MAAM,2BAC1D,CAAC;MACD,OAAOU,+BAAY;IACrB;IAEA,OAAO;MACL3D,KAAK;MACLQ,WAAW;MACXP,YAAY;MACZqB,OAAO;MACPpB,IAAI,EAAEyC,YAAY;MAClBpC,kBAAkB;MAClBE,OAAO;MACPC;IACF,CAAC;EACH;AACF;AAACkD,OAAA,CAAAhE,2BAAA,GAAAA,2BAAA","ignoreList":[]}
@@ -86,10 +86,21 @@ Description B.`,
86
86
  for (const group of groups) {
87
87
  const title = (0, _parseUtils.headingMarkdown)(group, 2) || (0, _parseUtils.headingMarkdown)(group, 3) || '';
88
88
  let imageUrl = (0, _parseUtils.firstImageSrc)(group);
89
- const description = (0, _parseUtils.bodyText)(group) || '';
89
+ // Both `FeatureCardsSection` renderers put this through `MarkdownText`,
90
+ // so a link inside a sentence has to survive: `bodyText` kept only text
91
+ // parts and joined them with a blank line, so `Email support@shop.example
92
+ // anytime` arrived as "Email\n\nanytime" — address gone, sentence split
93
+ // at the gap (GFM autolinks a bare email into a `link` node, so this
94
+ // needed no author). `proseBodyMarkdown` rather than `bodyMarkdown`
95
+ // because a links-only paragraph is the card's own CTA, read below into
96
+ // `linkText` / `linkHref`; keeping it here would render it twice.
97
+ const description = (0, _parseUtils.proseBodyMarkdown)(group) || '';
90
98
  let imageFromText;
91
99
  if (!imageUrl && context != null && context.getContextualImage) {
92
- const contentParts = [(0, _parseUtils.stripMarkdown)(title), description];
100
+ // Strip before keyword matching, as the title already is: the matcher
101
+ // scans for whole words, and a raw `](web5://ask/hydration)` would let
102
+ // a url slug pick the card's image.
103
+ const contentParts = [(0, _parseUtils.stripMarkdown)(title), (0, _parseUtils.stripMarkdown)(description)];
93
104
  const result = context.getContextualImage(contentParts);
94
105
  if (result) {
95
106
  imageUrl = result.filename;
@@ -1 +1 @@
1
- {"version":3,"names":["_parseUtils","require","FeatureCardsSectionDefinition","constructor","_defineProperty2","default","cards","title","description","markdown","expected","callout","text","kind","parse","parts","context","groups","current","part","type","some","p","push","length","group","headingMarkdown","imageUrl","firstImageSrc","bodyText","imageFromText","getContextualImage","contentParts","stripMarkdown","result","filename","isFromText","undefined","link","firstLink","linkText","linkHref","href","calloutFromParts","exports"],"sources":["../../../../src/component/componentDefinitions/FeatureCardsSectionDefinition.ts"],"sourcesContent":["import type { Part } from '../../parts/parts';\nimport {\n headingMarkdown,\n bodyText,\n calloutFromParts,\n firstImageSrc,\n firstLink,\n stripMarkdown,\n} from './parse-utils';\nimport type {\n FeatureCardCompProps,\n FeatureCardsCompProps,\n FeatureCardsSectionComponent,\n SectionFixture,\n} from '../types';\nimport type { SectionDefinition, ParseContext } from '../section-definition';\n\nexport class FeatureCardsSectionDefinition\n implements SectionDefinition<FeatureCardsSectionComponent>\n{\n sectionType = 'featureCards' as const;\n patterns = [\n '(html_comment[section^=\"information\"] > h2 > image? > t+ > link? > callout?)[2-]',\n ];\n\n defaults: FeatureCardsCompProps = {\n cards: [\n {\n title: 'Feature 1',\n description: 'Description of feature 1',\n },\n ],\n };\n\n fixtures: SectionFixture<FeatureCardsCompProps>[] = [\n {\n markdown: `<!-- section: information, reason: first card -->\n## Fast\n\nLightning quick performance\n\n> [!TIP] Speed is everything.\n\n<!-- section: information, reason: second card -->\n## Secure\n\nEnterprise-grade security\n\n> [!NOTE] Built with best practices.`,\n expected: {\n cards: [\n {\n title: 'Fast',\n description: 'Lightning quick performance',\n callout: { text: 'Speed is everything.', kind: 'TIP' },\n },\n {\n title: 'Secure',\n description: 'Enterprise-grade security',\n callout: { text: 'Built with best practices.', kind: 'NOTE' },\n },\n ],\n },\n },\n {\n markdown: `## Feature A\n\nFirst paragraph.\n\nSecond paragraph with more detail.\n\n## Feature B\n\nDescription B.`,\n expected: {\n cards: [\n {\n title: 'Feature A',\n description:\n 'First paragraph.\\n\\nSecond paragraph with more detail.',\n },\n { title: 'Feature B', description: 'Description B.' },\n ],\n },\n },\n ];\n\n parse(parts: Part[], context?: ParseContext): FeatureCardsCompProps {\n // Split flat parts into groups by heading boundaries\n const groups: Part[][] = [];\n let current: Part[] = [];\n\n for (const part of parts) {\n if (\n part.type === 'heading' &&\n current.some((p) => p.type === 'heading')\n ) {\n groups.push(current);\n current = [part];\n } else {\n current.push(part);\n }\n }\n if (current.length > 0 && current.some((p) => p.type === 'heading')) {\n groups.push(current);\n }\n\n const cards: FeatureCardCompProps[] = [];\n for (const group of groups) {\n const title =\n headingMarkdown(group, 2) || headingMarkdown(group, 3) || '';\n let imageUrl = firstImageSrc(group);\n const description = bodyText(group) || '';\n\n let imageFromText: boolean | undefined;\n if (!imageUrl && context?.getContextualImage) {\n const contentParts = [stripMarkdown(title), description];\n const result = context.getContextualImage(contentParts);\n if (result) {\n imageUrl = result.filename;\n imageFromText = result.isFromText || undefined;\n }\n }\n const link = firstLink(group);\n const linkText = link?.text || undefined;\n const linkHref = link?.href || undefined;\n const callout = calloutFromParts(group);\n\n cards.push({\n title,\n description,\n imageUrl,\n imageFromText,\n linkText,\n linkHref,\n callout,\n });\n }\n\n return { cards };\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAgBO,MAAMC,6BAA6B,CAE1C;EAAAC,YAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,uBACgB,cAAc;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBACjB,CACT,kFAAkF,CACnF;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBAEiC;MAChCC,KAAK,EAAE,CACL;QACEC,KAAK,EAAE,WAAW;QAClBC,WAAW,EAAE;MACf,CAAC;IAEL,CAAC;IAAA,IAAAJ,gBAAA,CAAAC,OAAA,oBAEmD,CAClD;MACEI,QAAQ,EAAE;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC;MAC/BC,QAAQ,EAAE;QACRJ,KAAK,EAAE,CACL;UACEC,KAAK,EAAE,MAAM;UACbC,WAAW,EAAE,6BAA6B;UAC1CG,OAAO,EAAE;YAAEC,IAAI,EAAE,sBAAsB;YAAEC,IAAI,EAAE;UAAM;QACvD,CAAC,EACD;UACEN,KAAK,EAAE,QAAQ;UACfC,WAAW,EAAE,2BAA2B;UACxCG,OAAO,EAAE;YAAEC,IAAI,EAAE,4BAA4B;YAAEC,IAAI,EAAE;UAAO;QAC9D,CAAC;MAEL;IACF,CAAC,EACD;MACEJ,QAAQ,EAAE;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;MACTC,QAAQ,EAAE;QACRJ,KAAK,EAAE,CACL;UACEC,KAAK,EAAE,WAAW;UAClBC,WAAW,EACT;QACJ,CAAC,EACD;UAAED,KAAK,EAAE,WAAW;U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,GAAGlB,OAAO,CAACe,kBAAkB,CAACC,YAAY,CAAC;QACvD,IAAIE,MAAM,EAAE;UACVP,QAAQ,GAAGO,MAAM,CAACC,QAAQ;UAC1BL,aAAa,GAAGI,MAAM,CAACE,UAAU,IAAIC,SAAS;QAChD;MACF;MACA,MAAMC,IAAI,GAAG,IAAAC,qBAAS,EAACd,KAAK,CAAC;MAC7B,MAAMe,QAAQ,GAAG,CAAAF,IAAI,oBAAJA,IAAI,CAAE1B,IAAI,KAAIyB,SAAS;MACxC,MAAMI,QAAQ,GAAG,CAAAH,IAAI,oBAAJA,IAAI,CAAEI,IAAI,KAAIL,SAAS;MACxC,MAAM1B,OAAO,GAAG,IAAAgC,4BAAgB,EAAClB,KAAK,CAAC;MAEvCnB,KAAK,CAACiB,IAAI,CAAC;QACThB,KAAK;QACLC,WAAW;QACXmB,QAAQ;QACRG,aAAa;QACbU,QAAQ;QACRC,QAAQ;QACR9B;MACF,CAAC,CAAC;IACJ;IAEA,OAAO;MAAEL;IAAM,CAAC;EAClB;AACF;AAACsC,OAAA,CAAA1C,6BAAA,GAAAA,6BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_parseUtils","require","FeatureCardsSectionDefinition","constructor","_defineProperty2","default","cards","title","description","markdown","expected","callout","text","kind","parse","parts","context","groups","current","part","type","some","p","push","length","group","headingMarkdown","imageUrl","firstImageSrc","proseBodyMarkdown","imageFromText","getContextualImage","contentParts","stripMarkdown","result","filename","isFromText","undefined","link","firstLink","linkText","linkHref","href","calloutFromParts","exports"],"sources":["../../../../src/component/componentDefinitions/FeatureCardsSectionDefinition.ts"],"sourcesContent":["import type { Part } from '../../parts/parts';\nimport {\n headingMarkdown,\n proseBodyMarkdown,\n calloutFromParts,\n firstImageSrc,\n firstLink,\n stripMarkdown,\n} from './parse-utils';\nimport type {\n FeatureCardCompProps,\n FeatureCardsCompProps,\n FeatureCardsSectionComponent,\n SectionFixture,\n} from '../types';\nimport type { SectionDefinition, ParseContext } from '../section-definition';\n\nexport class FeatureCardsSectionDefinition\n implements SectionDefinition<FeatureCardsSectionComponent>\n{\n sectionType = 'featureCards' as const;\n patterns = [\n '(html_comment[section^=\"information\"] > h2 > image? > t+ > link? > callout?)[2-]',\n ];\n\n defaults: FeatureCardsCompProps = {\n cards: [\n {\n title: 'Feature 1',\n description: 'Description of feature 1',\n },\n ],\n };\n\n fixtures: SectionFixture<FeatureCardsCompProps>[] = [\n {\n markdown: `<!-- section: information, reason: first card -->\n## Fast\n\nLightning quick performance\n\n> [!TIP] Speed is everything.\n\n<!-- section: information, reason: second card -->\n## Secure\n\nEnterprise-grade security\n\n> [!NOTE] Built with best practices.`,\n expected: {\n cards: [\n {\n title: 'Fast',\n description: 'Lightning quick performance',\n callout: { text: 'Speed is everything.', kind: 'TIP' },\n },\n {\n title: 'Secure',\n description: 'Enterprise-grade security',\n callout: { text: 'Built with best practices.', kind: 'NOTE' },\n },\n ],\n },\n },\n {\n markdown: `## Feature A\n\nFirst paragraph.\n\nSecond paragraph with more detail.\n\n## Feature B\n\nDescription B.`,\n expected: {\n cards: [\n {\n title: 'Feature A',\n description:\n 'First paragraph.\\n\\nSecond paragraph with more detail.',\n },\n { title: 'Feature B', description: 'Description B.' },\n ],\n },\n },\n ];\n\n parse(parts: Part[], context?: ParseContext): FeatureCardsCompProps {\n // Split flat parts into groups by heading boundaries\n const groups: Part[][] = [];\n let current: Part[] = [];\n\n for (const part of parts) {\n if (\n part.type === 'heading' &&\n current.some((p) => p.type === 'heading')\n ) {\n groups.push(current);\n current = [part];\n } else {\n current.push(part);\n }\n }\n if (current.length > 0 && current.some((p) => p.type === 'heading')) {\n groups.push(current);\n }\n\n const cards: FeatureCardCompProps[] = [];\n for (const group of groups) {\n const title =\n headingMarkdown(group, 2) || headingMarkdown(group, 3) || '';\n let imageUrl = firstImageSrc(group);\n // Both `FeatureCardsSection` renderers put this through `MarkdownText`,\n // so a link inside a sentence has to survive: `bodyText` kept only text\n // parts and joined them with a blank line, so `Email support@shop.example\n // anytime` arrived as \"Email\\n\\nanytime\" — address gone, sentence split\n // at the gap (GFM autolinks a bare email into a `link` node, so this\n // needed no author). `proseBodyMarkdown` rather than `bodyMarkdown`\n // because a links-only paragraph is the card's own CTA, read below into\n // `linkText` / `linkHref`; keeping it here would render it twice.\n const description = proseBodyMarkdown(group) || '';\n\n let imageFromText: boolean | undefined;\n if (!imageUrl && context?.getContextualImage) {\n // Strip before keyword matching, as the title already is: the matcher\n // scans for whole words, and a raw `](web5://ask/hydration)` would let\n // a url slug pick the card's image.\n const contentParts = [stripMarkdown(title), stripMarkdown(description)];\n const result = context.getContextualImage(contentParts);\n if (result) {\n imageUrl = result.filename;\n imageFromText = result.isFromText || undefined;\n }\n }\n const link = firstLink(group);\n const linkText = link?.text || undefined;\n const linkHref = link?.href || undefined;\n const callout = calloutFromParts(group);\n\n cards.push({\n title,\n description,\n imageUrl,\n imageFromText,\n linkText,\n linkHref,\n callout,\n });\n }\n\n return { cards };\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAgBO,MAAMC,6BAA6B,CAE1C;EAAAC,YAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,uBACgB,cAAc;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBACjB,CACT,kFAAkF,CACnF;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBAEiC;MAChCC,KAAK,EAAE,CACL;QACEC,KAAK,EAAE,WAAW;QAClBC,WAAW,EAAE;MACf,CAAC;IAEL,CAAC;IAAA,IAAAJ,gBAAA,CAAAC,OAAA,oBAEmD,CAClD;MACEI,QAAQ,EAAE;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC;MAC/BC,QAAQ,EAAE;QACRJ,KAAK,EAAE,CACL;UACEC,KAAK,EAAE,MAAM;UACbC,WAAW,EAAE,6BAA6B;UAC1CG,OAAO,EAAE;YAAEC,IAAI,EAAE,sBAAsB;YAAEC,IAAI,EAAE;U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D,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE;MAC9D,IAAIE,QAAQ,GAAG,IAAAC,yBAAa,EAACH,KAAK,CAAC;MACnC;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,MAAMjB,WAAW,GAAG,IAAAqB,6BAAiB,EAACJ,KAAK,CAAC,IAAI,EAAE;MAElD,IAAIK,aAAkC;MACtC,IAAI,CAACH,QAAQ,IAAIX,OAAO,YAAPA,OAAO,CAAEe,kBAAkB,EAAE;QAC5C;QACA;QACA;QACA,MAAMC,YAAY,GAAG,CAAC,IAAAC,yBAAa,EAAC1B,KAAK,CAAC,EAAE,IAAA0B,yBAAa,EAACzB,WAAW,CAAC,CAAC;QACvE,MAAM0B,MAAM,GAAGlB,OAAO,CAACe,kBAAkB,CAACC,YAAY,CAAC;QACvD,IAAIE,MAAM,EAAE;UACVP,QAAQ,GAAGO,MAAM,CAACC,QAAQ;UAC1BL,aAAa,GAAGI,MAAM,CAACE,UAAU,IAAIC,SAAS;QAChD;MACF;MACA,MAAMC,IAAI,GAAG,IAAAC,qBAAS,EAACd,KAAK,CAAC;MAC7B,MAAMe,QAAQ,GAAG,CAAAF,IAAI,oBAAJA,IAAI,CAAE1B,IAAI,KAAIyB,SAAS;MACxC,MAAMI,QAAQ,GAAG,CAAAH,IAAI,oBAAJA,IAAI,CAAEI,IAAI,KAAIL,SAAS;MACxC,MAAM1B,OAAO,GAAG,IAAAgC,4BAAgB,EAAClB,KAAK,CAAC;MAEvCnB,KAAK,CAACiB,IAAI,CAAC;QACThB,KAAK;QACLC,WAAW;QACXmB,QAAQ;QACRG,aAAa;QACbU,QAAQ;QACRC,QAAQ;QACR9B;MACF,CAAC,CAAC;IACJ;IAEA,OAAO;MAAEL;IAAM,CAAC;EAClB;AACF;AAACsC,OAAA,CAAA1C,6BAAA,GAAAA,6BAAA","ignoreList":[]}
@@ -92,9 +92,13 @@ Get started today with our amazing features.
92
92
  }
93
93
  }
94
94
 
95
- // Start with top-level links as buttons
95
+ // Start with the hero's own button row. NOT every top-level link: a link
96
+ // inside a prose paragraph is a top-level part too, so `getLinks` handed
97
+ // `Email support@shop.example` the `btn-0` / primary slot and pushed the
98
+ // real call to action down to secondary. `standaloneLinks` keeps only a
99
+ // link that stands alone as its own block, which is the row the hero means.
96
100
  let buttonIndex = 0;
97
- const buttons = (0, _parts.getLinks)(parts).map((l, i) => {
101
+ const buttons = (0, _parseUtils.standaloneLinks)(parts).map((l, i) => {
98
102
  var _l$content;
99
103
  return {
100
104
  id: `btn-${i}`,
@@ -1 +1 @@
1
- {"version":3,"names":["_parseUtils","require","_parts","HeroSectionDefinition","constructor","_defineProperty2","default","headline","content","buttons","id","text","variant","markdown","expected","onClick","image","parse","parts","firstImageSrc","lists","getPartsByType","list","item","_list$meta","meta","items","_item$meta","itemParts","nestedImage","buttonIndex","getLinks","map","l","i","_l$content","trim","href","length","trailingList","filteredItems","_list$meta2","_item$meta2","hasImage","some","p","type","push","allItemsAreLinks","listLinks","_item$meta3","_itemLinkParts$0$cont","itemLinkParts","filter","allText","extractListItemText","linkTexts","_l$content2","join","link","isFirstButton","lines","_item$meta4","h1Index","findIndex","_p$meta","level","blockquotes","leadingQuote","bq","_bq$meta","_bq$content","bqIndex","indexOf","raw","parseCalloutTag","undefined","headingMarkdown","badge","headingText","proseBodyMarkdown","exports"],"sources":["../../../../src/component/componentDefinitions/HeroSectionDefinition.ts"],"sourcesContent":["import {\n headingText,\n headingMarkdown,\n proseBodyMarkdown,\n firstImageSrc,\n parseCalloutTag,\n extractListItemText,\n} from './parse-utils';\nimport type { Part, ListPart, LinkPart, ListItemPart } from '../../parts/parts';\nimport { getPartsByType, getLinks } from '../../parts/parts';\nimport type {\n HeroButton,\n HeroCompProps,\n HeroSectionComponent,\n SectionFixture,\n} from '../types';\nimport type { SectionDefinition } from '../section-definition';\n\nexport class HeroSectionDefinition\n implements SectionDefinition<HeroSectionComponent>\n{\n sectionType = 'hero' as const;\n singleInstance = true;\n patterns = [\n // Canonical hero shape: section descriptor, then the leading ECHO callout\n // (optional in the grammar — the orchestrator always emits it, but a missing\n // ECHO must not stop the hero from rendering), then an optional h3 badge,\n // then the h1. The callout and badge are independent slots so a hero can\n // carry both. The second `html_comment?` keeps the legacy ordering\n // (callout before the descriptor) matching for pages saved before this change.\n 'html_comment? > callout? > html_comment? > h3? > h1 > (image | t | link)* > list?',\n ];\n\n defaults: HeroCompProps = {\n headline: 'Build something amazing',\n content: 'Your platform for data-driven decisions.',\n buttons: [{ id: 'btn-0', text: 'Get started', variant: 'primary' }],\n };\n\n fixtures: SectionFixture<HeroCompProps>[] = [\n {\n markdown:\n '# Welcome\\n\\nBuild amazing things.\\n\\n[Get Started](/) [Learn More](/about)',\n expected: {\n headline: 'Welcome',\n content: 'Build amazing things.',\n buttons: [\n {\n id: 'btn-0',\n text: 'Get Started',\n variant: 'primary',\n onClick: '/',\n },\n {\n id: 'btn-1',\n text: 'Learn More',\n variant: 'secondary',\n onClick: '/about',\n },\n ],\n },\n },\n {\n markdown: `<!-- Hero Section -->\n\n# Welcome to Our Platform\n\n![Hero Image](hero.jpg)\n\nGet started today with our amazing features.\n\n[Get Started](/signup) [Learn More](/about)`,\n expected: {\n headline: 'Welcome to Our Platform',\n content: 'Get started today with our amazing features.',\n buttons: [\n {\n id: 'btn-0',\n text: 'Get Started',\n variant: 'primary',\n onClick: '/signup',\n },\n {\n id: 'btn-1',\n text: 'Learn More',\n variant: 'secondary',\n onClick: '/about',\n },\n ],\n image: 'hero.jpg',\n },\n },\n ];\n\n parse(parts: Part[]): HeroCompProps {\n let image = firstImageSrc(parts);\n const lists = getPartsByType<ListPart>(parts, 'list');\n\n if (!image) {\n for (const list of lists) {\n for (const item of list.meta?.items ?? []) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const nestedImage = firstImageSrc(itemParts);\n if (nestedImage) {\n image = nestedImage;\n break;\n }\n }\n if (image) {\n break;\n }\n }\n }\n\n // Start with top-level links as buttons\n let buttonIndex = 0;\n const buttons: HeroButton[] = getLinks(parts).map(\n (l, i): HeroButton => ({\n id: `btn-${i}`,\n text: l.content?.trim() || 'Learn more',\n variant: i === 0 ? 'primary' : 'secondary',\n onClick: l.meta.href,\n }),\n );\n buttonIndex = buttons.length;\n\n // Process lists: filter out image-only items, then check if remaining\n // items are all link-only. If so, convert to buttons; otherwise keep as trailingList.\n let trailingList: string | undefined;\n if (lists.length > 0) {\n for (const list of lists) {\n // Filter out image-only items\n const filteredItems: ListItemPart[] = [];\n for (const item of list.meta?.items ?? []) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const hasImage = itemParts.some((p) => p.type === 'image');\n if (hasImage) {\n continue;\n }\n filteredItems.push(item);\n }\n\n if (filteredItems.length === 0) {\n continue;\n }\n\n // Check if ALL remaining items contain only links (no other text)\n let allItemsAreLinks = true;\n const listLinks: { text: string; href: string }[] = [];\n\n for (const item of filteredItems) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const itemLinkParts = itemParts.filter(\n (p): p is LinkPart => p.type === 'link',\n );\n\n if (itemLinkParts.length === 0) {\n allItemsAreLinks = false;\n break;\n }\n\n // Check if the item text is entirely link text (no extra content)\n const allText = extractListItemText(item).trim();\n const linkTexts = itemLinkParts\n .map((l) => l.content?.trim() || '')\n .join(' ')\n .trim();\n\n if (allText !== linkTexts) {\n allItemsAreLinks = false;\n break;\n }\n\n listLinks.push({\n text: itemLinkParts[0].content?.trim() || 'Learn more',\n href: itemLinkParts[0].meta.href,\n });\n }\n\n if (allItemsAreLinks && listLinks.length > 0) {\n // Convert link-only list items to buttons\n for (const link of listLinks) {\n const isFirstButton = buttons.length === 0;\n buttons.push({\n id: `btn-${buttonIndex++}`,\n text: link.text,\n variant: isFirstButton ? 'primary' : 'secondary',\n onClick: link.href,\n });\n }\n } else {\n // Keep as trailing list markdown\n const lines: string[] = [];\n for (const item of filteredItems) {\n const text =\n (item.meta?.markdown as string) || extractListItemText(item);\n if (text) {\n lines.push(`- ${text}`);\n }\n }\n if (lines.length > 0) {\n trailingList = lines.join('\\n');\n }\n }\n }\n }\n\n // The hero claims the leading callout before the h1 — the ECHO the\n // orchestrator emits as the hero's opening line, right after the section\n // descriptor. A trailing blockquote is not part of the hero pattern, so it\n // falls through to a downstream callout section instead.\n const h1Index = parts.findIndex(\n (p) => p.type === 'heading' && (p.meta as { level: number })?.level === 1,\n );\n const blockquotes = getPartsByType<Part>(parts, 'callout');\n let leadingQuote: string | undefined;\n\n for (const bq of blockquotes) {\n const bqIndex = parts.indexOf(bq);\n if (h1Index >= 0 && bqIndex > h1Index) {\n continue;\n }\n const raw = (bq.meta?.markdown as string)?.trim() || bq.content?.trim();\n if (!raw) {\n continue;\n }\n leadingQuote = parseCalloutTag(raw).text || undefined;\n }\n\n return {\n // Markdown-preserving (not headingText): the hero title now carries the\n // bold+italic hook the ECHO callout used to own, so the FE needs the\n // formatting, not just the plain text. See FeatureComparisonHero.tsx.\n headline: headingMarkdown(parts, 1),\n badge: headingText(parts, 3) || undefined,\n content: proseBodyMarkdown(parts) || undefined,\n buttons: buttons.length > 0 ? buttons : undefined,\n image,\n trailingList,\n leadingQuote,\n };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AASA,IAAAC,MAAA,GAAAD,OAAA;AASO,MAAME,qBAAqB,CAElC;EAAAC,YAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,uBACgB,MAAM;IAAA,IAAAD,gBAAA,CAAAC,OAAA,0BACH,IAAI;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBACV;IACT;IACA;IACA;IACA;IACA;IACA;IACA,mFAAmF,CACpF;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBAEyB;MACxBC,QAAQ,EAAE,yBAAyB;MACnCC,OAAO,EAAE,0CAA0C;MACnDC,OAAO,EAAE,CAAC;QAAEC,EAAE,EAAE,OAAO;QAAEC,IAAI,EAAE,aAAa;QAAEC,OAAO,EAAE;MAAU,CAAC;IACpE,CAAC;IAAA,IAAAP,gB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KAAK,MAAK,CAAC;IAAA,CAC3E,CAAC;IACD,MAAMC,WAAW,GAAG,IAAA9C,qBAAc,EAAOH,KAAK,EAAE,SAAS,CAAC;IAC1D,IAAIkD,YAAgC;IAEpC,KAAK,MAAMC,EAAE,IAAIF,WAAW,EAAE;MAAA,IAAAG,QAAA,EAAAC,WAAA;MAC5B,MAAMC,OAAO,GAAGtD,KAAK,CAACuD,OAAO,CAACJ,EAAE,CAAC;MACjC,IAAIN,OAAO,IAAI,CAAC,IAAIS,OAAO,GAAGT,OAAO,EAAE;QACrC;MACF;MACA,MAAMW,GAAG,GAAG,EAAAJ,QAAA,GAACD,EAAE,CAAC5C,IAAI,cAAA6C,QAAA,GAAPA,QAAA,CAASzD,QAAQ,qBAAlByD,QAAA,CAA+BlC,IAAI,CAAC,CAAC,OAAAmC,WAAA,GAAIF,EAAE,CAAC7D,OAAO,qBAAV+D,WAAA,CAAYnC,IAAI,CAAC,CAAC;MACvE,IAAI,CAACsC,GAAG,EAAE;QACR;MACF;MACAN,YAAY,GAAG,IAAAO,2BAAe,EAACD,GAAG,CAAC,CAAC/D,IAAI,IAAIiE,SAAS;IACvD;IAEA,OAAO;MACL;MACA;MACA;MACArE,QAAQ,EAAE,IAAAsE,2BAAe,EAAC3D,KAAK,EAAE,CAAC,CAAC;MACnC4D,KAAK,EAAE,IAAAC,uBAAW,EAAC7D,KAAK,EAAE,CAAC,CAAC,IAAI0D,SAAS;MACzCpE,OAAO,EAAE,IAAAwE,6BAAiB,EAAC9D,KAAK,CAAC,IAAI0D,SAAS;MAC9CnE,OAAO,EAAEA,OAAO,CAAC6B,MAAM,GAAG,CAAC,GAAG7B,OAAO,GAAGmE,SAAS;MACjD5D,KAAK;MACLuB,YAAY;MACZ6B;IACF,CAAC;EACH;AACF;AAACa,OAAA,CAAA9E,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_parseUtils","require","_parts","HeroSectionDefinition","constructor","_defineProperty2","default","headline","content","buttons","id","text","variant","markdown","expected","onClick","image","parse","parts","firstImageSrc","lists","getPartsByType","list","item","_list$meta","meta","items","_item$meta","itemParts","nestedImage","buttonIndex","standaloneLinks","map","l","i","_l$content","trim","href","length","trailingList","filteredItems","_list$meta2","_item$meta2","hasImage","some","p","type","push","allItemsAreLinks","listLinks","_item$meta3","_itemLinkParts$0$cont","itemLinkParts","filter","allText","extractListItemText","linkTexts","_l$content2","join","link","isFirstButton","lines","_item$meta4","h1Index","findIndex","_p$meta","level","blockquotes","leadingQuote","bq","_bq$meta","_bq$content","bqIndex","indexOf","raw","parseCalloutTag","undefined","headingMarkdown","badge","headingText","proseBodyMarkdown","exports"],"sources":["../../../../src/component/componentDefinitions/HeroSectionDefinition.ts"],"sourcesContent":["import {\n headingText,\n headingMarkdown,\n proseBodyMarkdown,\n firstImageSrc,\n parseCalloutTag,\n extractListItemText,\n standaloneLinks,\n} from './parse-utils';\nimport type { Part, ListPart, LinkPart, ListItemPart } from '../../parts/parts';\nimport { getPartsByType } from '../../parts/parts';\nimport type {\n HeroButton,\n HeroCompProps,\n HeroSectionComponent,\n SectionFixture,\n} from '../types';\nimport type { SectionDefinition } from '../section-definition';\n\nexport class HeroSectionDefinition\n implements SectionDefinition<HeroSectionComponent>\n{\n sectionType = 'hero' as const;\n singleInstance = true;\n patterns = [\n // Canonical hero shape: section descriptor, then the leading ECHO callout\n // (optional in the grammar — the orchestrator always emits it, but a missing\n // ECHO must not stop the hero from rendering), then an optional h3 badge,\n // then the h1. The callout and badge are independent slots so a hero can\n // carry both. The second `html_comment?` keeps the legacy ordering\n // (callout before the descriptor) matching for pages saved before this change.\n 'html_comment? > callout? > html_comment? > h3? > h1 > (image | t | link)* > list?',\n ];\n\n defaults: HeroCompProps = {\n headline: 'Build something amazing',\n content: 'Your platform for data-driven decisions.',\n buttons: [{ id: 'btn-0', text: 'Get started', variant: 'primary' }],\n };\n\n fixtures: SectionFixture<HeroCompProps>[] = [\n {\n markdown:\n '# Welcome\\n\\nBuild amazing things.\\n\\n[Get Started](/) [Learn More](/about)',\n expected: {\n headline: 'Welcome',\n content: 'Build amazing things.',\n buttons: [\n {\n id: 'btn-0',\n text: 'Get Started',\n variant: 'primary',\n onClick: '/',\n },\n {\n id: 'btn-1',\n text: 'Learn More',\n variant: 'secondary',\n onClick: '/about',\n },\n ],\n },\n },\n {\n markdown: `<!-- Hero Section -->\n\n# Welcome to Our Platform\n\n![Hero Image](hero.jpg)\n\nGet started today with our amazing features.\n\n[Get Started](/signup) [Learn More](/about)`,\n expected: {\n headline: 'Welcome to Our Platform',\n content: 'Get started today with our amazing features.',\n buttons: [\n {\n id: 'btn-0',\n text: 'Get Started',\n variant: 'primary',\n onClick: '/signup',\n },\n {\n id: 'btn-1',\n text: 'Learn More',\n variant: 'secondary',\n onClick: '/about',\n },\n ],\n image: 'hero.jpg',\n },\n },\n ];\n\n parse(parts: Part[]): HeroCompProps {\n let image = firstImageSrc(parts);\n const lists = getPartsByType<ListPart>(parts, 'list');\n\n if (!image) {\n for (const list of lists) {\n for (const item of list.meta?.items ?? []) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const nestedImage = firstImageSrc(itemParts);\n if (nestedImage) {\n image = nestedImage;\n break;\n }\n }\n if (image) {\n break;\n }\n }\n }\n\n // Start with the hero's own button row. NOT every top-level link: a link\n // inside a prose paragraph is a top-level part too, so `getLinks` handed\n // `Email support@shop.example` the `btn-0` / primary slot and pushed the\n // real call to action down to secondary. `standaloneLinks` keeps only a\n // link that stands alone as its own block, which is the row the hero means.\n let buttonIndex = 0;\n const buttons: HeroButton[] = standaloneLinks(parts).map(\n (l, i): HeroButton => ({\n id: `btn-${i}`,\n text: l.content?.trim() || 'Learn more',\n variant: i === 0 ? 'primary' : 'secondary',\n onClick: l.meta.href,\n }),\n );\n buttonIndex = buttons.length;\n\n // Process lists: filter out image-only items, then check if remaining\n // items are all link-only. If so, convert to buttons; otherwise keep as trailingList.\n let trailingList: string | undefined;\n if (lists.length > 0) {\n for (const list of lists) {\n // Filter out image-only items\n const filteredItems: ListItemPart[] = [];\n for (const item of list.meta?.items ?? []) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const hasImage = itemParts.some((p) => p.type === 'image');\n if (hasImage) {\n continue;\n }\n filteredItems.push(item);\n }\n\n if (filteredItems.length === 0) {\n continue;\n }\n\n // Check if ALL remaining items contain only links (no other text)\n let allItemsAreLinks = true;\n const listLinks: { text: string; href: string }[] = [];\n\n for (const item of filteredItems) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const itemLinkParts = itemParts.filter(\n (p): p is LinkPart => p.type === 'link',\n );\n\n if (itemLinkParts.length === 0) {\n allItemsAreLinks = false;\n break;\n }\n\n // Check if the item text is entirely link text (no extra content)\n const allText = extractListItemText(item).trim();\n const linkTexts = itemLinkParts\n .map((l) => l.content?.trim() || '')\n .join(' ')\n .trim();\n\n if (allText !== linkTexts) {\n allItemsAreLinks = false;\n break;\n }\n\n listLinks.push({\n text: itemLinkParts[0].content?.trim() || 'Learn more',\n href: itemLinkParts[0].meta.href,\n });\n }\n\n if (allItemsAreLinks && listLinks.length > 0) {\n // Convert link-only list items to buttons\n for (const link of listLinks) {\n const isFirstButton = buttons.length === 0;\n buttons.push({\n id: `btn-${buttonIndex++}`,\n text: link.text,\n variant: isFirstButton ? 'primary' : 'secondary',\n onClick: link.href,\n });\n }\n } else {\n // Keep as trailing list markdown\n const lines: string[] = [];\n for (const item of filteredItems) {\n const text =\n (item.meta?.markdown as string) || extractListItemText(item);\n if (text) {\n lines.push(`- ${text}`);\n }\n }\n if (lines.length > 0) {\n trailingList = lines.join('\\n');\n }\n }\n }\n }\n\n // The hero claims the leading callout before the h1 — the ECHO the\n // orchestrator emits as the hero's opening line, right after the section\n // descriptor. A trailing blockquote is not part of the hero pattern, so it\n // falls through to a downstream callout section instead.\n const h1Index = parts.findIndex(\n (p) => p.type === 'heading' && (p.meta as { level: number })?.level === 1,\n );\n const blockquotes = getPartsByType<Part>(parts, 'callout');\n let leadingQuote: string | undefined;\n\n for (const bq of blockquotes) {\n const bqIndex = parts.indexOf(bq);\n if (h1Index >= 0 && bqIndex > h1Index) {\n continue;\n }\n const raw = (bq.meta?.markdown as string)?.trim() || bq.content?.trim();\n if (!raw) {\n continue;\n }\n leadingQuote = parseCalloutTag(raw).text || undefined;\n }\n\n return {\n // Markdown-preserving (not headingText): the hero title now carries the\n // bold+italic hook the ECHO callout used to own, so the FE needs the\n // formatting, not just the plain text. See FeatureComparisonHero.tsx.\n headline: headingMarkdown(parts, 1),\n badge: headingText(parts, 3) || undefined,\n content: proseBodyMarkdown(parts) || undefined,\n buttons: buttons.length > 0 ? buttons : undefined,\n image,\n trailingList,\n leadingQuote,\n };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAUA,IAAAC,MAAA,GAAAD,OAAA;AASO,MAAME,qBAAqB,CAElC;EAAAC,YAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,uBACgB,MAAM;IAAA,IAAAD,gBAAA,CAAAC,OAAA,0BACH,IAAI;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBACV;IACT;IACA;IACA;IACA;IACA;IACA;IACA,mFAAmF,CACpF;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBAEyB;MACxBC,QAAQ,EAAE,yBAAyB;MACnCC,OAAO,EAAE,0CAA0C;MACnDC,OAAO,EAAE,CAAC;QAAEC,EAAE,EAAE,OAAO;QAAEC,IAAI,EAAE,aAAa;QAAEC,OAAO,EAAE;MAAU,CAAC;IACpE,CAAC;IAAA,IAAAP,gBAAA,CAAAC,OAAA,oBAE2C,CAC1C;MACEO,QAAQ,EACN,6EAA6E;MAC/EC,QAAQ,EAAE;QACRP,QAAQ,EAAE,SAAS;QACnBC,OAAO,EAAE,uBAAuB;QAChCC,OAAO,EAAE,CACP;UACEC,EAAE,EAAE,OAAO;UACXC,IAAI,EAAE,aAAa;UACnBC,OAAO,EAAE,SAAS;UAClBG,OAAO,EAAE;QACX,CAAC,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CAACuD,OAAO,CAACJ,EAAE,CAAC;MACjC,IAAIN,OAAO,IAAI,CAAC,IAAIS,OAAO,GAAGT,OAAO,EAAE;QACrC;MACF;MACA,MAAMW,GAAG,GAAG,EAAAJ,QAAA,GAACD,EAAE,CAAC5C,IAAI,cAAA6C,QAAA,GAAPA,QAAA,CAASzD,QAAQ,qBAAlByD,QAAA,CAA+BlC,IAAI,CAAC,CAAC,OAAAmC,WAAA,GAAIF,EAAE,CAAC7D,OAAO,qBAAV+D,WAAA,CAAYnC,IAAI,CAAC,CAAC;MACvE,IAAI,CAACsC,GAAG,EAAE;QACR;MACF;MACAN,YAAY,GAAG,IAAAO,2BAAe,EAACD,GAAG,CAAC,CAAC/D,IAAI,IAAIiE,SAAS;IACvD;IAEA,OAAO;MACL;MACA;MACA;MACArE,QAAQ,EAAE,IAAAsE,2BAAe,EAAC3D,KAAK,EAAE,CAAC,CAAC;MACnC4D,KAAK,EAAE,IAAAC,uBAAW,EAAC7D,KAAK,EAAE,CAAC,CAAC,IAAI0D,SAAS;MACzCpE,OAAO,EAAE,IAAAwE,6BAAiB,EAAC9D,KAAK,CAAC,IAAI0D,SAAS;MAC9CnE,OAAO,EAAEA,OAAO,CAAC6B,MAAM,GAAG,CAAC,GAAG7B,OAAO,GAAGmE,SAAS;MACjD5D,KAAK;MACLuB,YAAY;MACZ6B;IACF,CAAC;EACH;AACF;AAACa,OAAA,CAAA9E,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -41,8 +41,23 @@ class NextStepsSectionDefinition {
41
41
  constructor() {
42
42
  (0, _defineProperty2.default)(this, "sectionType", 'nextSteps');
43
43
  (0, _defineProperty2.default)(this, "patterns", [
44
- // Framing sentence (`t?`) then one chip per bullet — the authored shape.
45
- '(html_comment[section^="next"] | html_comment[semantic^="next"]) > h2 > image? > t? > list{item[1-]:(icon | t)* > (t? > link)+}',
44
+ // Framing sentence then one chip per bullet — the authored shape. The
45
+ // framing slot is `(t | link)*`, not `t?`, because a paragraph is unwrapped
46
+ // into its inline nodes: `Questions? Email support@shop.example for help.`
47
+ // arrives as `t link t` (GFM autolinks a bare email) and so does an
48
+ // authored `[men's shoes](web5://ask/…)`. With `t?` the run ended at that
49
+ // `link`, this pattern failed, and the legacy pattern below claimed the
50
+ // section instead — turning the prose link into a chip and stranding the
51
+ // real chip list in the fallback as raw bullets.
52
+ //
53
+ // This does NOT steal the legacy pattern's inputs: the `list` here is
54
+ // mandatory, so a section with chips in the prose and no list still falls
55
+ // through. It does change one rare shape — prose that is nothing but links
56
+ // ALONGSIDE a chip list now matches here, and `proseBodyMarkdown` drops
57
+ // link-only paragraphs, so those links are dropped rather than rendered
58
+ // inline. That shape previously stranded the list entirely, so neither
59
+ // outcome was whole; this one at least renders the authored chips.
60
+ '(html_comment[section^="next"] | html_comment[semantic^="next"]) > h2 > image? > (t | link)* > list{item[1-]:(icon | t)* > (t? > link)+}',
46
61
  // Legacy inline shape: chips embedded in the prose. Still arrives from
47
62
  // sites whose next-steps prompt has not moved to the list shape.
48
63
  '(html_comment[section^="next"] | html_comment[semantic^="next"]) > h2 > image? > (t | link)+']);
@@ -1 +1 @@
1
- {"version":3,"names":["_parseUtils","require","_parts","linkToMarkdown","link","_link$content","_link$meta","content","trim","meta","href","appendInlineToken","current","token","trimmed","test","inlineBodyMarkdown","parts","body","reduce","part","type","_part$meta","markdown","undefined","NextStepsSectionDefinition","constructor","_defineProperty2","default","title","backgroundImage","steps","expected","parse","headingText","firstImageSrc","chipsInlineInBody","lists","getPartsByType","length","proseBodyMarkdown","list","item","_list$meta","items","_item$meta","_iconPart$meta","itemParts","iconPart","find","p","iconHint","contentFragments","push","_p$content","filter","Boolean","join","extractListItemText","links","getLinks","_link$content2","_link$meta2","text","exports"],"sources":["../../../../src/component/componentDefinitions/NextStepsSectionDefinition.ts"],"sourcesContent":["import {\n headingText,\n proseBodyMarkdown,\n extractListItemText,\n firstImageSrc,\n} from './parse-utils';\nimport {\n getPartsByType,\n getLinks,\n type Part,\n type ListPart,\n type LinkPart,\n type IconPart,\n} from '../../parts/parts';\nimport type {\n NextStepsCompProps,\n NextStepsSectionComponent,\n SectionFixture,\n} from '../types';\nimport type { SectionDefinition } from '../section-definition';\n\nfunction linkToMarkdown(link: LinkPart): string {\n return `[${link.content?.trim() || ''}](${link.meta?.href || ''})`;\n}\n\nfunction appendInlineToken(current: string, token: string): string {\n const trimmed = token.trim();\n if (!trimmed) {\n return current;\n }\n if (!current) {\n return trimmed;\n }\n if (/^[,.;:!?)]/.test(trimmed)) {\n return `${current}${trimmed}`;\n }\n return `${current} ${trimmed}`;\n}\n\nfunction inlineBodyMarkdown(parts: Part[]): string | undefined {\n const body = parts.reduce((current, part) => {\n if (part.type === 'link') {\n return appendInlineToken(current, linkToMarkdown(part as LinkPart));\n }\n if (part.type === 'text' || part.type === 'richText') {\n const markdown = (part.meta?.markdown as string | undefined)?.trim();\n return appendInlineToken(current, markdown || part.content || '');\n }\n return current;\n }, '');\n\n return body || undefined;\n}\n\nexport class NextStepsSectionDefinition\n implements SectionDefinition<NextStepsSectionComponent>\n{\n sectionType = 'nextSteps' as const;\n patterns = [\n // Framing sentence (`t?`) then one chip per bullet — the authored shape.\n '(html_comment[section^=\"next\"] | html_comment[semantic^=\"next\"]) > h2 > image? > t? > list{item[1-]:(icon | t)* > (t? > link)+}',\n // Legacy inline shape: chips embedded in the prose. Still arrives from\n // sites whose next-steps prompt has not moved to the list shape.\n '(html_comment[section^=\"next\"] | html_comment[semantic^=\"next\"]) > h2 > image? > (t | link)+',\n ];\n\n defaults: NextStepsCompProps = {\n title: 'Next Steps',\n body: 'Where would you like to go next?',\n backgroundImage: undefined,\n steps: [{ content: '[Get started](/start)' }],\n };\n\n fixtures: SectionFixture<NextStepsCompProps>[] = [\n {\n markdown: `<!-- section:next-steps, semantic:next_steps -->\n\n## Find the right care for mature, sensitive skin\n\nWant to focus on rich hydrators and barrier builders?\n\n- [hydrating creams →](web5://ask/hydrating+creams+for+mature+skin)\n- [gentle resurfacing serums →](web5://ask/gentle+resurfacing+serums)`,\n expected: {\n title: 'Find the right care for mature, sensitive skin',\n body: 'Want to focus on rich hydrators and barrier builders?',\n steps: [\n {\n content:\n '[hydrating creams →](web5://ask/hydrating+creams+for+mature+skin)',\n },\n {\n content:\n '[gentle resurfacing serums →](web5://ask/gentle+resurfacing+serums)',\n },\n ],\n },\n },\n {\n markdown: `<!-- section: next_steps -->\n\n## Next Steps\n\n- Check out [Documentation](/docs)\n- Try [Examples](/examples)`,\n expected: {\n title: 'Next Steps',\n steps: [\n { content: 'Check out [Documentation](/docs)' },\n { content: 'Try [Examples](/examples)' },\n ],\n },\n },\n ];\n\n parse(parts: Part[]): NextStepsCompProps {\n const title = headingText(parts, 2) || 'Next Steps';\n const backgroundImage = firstImageSrc(parts);\n const steps: { content: string; iconHint?: string }[] = [];\n let body: string | undefined;\n let chipsInlineInBody = false;\n\n // Try list-based pattern first\n const lists = getPartsByType<ListPart>(parts, 'list');\n if (lists.length > 0) {\n // The framing sentence is the only top-level prose — list items live\n // under each list's meta.items, so this never picks up a chip.\n body = proseBodyMarkdown(parts) || undefined;\n\n for (const list of lists) {\n for (const item of list.meta?.items ?? []) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n\n const iconPart = itemParts.find((p) => p.type === 'icon') as\n | IconPart\n | undefined;\n const iconHint = (iconPart?.meta as { iconHint?: string })?.iconHint;\n\n const contentFragments: string[] = [];\n for (const p of itemParts) {\n if (p.type === 'link') {\n const link = p as LinkPart;\n contentFragments.push(linkToMarkdown(link));\n } else if (p.type === 'text' || p.type === 'richText') {\n contentFragments.push(p.content?.trim() || '');\n }\n }\n const content =\n contentFragments.filter(Boolean).join(' ') ||\n extractListItemText(item);\n if (content.trim()) {\n steps.push({\n content: content.trim(),\n ...(iconHint ? { iconHint } : {}),\n });\n }\n }\n }\n } else {\n body = inlineBodyMarkdown(parts);\n // body carries the chips as inline links — flag it so renderers show the\n // prose alone instead of repeating every chip as a row beneath it.\n chipsInlineInBody = Boolean(body);\n }\n\n // Fallback: inline links pattern\n if (steps.length === 0) {\n const links = getLinks(parts);\n for (const link of links) {\n const text = link.content?.trim();\n const href = link.meta?.href;\n if (text && href) {\n steps.push({ content: linkToMarkdown(link) });\n }\n }\n }\n\n return {\n title,\n ...(body ? { body } : {}),\n ...(chipsInlineInBody ? { chipsInlineInBody } : {}),\n ...(backgroundImage ? { backgroundImage } : {}),\n steps,\n };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AAeA,SAASE,cAAcA,CAACC,IAAc,EAAU;EAAA,IAAAC,aAAA,EAAAC,UAAA;EAC9C,OAAO,IAAI,EAAAD,aAAA,GAAAD,IAAI,CAACG,OAAO,qBAAZF,aAAA,CAAcG,IAAI,CAAC,CAAC,KAAI,EAAE,KAAK,EAAAF,UAAA,GAAAF,IAAI,CAACK,IAAI,qBAATH,UAAA,CAAWI,IAAI,KAAI,EAAE,GAAG;AACpE;AAEA,SAASC,iBAAiBA,CAACC,OAAe,EAAEC,KAAa,EAAU;EACjE,MAAMC,OAAO,GAAGD,KAAK,CAACL,IAAI,CAAC,CAAC;EAC5B,IAAI,CAACM,OAAO,EAAE;IACZ,OAAOF,OAAO;EAChB;EACA,IAAI,CAACA,OAAO,EAAE;IACZ,OAAOE,OAAO;EAChB;EACA,IAAI,YAAY,CAACC,IAAI,CAACD,OAAO,CAAC,EAAE;IAC9B,OAAO,GAAGF,OAAO,GAAGE,OAAO,EAAE;EAC/B;EACA,OAAO,GAAGF,OAAO,IAAIE,OAAO,EAAE;AAChC;AAEA,SAASE,kBAAkBA,CAACC,KAAa,EAAsB;EAC7D,MAAMC,IAAI,GAAGD,KAAK,CAACE,MAAM,CAAC,CAACP,OAAO,EAAEQ,IAAI,KAAK;IAC3C,IAAIA,IAAI,CAACC,IAAI,KAAK,MAAM,EAAE;MACxB,OAAOV,iBAAiB,CAACC,OAAO,EAAET,cAAc,CAACiB,IAAgB,CAA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,CAACK,IAAI,qBAATqD,WAAA,CAAWpD,IAAI;QAC5B,IAAIqD,IAAI,IAAIrD,IAAI,EAAE;UAChBqB,KAAK,CAACsB,IAAI,CAAC;YAAE9C,OAAO,EAAEJ,cAAc,CAACC,IAAI;UAAE,CAAC,CAAC;QAC/C;MACF;IACF;IAEA,OAAO;MACLyB,KAAK;MACL,IAAIX,IAAI,GAAG;QAAEA;MAAK,CAAC,GAAG,CAAC,CAAC,CAAC;MACzB,IAAIkB,iBAAiB,GAAG;QAAEA;MAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;MACnD,IAAIN,eAAe,GAAG;QAAEA;MAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;MAC/CC;IACF,CAAC;EACH;AACF;AAACiC,OAAA,CAAAvC,0BAAA,GAAAA,0BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_parseUtils","require","_parts","linkToMarkdown","link","_link$content","_link$meta","content","trim","meta","href","appendInlineToken","current","token","trimmed","test","inlineBodyMarkdown","parts","body","reduce","part","type","_part$meta","markdown","undefined","NextStepsSectionDefinition","constructor","_defineProperty2","default","title","backgroundImage","steps","expected","parse","headingText","firstImageSrc","chipsInlineInBody","lists","getPartsByType","length","proseBodyMarkdown","list","item","_list$meta","items","_item$meta","_iconPart$meta","itemParts","iconPart","find","p","iconHint","contentFragments","push","_p$content","filter","Boolean","join","extractListItemText","links","getLinks","_link$content2","_link$meta2","text","exports"],"sources":["../../../../src/component/componentDefinitions/NextStepsSectionDefinition.ts"],"sourcesContent":["import {\n headingText,\n proseBodyMarkdown,\n extractListItemText,\n firstImageSrc,\n} from './parse-utils';\nimport {\n getPartsByType,\n getLinks,\n type Part,\n type ListPart,\n type LinkPart,\n type IconPart,\n} from '../../parts/parts';\nimport type {\n NextStepsCompProps,\n NextStepsSectionComponent,\n SectionFixture,\n} from '../types';\nimport type { SectionDefinition } from '../section-definition';\n\nfunction linkToMarkdown(link: LinkPart): string {\n return `[${link.content?.trim() || ''}](${link.meta?.href || ''})`;\n}\n\nfunction appendInlineToken(current: string, token: string): string {\n const trimmed = token.trim();\n if (!trimmed) {\n return current;\n }\n if (!current) {\n return trimmed;\n }\n if (/^[,.;:!?)]/.test(trimmed)) {\n return `${current}${trimmed}`;\n }\n return `${current} ${trimmed}`;\n}\n\nfunction inlineBodyMarkdown(parts: Part[]): string | undefined {\n const body = parts.reduce((current, part) => {\n if (part.type === 'link') {\n return appendInlineToken(current, linkToMarkdown(part as LinkPart));\n }\n if (part.type === 'text' || part.type === 'richText') {\n const markdown = (part.meta?.markdown as string | undefined)?.trim();\n return appendInlineToken(current, markdown || part.content || '');\n }\n return current;\n }, '');\n\n return body || undefined;\n}\n\nexport class NextStepsSectionDefinition\n implements SectionDefinition<NextStepsSectionComponent>\n{\n sectionType = 'nextSteps' as const;\n patterns = [\n // Framing sentence then one chip per bullet — the authored shape. The\n // framing slot is `(t | link)*`, not `t?`, because a paragraph is unwrapped\n // into its inline nodes: `Questions? Email support@shop.example for help.`\n // arrives as `t link t` (GFM autolinks a bare email) and so does an\n // authored `[men's shoes](web5://ask/…)`. With `t?` the run ended at that\n // `link`, this pattern failed, and the legacy pattern below claimed the\n // section instead — turning the prose link into a chip and stranding the\n // real chip list in the fallback as raw bullets.\n //\n // This does NOT steal the legacy pattern's inputs: the `list` here is\n // mandatory, so a section with chips in the prose and no list still falls\n // through. It does change one rare shape — prose that is nothing but links\n // ALONGSIDE a chip list now matches here, and `proseBodyMarkdown` drops\n // link-only paragraphs, so those links are dropped rather than rendered\n // inline. That shape previously stranded the list entirely, so neither\n // outcome was whole; this one at least renders the authored chips.\n '(html_comment[section^=\"next\"] | html_comment[semantic^=\"next\"]) > h2 > image? > (t | link)* > list{item[1-]:(icon | t)* > (t? > link)+}',\n // Legacy inline shape: chips embedded in the prose. Still arrives from\n // sites whose next-steps prompt has not moved to the list shape.\n '(html_comment[section^=\"next\"] | html_comment[semantic^=\"next\"]) > h2 > image? > (t | link)+',\n ];\n\n defaults: NextStepsCompProps = {\n title: 'Next Steps',\n body: 'Where would you like to go next?',\n backgroundImage: undefined,\n steps: [{ content: '[Get started](/start)' }],\n };\n\n fixtures: SectionFixture<NextStepsCompProps>[] = [\n {\n markdown: `<!-- section:next-steps, semantic:next_steps -->\n\n## Find the right care for mature, sensitive skin\n\nWant to focus on rich hydrators and barrier builders?\n\n- [hydrating creams →](web5://ask/hydrating+creams+for+mature+skin)\n- [gentle resurfacing serums →](web5://ask/gentle+resurfacing+serums)`,\n expected: {\n title: 'Find the right care for mature, sensitive skin',\n body: 'Want to focus on rich hydrators and barrier builders?',\n steps: [\n {\n content:\n '[hydrating creams →](web5://ask/hydrating+creams+for+mature+skin)',\n },\n {\n content:\n '[gentle resurfacing serums →](web5://ask/gentle+resurfacing+serums)',\n },\n ],\n },\n },\n {\n markdown: `<!-- section: next_steps -->\n\n## Next Steps\n\n- Check out [Documentation](/docs)\n- Try [Examples](/examples)`,\n expected: {\n title: 'Next Steps',\n steps: [\n { content: 'Check out [Documentation](/docs)' },\n { content: 'Try [Examples](/examples)' },\n ],\n },\n },\n ];\n\n parse(parts: Part[]): NextStepsCompProps {\n const title = headingText(parts, 2) || 'Next Steps';\n const backgroundImage = firstImageSrc(parts);\n const steps: { content: string; iconHint?: string }[] = [];\n let body: string | undefined;\n let chipsInlineInBody = false;\n\n // Try list-based pattern first\n const lists = getPartsByType<ListPart>(parts, 'list');\n if (lists.length > 0) {\n // The framing sentence is the only top-level prose — list items live\n // under each list's meta.items, so this never picks up a chip.\n body = proseBodyMarkdown(parts) || undefined;\n\n for (const list of lists) {\n for (const item of list.meta?.items ?? []) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n\n const iconPart = itemParts.find((p) => p.type === 'icon') as\n | IconPart\n | undefined;\n const iconHint = (iconPart?.meta as { iconHint?: string })?.iconHint;\n\n const contentFragments: string[] = [];\n for (const p of itemParts) {\n if (p.type === 'link') {\n const link = p as LinkPart;\n contentFragments.push(linkToMarkdown(link));\n } else if (p.type === 'text' || p.type === 'richText') {\n contentFragments.push(p.content?.trim() || '');\n }\n }\n const content =\n contentFragments.filter(Boolean).join(' ') ||\n extractListItemText(item);\n if (content.trim()) {\n steps.push({\n content: content.trim(),\n ...(iconHint ? { iconHint } : {}),\n });\n }\n }\n }\n } else {\n body = inlineBodyMarkdown(parts);\n // body carries the chips as inline links — flag it so renderers show the\n // prose alone instead of repeating every chip as a row beneath it.\n chipsInlineInBody = Boolean(body);\n }\n\n // Fallback: inline links pattern\n if (steps.length === 0) {\n const links = getLinks(parts);\n for (const link of links) {\n const text = link.content?.trim();\n const href = link.meta?.href;\n if (text && href) {\n steps.push({ content: linkToMarkdown(link) });\n }\n }\n }\n\n return {\n title,\n ...(body ? { body } : {}),\n ...(chipsInlineInBody ? { chipsInlineInBody } : {}),\n ...(backgroundImage ? { backgroundImage } : {}),\n steps,\n };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AAeA,SAASE,cAAcA,CAACC,IAAc,EAAU;EAAA,IAAAC,aAAA,EAAAC,UAAA;EAC9C,OAAO,IAAI,EAAAD,aAAA,GAAAD,IAAI,CAACG,OAAO,qBAAZF,aAAA,CAAcG,IAAI,CAAC,CAAC,KAAI,EAAE,KAAK,EAAAF,UAAA,GAAAF,IAAI,CAACK,IAAI,qBAATH,UAAA,CAAWI,IAAI,KAAI,EAAE,GAAG;AACpE;AAEA,SAASC,iBAAiBA,CAACC,OAAe,EAAEC,KAAa,EAAU;EACjE,MAAMC,OAAO,GAAGD,KAAK,CAACL,IAAI,CAAC,CAAC;EAC5B,IAAI,CAACM,OAAO,EAAE;IACZ,OAAOF,OAAO;EAChB;EACA,IAAI,CAACA,OAAO,EAAE;IACZ,OAAOE,OAAO;EAChB;EACA,IAAI,YAAY,CAACC,IAAI,CAACD,OAAO,CAAC,EAAE;IAC9B,OAAO,GAAGF,OAAO,GAAGE,OAAO,EAAE;EAC/B;EACA,OAAO,GAAGF,OAAO,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;IACA,IAAIa,KAAK,CAACQ,MAAM,KAAK,CAAC,EAAE;MACtB,MAAMoB,KAAK,GAAG,IAAAC,eAAQ,EAAC3C,KAAK,CAAC;MAC7B,KAAK,MAAMb,IAAI,IAAIuD,KAAK,EAAE;QAAA,IAAAE,cAAA,EAAAC,WAAA;QACxB,MAAMC,IAAI,IAAAF,cAAA,GAAGzD,IAAI,CAACG,OAAO,qBAAZsD,cAAA,CAAcrD,IAAI,CAAC,CAAC;QACjC,MAAME,IAAI,IAAAoD,WAAA,GAAG1D,IAAI,CAACK,IAAI,qBAATqD,WAAA,CAAWpD,IAAI;QAC5B,IAAIqD,IAAI,IAAIrD,IAAI,EAAE;UAChBqB,KAAK,CAACsB,IAAI,CAAC;YAAE9C,OAAO,EAAEJ,cAAc,CAACC,IAAI;UAAE,CAAC,CAAC;QAC/C;MACF;IACF;IAEA,OAAO;MACLyB,KAAK;MACL,IAAIX,IAAI,GAAG;QAAEA;MAAK,CAAC,GAAG,CAAC,CAAC,CAAC;MACzB,IAAIkB,iBAAiB,GAAG;QAAEA;MAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;MACnD,IAAIN,eAAe,GAAG;QAAEA;MAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;MAC/CC;IACF,CAAC;EACH;AACF;AAACiC,OAAA,CAAAvC,0BAAA,GAAAA,0BAAA","ignoreList":[]}
@@ -22,6 +22,7 @@ exports.parseKpiItem = parseKpiItem;
22
22
  exports.parseTableValue = parseTableValue;
23
23
  exports.partsToMarkdown = partsToMarkdown;
24
24
  exports.proseBodyMarkdown = proseBodyMarkdown;
25
+ exports.standaloneLinks = standaloneLinks;
25
26
  exports.stripMarkdown = stripMarkdown;
26
27
  var _parts = require("../../parts/parts");
27
28
  var _entityLinkParser = require("../../utils/entityLinkParser");
@@ -85,6 +86,37 @@ function inlineParagraphs(parts) {
85
86
  }
86
87
  return paragraphs;
87
88
  }
89
+
90
+ /**
91
+ * A paragraph that is nothing but links — the hero's button row under the h1,
92
+ * the CTA after a comparison table. This is the one shape a section is entitled
93
+ * to spend on a control instead of printing as copy, and its complement — a
94
+ * link sharing its paragraph with a sentence — is body copy and nothing else.
95
+ *
96
+ * A blank part does not disqualify it. A hard line break between two links
97
+ * (`[A](/a)··\n[B](/b)`) leaves an empty `t` part behind, and an empty part is
98
+ * not a sentence; without this the row is BOTH a button and a line of body
99
+ * copy, which is the duplication the rule exists to prevent.
100
+ */
101
+ function isLinkRow(paragraph) {
102
+ return paragraph.some(part => part.type === 'link') && paragraph.every(part => part.type === 'link' || markdownOrText(part) === '');
103
+ }
104
+
105
+ /**
106
+ * The links a section is entitled to render as its own control — a hero button
107
+ * row, a CTA — as opposed to a link that is part of a sentence.
108
+ *
109
+ * The exact complement of what {@link proseBodyMarkdown} keeps, and that is the
110
+ * point: between the two, every top-level link reaches the page exactly once.
111
+ * `getLinks` is the wrong tool for a control slot — it takes EVERY top-level
112
+ * link part, and a link inside a prose paragraph is a top-level part, so
113
+ * `Email support@shop.example` (GFM autolinks a bare address, no author needed)
114
+ * arrived as the hero's first and therefore PRIMARY button, displacing the real
115
+ * call to action into the secondary slot and printing the address twice.
116
+ */
117
+ function standaloneLinks(parts) {
118
+ return inlineParagraphs(parts).filter(isLinkRow).flat().filter(part => part.type === 'link');
119
+ }
88
120
  function paragraphsToMarkdown(paragraphs) {
89
121
  return paragraphs.map(inlinePartsToMarkdown).map(paragraph => paragraph.trim()).filter(Boolean).join('\n\n');
90
122
  }
@@ -110,16 +142,17 @@ function paragraphsToMarkdown(paragraphs) {
110
142
  * wrong for a section that already spends its links elsewhere — see
111
143
  * {@link proseBodyMarkdown}.
112
144
  *
113
- * Kept separate from `bodyText` deliberately, but not for the reason this
114
- * comment used to give. Of the four callers still on `bodyText`:
115
- * `ErrorSectionDefinition` and `CtaBannerSectionDefinition` do hand their
116
- * result to a consumer that renders it raw (`ErrorSection` prints the copy in
117
- * a `<p>`, `CtaBannerSection` the same), so markdown there would show a
118
- * visitor a literal `[label](url)`. `FeatureCardsSectionDefinition` does NOT
119
- * both `FeatureCardsSection` renderers in this repo put `card.description`
120
- * through `MarkdownText`, so it loses inline links exactly like the sections
121
- * fixed here; it is left alone only because its callers were not verified end
122
- * to end. `FeatureSection9PlusDefinition` has no registered renderer at all.
145
+ * Kept separate from `bodyText` deliberately. Of the three callers still on
146
+ * `bodyText`: `ErrorSectionDefinition` and `CtaBannerSectionDefinition` do
147
+ * hand their result to a consumer that renders it raw (`ErrorSection` prints
148
+ * the copy in a `<p>`, `CtaBannerSection` the same), so markdown there would
149
+ * show a visitor a literal `[label](url)`. `FeatureSection9PlusDefinition` is
150
+ * the odd one out: it has no registered renderer in either client bundle
151
+ * (`createSdkRegistry` registers the definition with no component, and only
152
+ * `createTestRegistry` gives it a stub), so its `description` reaches nothing
153
+ * and there is no consumer to decide against. `FeatureCardsSectionDefinition`
154
+ * used to be listed here as affected-but-unfixed; it now uses
155
+ * {@link proseBodyMarkdown}.
123
156
  */
124
157
  function bodyMarkdown(parts) {
125
158
  return paragraphsToMarkdown(inlineParagraphs(parts));
@@ -133,11 +166,14 @@ function bodyMarkdown(parts) {
133
166
  * sentence survives instead of being deleted with its label — but it drops the
134
167
  * two shapes those sections have already claimed, so nothing renders twice:
135
168
  *
136
- * - A paragraph that is nothing but links. `[Get started](/) [Learn more](/x)`
137
- * under a hero h1 is the button row `HeroSectionDefinition` turns into
138
- * `buttons`; the trailing link after a comparison table is its `ctaText` /
139
- * `ctaHref`. Whole-paragraph is the right test because a link that is part
140
- * of a sentence always shares its paragraph with the text around it.
169
+ * - A paragraph that is nothing but links {@link isLinkRow}.
170
+ * `[Get started](/) [Learn more](/x)` under a hero h1 is the button row
171
+ * `HeroSectionDefinition` turns into `buttons`; the trailing link after a
172
+ * comparison table is its `ctaText` / `ctaHref`. Whole-paragraph is the right
173
+ * test because a link that is part of a sentence always shares its paragraph
174
+ * with the text around it. `HeroSectionDefinition` reads the same predicate
175
+ * from the other side via {@link standaloneLinks}, so the two partition the
176
+ * links rather than each deciding for itself.
141
177
  * - Everything from the first `web5://entity/…` link onward, which is item
142
178
  * copy rather than section copy — `HeroEntitySectionDefinition` reads those
143
179
  * links (and the text after each) into `items`. Same cut
@@ -152,7 +188,7 @@ function proseBodyMarkdown(parts) {
152
188
  return p.type === 'link' && isEntityHref((_meta = p.meta) == null ? void 0 : _meta.href);
153
189
  });
154
190
  const sectionParts = firstEntityLinkIndex >= 0 ? parts.slice(0, firstEntityLinkIndex) : parts;
155
- return paragraphsToMarkdown(inlineParagraphs(sectionParts).filter(paragraph => !paragraph.every(part => part.type === 'link')));
191
+ return paragraphsToMarkdown(inlineParagraphs(sectionParts).filter(paragraph => !isLinkRow(paragraph)));
156
192
  }
157
193
 
158
194
  /**
@@ -170,9 +206,16 @@ function entitySectionBodyText(parts) {
170
206
  return sectionParts.filter(p => p.type === 'text' || p.type === 'richText').map(markdownOrText).filter(Boolean).join('\n\n');
171
207
  }
172
208
 
173
- /** Build HeroButton[] from link parts — aligned to HeroSection1Button shape */
209
+ /**
210
+ * Build HeroButton[] from link parts — aligned to HeroSection1Button shape.
211
+ *
212
+ * `standaloneLinks`, not `getLinks`, for the reason spelled out there: a link
213
+ * in a sentence is body copy, not a button. Currently uncalled — kept on the
214
+ * same rule as `HeroSectionDefinition` so wiring it up cannot reintroduce the
215
+ * bug.
216
+ */
174
217
  function linksToHeroButtons(parts) {
175
- let links = (0, _parts.getLinks)(parts);
218
+ let links = standaloneLinks(parts);
176
219
  if (!links.length) {
177
220
  const lists = (0, _parts.getPartsByType)(parts, 'list');
178
221
  links = lists.flatMap(l => {