mirror of
https://github.com/glassflame/glassflame.github.io.git
synced 2024-11-29 03:24:25 +00:00
Add initial support for hashtag
s
This commit is contained in:
parent
6bd681d47e
commit
2aab74553a
1 changed files with 20 additions and 1 deletions
21
src/page.mjs
21
src/page.mjs
|
@ -15,7 +15,6 @@ const marked = new Marked({
|
||||||
},
|
},
|
||||||
tokenizer(src, tokens) {
|
tokenizer(src, tokens) {
|
||||||
const match = src.match(/^\[\[([^|\]]+)(?:\|([^\]]+))?]]/)
|
const match = src.match(/^\[\[([^|\]]+)(?:\|([^\]]+))?]]/)
|
||||||
console.debug("Is this a wikilink?", src, tokens, match)
|
|
||||||
if(match) {
|
if(match) {
|
||||||
return {
|
return {
|
||||||
type: "wikilink",
|
type: "wikilink",
|
||||||
|
@ -28,6 +27,26 @@ const marked = new Marked({
|
||||||
renderer(token) {
|
renderer(token) {
|
||||||
return `<abbr title="${token.target}">${token.display ?? token.target}</abbr>`
|
return `<abbr title="${token.target}">${token.display ?? token.target}</abbr>`
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "hashtag",
|
||||||
|
level: "inline",
|
||||||
|
start(src) {
|
||||||
|
return src.match(/^#/)?.index
|
||||||
|
},
|
||||||
|
tokenizer(src, tokens) {
|
||||||
|
const match = src.match(/^#([A-Za-z0-9]+)/)
|
||||||
|
if(match) {
|
||||||
|
return {
|
||||||
|
type: "hashtag",
|
||||||
|
raw: match[0],
|
||||||
|
tag: match[1],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
renderer(token) {
|
||||||
|
return `<abbr title="#${token.tag}">#${token.tag}</abbr>`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue