ttcmd: adds hr element
help pages: adds a way to extract the table of contents to the parent, smoothes out the rough loading on help pages
This commit is contained in:
@@ -63,8 +63,6 @@ TokenIdentifiers.set("card", {
|
||||
return search(s, start, end, rx, crx);
|
||||
},
|
||||
parse(s) {
|
||||
console.log(s);
|
||||
|
||||
const rx = /\[{2}\n+([\s\S]*)\n+\]{2}/;
|
||||
const [_, content] = s.match(rx) || ["", "Unable to parse card"];
|
||||
|
||||
@@ -279,6 +277,20 @@ TokenIdentifiers.set("p", {
|
||||
},
|
||||
});
|
||||
|
||||
TokenIdentifiers.set("hr", {
|
||||
rx: /^-{3,}$/gm,
|
||||
parse(s) {
|
||||
return {
|
||||
content: s,
|
||||
raw: s,
|
||||
metadata: {},
|
||||
type: "hr",
|
||||
uuid: crypto.randomUUID(),
|
||||
rendersContentOnly,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// const p = TokenIdentifiers.get("p");
|
||||
// TokenIdentifiers.clear();
|
||||
// p && TokenIdentifiers.set("p", p);
|
||||
|
@@ -3,22 +3,9 @@
|
||||
import { zipArrays } from "../zip";
|
||||
import { TokenIdentifiers } from "./TokenIdentifiers";
|
||||
|
||||
export const createElements = (body: string): [TokenMarker[], number] => {
|
||||
const tabOptions = [
|
||||
/^\s{2}(?!\s|\t)/m,
|
||||
/^\s{4}(?!\s|\t)/m,
|
||||
/^\t(?!\s|\t)]/m,
|
||||
];
|
||||
let tabSpacing = 0;
|
||||
|
||||
for (const [i, tabOption] of tabOptions.entries()) {
|
||||
if (body.match(tabOption)) {
|
||||
tabSpacing = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
export const createElements = (body: string): Token[] => {
|
||||
const tokens = tokenize(body);
|
||||
return [buildAbstractSyntaxTree(tokens), tabSpacing];
|
||||
return buildAbstractSyntaxTree(tokens).map((t) => t.token);
|
||||
};
|
||||
|
||||
const tokenize = (body: string) => {
|
||||
@@ -159,7 +146,6 @@ const contentToChildren = (token: Token) => {
|
||||
|
||||
const splitMarker = "{{^^}}";
|
||||
for (const child of token.children || []) {
|
||||
if (token.type === "card" && child.type === "code") debugger;
|
||||
content = content.replace(child.raw, splitMarker);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user