tcmd: Accordion and popover md elements
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
},
|
||||
},
|
||||
];
|
||||
|
@@ -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,
|
||||
};
|
||||
},
|
||||
},
|
||||
];
|
||||
|
Reference in New Issue
Block a user