mirror of
https://github.com/glassflame/glassflame.github.io.git
synced 2024-11-22 16:14:26 +00:00
Start implementing callouts
This commit is contained in:
parent
bcd51d2eb5
commit
7916c877bc
2 changed files with 35 additions and 3 deletions
9
src/elements/markdown/callout.mjs
Normal file
9
src/elements/markdown/callout.mjs
Normal 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!
|
||||||
|
}
|
|
@ -29,7 +29,7 @@ export class MarkdownElement extends CustomElement {
|
||||||
tokens: this.lexer.inline(cap[1])
|
tokens: this.lexer.inline(cap[1])
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
extensions: [
|
extensions: [
|
||||||
{
|
{
|
||||||
|
@ -58,8 +58,7 @@ export class MarkdownElement extends CustomElement {
|
||||||
name: "mathBlock",
|
name: "mathBlock",
|
||||||
level: "block",
|
level: "block",
|
||||||
start(src) {
|
start(src) {
|
||||||
const match = src.match(/[$][$]/)
|
return src.match(/[$][$]/)?.index
|
||||||
return match?.index
|
|
||||||
},
|
},
|
||||||
tokenizer(src, _) {
|
tokenizer(src, _) {
|
||||||
const match = src.match(/^[$][$](.*?)[$][$]/s)
|
const match = src.match(/^[$][$](.*?)[$][$]/s)
|
||||||
|
@ -75,6 +74,30 @@ export class MarkdownElement extends CustomElement {
|
||||||
return `<x-math document="${token.document}" block></x-math>`
|
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",
|
name: "wikilink",
|
||||||
level: "inline",
|
level: "inline",
|
||||||
|
|
Loading…
Reference in a new issue