i think this is a good checkpoint
All checks were successful
Build and Deploy Client / build-and-deploy (push) Successful in 10s

This commit is contained in:
2026-08-29 23:47:59 -05:00
parent 95fe7c7745
commit 039dc4de0c
2 changed files with 43 additions and 42 deletions

View File

@@ -1,7 +1,6 @@
.format-plain {
// empty on purpose
color: #000000;
p {
font-size: larger;
}
.format-bold {

View File

@@ -109,17 +109,8 @@ export class Markleft {
// and then move to the next
parseStyle(parentNode ? parentNode : null, styles); // recursion
} else if(input[index] == "}") { // this node has closed
if(text.length === 0) break; // an empty text block is to be ignored
const node: textNode = {
type: "text",
text: text,
styles: styles
};
if(parentNode) {
parentNode.children.push(node);
} else {
nodes.push(node);
}
addTextNode(text, styles, parentNode);
//index++; // step to next
break;
} else { // regular text
text += input[index];
@@ -137,11 +128,6 @@ export class Markleft {
}
console.log("Parsing structure for format specifier", code);
let text: string = "";
while(true) { // assemble text
index++;
if(input[index] === "%" || input[index] === "#") { // encountered another format specifier
// create the node
const node: blockNode = {
type: "block",
@@ -149,7 +135,12 @@ export class Markleft {
children: [] // this blockNode will get passed to children so they can be added to the parent
};
// commit text to the block
let text: string = "";
while(true) { // assemble text
index++;
if(input[index] === "%" || input[index] === "#") { // encountered another format specifier
// commit current plain text to the block
if(text.length !== 0) {
const textNode: textNode = {
type: "text",
@@ -159,12 +150,6 @@ export class Markleft {
node.children.push(textNode);
}
if(parentNode) {
parentNode.children.push(node);
} else {
nodes.push(node);
}
text = ""; // clear the already commited text
// and then move to the next
if(input[index] === "%") {
@@ -173,21 +158,17 @@ export class Markleft {
parseStructure(node);
}
} else if(input[index] == "}") { // this node has closed
// create the node
const node: blockNode = {
type: "block",
kind: code,
children: [] // this blockNode will get passed to children so they can be added to the parent
};
index++;
// add its text
const textNode: textNode = {
type: "text",
text: text,
styles: [] // none in this case
};
node.children.push(textNode);
addTextNode(text, null, node);
// push node to children list
if(parentNode) {
parentNode.children.push(node);
} else {
nodes.push(node);
}
break;
} else { // regular text
text += input[index];
@@ -195,24 +176,45 @@ export class Markleft {
}
}
function addTextNode(text: string, styles: string[] | null = null, parentNode: blockNode | null = null) {
if(text.length === 0) return;
const textNode: textNode = {
type: "text",
text: text,
styles: styles ? styles : []
}
if(parentNode) {
parentNode.children.push(textNode);
} else {
nodes.push(textNode);
}
}
function parse(endChar: string | null = null) {
console.log("parsing...");
let currentText: string = "";
while(index < input.length) {
if(endChar && (input[index] === endChar)) {
index++;
break;
}
if(input[index] === "%") { // encountered a style specifier
addTextNode(currentText);
parseStyle();
currentText = "";
} else if(input[index] === "#") { // encountered a structure specifier
addTextNode(currentText);
parseStructure();
currentText = "";
} else if(input[index] === "@") { // encountered an attribute specifier
// nodes.push(parseAttribute());
} else {
// regular character
currentText += input[index];
index++;
}
}
addTextNode(currentText);
}
parse();