ttcmd: attempts to fix infinite loop on p tags
This commit is contained in:
parent
6760d06b18
commit
fd5e5bcc8b
@ -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 {
|
||||
|
@ -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 = {};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user