scaffold markup
All checks were successful
Build and Deploy Client / build-and-deploy (push) Successful in 10s
All checks were successful
Build and Deploy Client / build-and-deploy (push) Successful in 10s
This commit is contained in:
@@ -8,4 +8,6 @@
|
|||||||
<p>2. automated dynamic themes. a theme based on a good color palette can rotate the hues around so the colors can change but maintain the same distance apart</p>
|
<p>2. automated dynamic themes. a theme based on a good color palette can rotate the hues around so the colors can change but maintain the same distance apart</p>
|
||||||
<p>3. world of text is goated, its like a chat room but infinite</p>
|
<p>3. world of text is goated, its like a chat room but infinite</p>
|
||||||
|
|
||||||
|
<app-markleft></app-markleft>
|
||||||
|
|
||||||
<router-outlet />
|
<router-outlet />
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { Component, signal } from '@angular/core';
|
import { Component, signal } from '@angular/core';
|
||||||
import { RouterOutlet } from '@angular/router';
|
import { RouterOutlet } from '@angular/router';
|
||||||
|
import { Markleft } from './markleft/markleft'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
imports: [RouterOutlet],
|
imports: [Markleft, RouterOutlet],
|
||||||
templateUrl: './app.html',
|
templateUrl: './app.html',
|
||||||
styleUrl: './app.scss'
|
styleUrl: './app.scss'
|
||||||
})
|
})
|
||||||
|
|||||||
1
client/src/app/markleft/markleft.html
Normal file
1
client/src/app/markleft/markleft.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<p>markleft works!</p>
|
||||||
12
client/src/app/markleft/markleft.scss
Normal file
12
client/src/app/markleft/markleft.scss
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
.format-bold {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.format-italic {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.format-underline {
|
||||||
|
text-decoration: underline solid #000000 3px;
|
||||||
|
}
|
||||||
22
client/src/app/markleft/markleft.spec.ts
Normal file
22
client/src/app/markleft/markleft.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { Markleft } from './markleft';
|
||||||
|
|
||||||
|
describe('Markleft', () => {
|
||||||
|
let component: Markleft;
|
||||||
|
let fixture: ComponentFixture<Markleft>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [Markleft],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(Markleft);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
await fixture.whenStable();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
124
client/src/app/markleft/markleft.ts
Normal file
124
client/src/app/markleft/markleft.ts
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
|
// type descriptions
|
||||||
|
|
||||||
|
interface formatDescriptor {
|
||||||
|
className: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
interface textNode {
|
||||||
|
type: string;
|
||||||
|
text: string;
|
||||||
|
styles: formatDescriptor[]
|
||||||
|
}
|
||||||
|
|
||||||
|
interface blockNode {
|
||||||
|
type: string;
|
||||||
|
kind: string;
|
||||||
|
children: (blockNode | textNode)[]
|
||||||
|
}
|
||||||
|
|
||||||
|
// styles registry: this maps format specifiers to css classes
|
||||||
|
const styles: Record<string, formatDescriptor> = {
|
||||||
|
B: {
|
||||||
|
className: "format-bold"
|
||||||
|
},
|
||||||
|
I: {
|
||||||
|
className: "format-italic"
|
||||||
|
},
|
||||||
|
U: {
|
||||||
|
className: "format-underline"
|
||||||
|
},
|
||||||
|
}; // i.e. %B{...} will apply "format-bold"
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-markleft',
|
||||||
|
imports: [],
|
||||||
|
templateUrl: './markleft.html',
|
||||||
|
styleUrl: './markleft.scss',
|
||||||
|
})
|
||||||
|
export class Markleft {
|
||||||
|
|
||||||
|
plaintext: String = `
|
||||||
|
#H1{Hello World!}
|
||||||
|
#P{
|
||||||
|
This is some markleft text. This is %I{italic} and this is %B{bold}. Some might %I{even be %B{both}}.
|
||||||
|
}
|
||||||
|
This should be plain and unstylized.
|
||||||
|
`;
|
||||||
|
|
||||||
|
parsePlaintext(input: string): /*structureNode[]*/ void {
|
||||||
|
|
||||||
|
/* pseudocode (c lol)
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
void parse(char endChar = null, formatDescriptor[]) {
|
||||||
|
const nodes = []; // start with an empty list of nodes
|
||||||
|
|
||||||
|
while(index < input.length) { // iterate over the input string
|
||||||
|
// break if } encountered, step forward (this format block has exited)
|
||||||
|
if(endChar && (input[pos] == endChar)) {
|
||||||
|
index++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(input[index] == "%") {
|
||||||
|
nodes.push(parseStyle(...));
|
||||||
|
} else if(input[index] == "#") {
|
||||||
|
nodes.push(parseBlock(...));
|
||||||
|
} else {
|
||||||
|
nodes.push(parseText(...));
|
||||||
|
}
|
||||||
|
|
||||||
|
return mergeAdjacentText(nodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void parseStyle(parentStyle) {
|
||||||
|
index++; // step onto specifier
|
||||||
|
char code = readIdentifier(input[index])
|
||||||
|
index++;
|
||||||
|
expect("{"); // parsing error if not
|
||||||
|
const styles = [...parentStyles, code] // append style code to styles list of this node
|
||||||
|
const children = parseUntil("}", styles); // recursion probably
|
||||||
|
|
||||||
|
return children
|
||||||
|
}
|
||||||
|
... and so on for parseBlock and parseText
|
||||||
|
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderNode(node: (textNode | blockNode)): void {
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(node.type == "text") { // text nodes only need span elements
|
||||||
|
|
||||||
|
element span = html.createElement("span"); // or whatever it is
|
||||||
|
|
||||||
|
// add styles
|
||||||
|
foreach(style style in node.styles) {
|
||||||
|
span.classes.add(styles[style].className);
|
||||||
|
}
|
||||||
|
return span;
|
||||||
|
|
||||||
|
} else if(node.type == "block") {
|
||||||
|
|
||||||
|
element block = html.createElement(node.kind); // or whatever it is
|
||||||
|
|
||||||
|
// recursion
|
||||||
|
foreach(nodeType child in node.children) {
|
||||||
|
block.children.add(renderNode(child));
|
||||||
|
}
|
||||||
|
return block;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user