diff --git a/lib/tcmd/TokenIdentifiers.tsx b/lib/tcmd/TokenIdentifiers.tsx index eb469aa..0b65dd6 100644 --- a/lib/tcmd/TokenIdentifiers.tsx +++ b/lib/tcmd/TokenIdentifiers.tsx @@ -549,6 +549,7 @@ export const buildOnlyDefaultElements = () => { // paragraph registerIdentifier( "p", + // /(?<=\n\n|^)([\s\S]*?)(?=\n\n|$)/g, /(?<=\n\n)([\s\S]*?)(?=\n\n)/g, (s) => { return { diff --git a/lib/tcmd/index.ts b/lib/tcmd/index.ts index f6151a6..a966d5b 100644 --- a/lib/tcmd/index.ts +++ b/lib/tcmd/index.ts @@ -11,7 +11,10 @@ export const createElements = (body: string): Token[] => { const tokenize = (body: string) => { const tokenizedBody: TokenMarker[] = []; - body = body.replaceAll(/[ \t]+\n/g, "\n").replaceAll(/\n{3,}/g, "\n\n"); + body = body + .trim() + .replaceAll(/[ \t]+\n/g, "\n") + .replaceAll(/\n{3,}/g, "\n\n"); const addToken = (thing: TokenMarker) => { tokenizedBody.push(thing); @@ -23,6 +26,7 @@ const tokenize = (body: string) => { const rx = new RegExp(token.rx); let match; while ((match = rx.exec(body)) !== null) { + if (type === "p") debugger; const start = match.index; const end = rx.lastIndex; @@ -269,7 +273,10 @@ export function extractFrontMatter(body: string): [FrontMatter, string] { const rx = /^---([\s\S]*?)---/; const [_, frontmatterString] = body.match(rx) || ["", ""]; - body = body.replace(rx, ""); + console.log(body.replace(rx, "")); + + body = body.replace(rx, "").trim(); + console.log(body); const frontMatter: FrontMatter = {};