MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / parseColWidthsComment

Function parseColWidthsComment

packages/app-core/src/lib/markdown-table.ts:227–236  ·  view source on GitHub ↗
(line: string)

Source from the content-addressed store, hash-verified

225/** Parse a `<!-- zen:cols=… -->` width-hint line into per-column pixel widths
226 * (`null` = auto). Returns null if the line isn't a zen:cols comment. */
227export function parseColWidthsComment(line: string): Array<number | null> | null {
228 const m = COLS_COMMENT_RE.exec(line)
229 if (!m) return null
230 return (m[1] ?? '').split(',').map((part) => {
231 const t = part.trim().toLowerCase()
232 if (t === '' || t === 'auto') return null
233 const n = Number.parseInt(t, 10)
234 return Number.isFinite(n) && n > 0 ? n : null
235 })
236}
237
238/** Serialize per-column widths to a `<!-- zen:cols=… -->` line, or null when no
239 * column has an explicit width (so an un-resized table emits no comment). */

Callers 3

rehypeTableColWidthsFunction · 0.90
colWidthsAfterFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected