1
Fork 0
mirror of https://github.com/glassflame/glassflame.github.io.git synced 2024-11-22 08:04:27 +00:00

Start implementing callouts

This commit is contained in:
Steffo 2023-11-06 20:25:17 +01:00
parent bcd51d2eb5
commit 7916c877bc
Signed by: steffo
GPG key ID: 2A24051445686895
2 changed files with 35 additions and 3 deletions

View file

@ -0,0 +1,9 @@
import {CustomElement} from "../base.mjs";
export class Callout extends CustomElement {
static get template() {
return document.getElementById("template-callout")
}
// TODO: Last time, you were here!
}

View file

@ -29,7 +29,7 @@ export class MarkdownElement extends CustomElement {
tokens: this.lexer.inline(cap[1])
};
}
}
},
},
extensions: [
{
@ -58,8 +58,7 @@ export class MarkdownElement extends CustomElement {
name: "mathBlock",
level: "block",
start(src) {
const match = src.match(/[$][$]/)
return match?.index
return src.match(/[$][$]/)?.index
},
tokenizer(src, _) {
const match = src.match(/^[$][$](.*?)[$][$]/s)
@ -75,6 +74,30 @@ export class MarkdownElement extends CustomElement {
return `<x-math document="${token.document}" block></x-math>`
}
},
{
name: "callout",
level: "block",
start(src) {
return src.match(/[$][$]/)?.index
},
tokenizer(src, _) {
const match = src.match(/^ {0,3}> ?\[!(.+)]([-+])? ?(.+)?\n+( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/)
if(match) {
return {
type: "callout",
raw: match[0],
kind: match[1],
collapse: match[2],
admonition: match[3],
contents: match[4],
}
}
},
renderer(token) {
console.log(token)
return `<x-callout kind="${token.kind}" collapse="${token.collapse}" admonition="${token.admonition}" contents="${token.contents}"></x-callout>`
}
},
{
name: "wikilink",
level: "inline",