UNPKG

aubade

Version:

filesystem-based content processor

34 lines (33 loc) 997 B
export function code({ cursor }) { if (!cursor.eat('```')) return null; const language = cursor.locate(/\n/).trim(); const source = cursor.locate(/\r?\n```|$/).trim(); if (!source.length) return null; cursor.trim(), cursor.eat('```'); return { type: 'block:code', attr: { 'data-language': language }, children: source.split('\n').map((line) => ({ type: 'inline:code', text: line, })), }; } export function linebreak({ cursor }) { const source = cursor.locate(/\n|$/).trim(); if (!['---', '***', '___'].includes(source)) return null; return { type: 'block:break' }; } export function list({ cursor, compose }) { const char = cursor.read(1); const bullet = char === '-' || char === '*'; const number = /^\d/.test(char); if (!bullet && !number) return null; // @TODO: implement compose; // recursive call to parse the list items return null; }