archivo del paquete→ .shtukbase/packages/ontology/actions/lib/mdlite.ts
actions/lib/mdlite.ts
12 líneas, 527 B.
El archivo tal como está en el paquete: el código y sus comentarios no se traducen.
- // The two pieces of markdown tables the generators read: the separator row and the cells of a row.
- /** `|---|:--:|` */
- export const SEP = /^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/;
- /** The cells of a table row; a literal pipe inside a cell is written `\|`. */
- export function cells(line: string): string[] {
- let s = line.trim();
- if (s.startsWith('|')) s = s.slice(1);
- if (s.endsWith('|') && !s.endsWith('\\|')) s = s.slice(0, -1);
- return s.split(/(?<!\\)\|/).map((c) => c.trim().replaceAll('\\|', '|'));
- }