包文件→ .shtukbase/packages/ontology/actions/lib/mdlite.ts
actions/lib/mdlite.ts
12 行, 527 B.
文件按包中的原样显示:代码及其注释不做翻译。
- // 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('\\|', '|'));
- }