tcmd: Accordion and popover md elements

This commit is contained in:
2024-02-28 21:41:12 -07:00
parent 2e9bfa1557
commit ff0a4280e2
22 changed files with 729 additions and 68 deletions

View File

@@ -21,7 +21,6 @@ const tokenize = (body: string) => {
let openBT = blockTokens.findLast((bt) => !bt.closed);
if (block) {
if (typeof block === "string") {
console.log(block);
if (openBT) {
openBT.closed = true;
}

View File

@@ -24,7 +24,7 @@ export const inlineTokens: {
},
},
{
rx: /(?<!\!)\[(.*?)\]\((.*?)\)/g,
rx: /(?<![\!\?|^])\[(.*?)\]\((.*?)\)/g,
create(content, start, end, tokens) {
const [_, label, href] = content;
tokens.push({
@@ -60,4 +60,22 @@ export const inlineTokens: {
return l;
},
},
{
rx: /\^\[(.*?)\]\((.*?)\)/g,
create(content, start, end, tokens) {
const [_, text, popover] = content;
tokens.push({
content: text,
end,
start,
type: "popover",
data: {
popover,
},
});
},
replace(l) {
return l;
},
},
];

View File

@@ -41,4 +41,17 @@ const blockTokens: {
};
},
},
{
rx: /\[accordion\s?([a-z\s]*)\]/,
closeRx: /\[\/accordion\]/,
create(line) {
const title = line.match(this.rx)?.at(1);
return {
type: "accordion",
metadata: { title },
children: [],
closed: false,
};
},
},
];