implement mention

This commit is contained in:
marihachi 2021-03-20 12:25:29 +09:00
parent 605c6585c7
commit 7cfcf2edcd

View file

@ -155,6 +155,7 @@ inline
/ strike / strike
/ inlineCode / inlineCode
/ mathInline / mathInline
/ mention
/ hashtag / hashtag
/ url / url
/ link / link
@ -259,6 +260,37 @@ mathInline
}); });
} }
// inline: mention
mention
= "@" name:mentionName host:("@" host:mentionHost { return host; })?
{
return createNode('mention', {
name: name,
host: host
});
}
mentionName
= !"-" mentionNamePart+ // first char is not "-".
{
return text();
}
mentionNamePart
= "-" &mentionNamePart // last char is not "-".
/ [a-z0-9_]i
mentionHost
= ![.-] mentionHostPart+ // first char is neither "." nor "-".
{
return text();
}
mentionHostPart
= [.-] &mentionHostPart // last char is neither "." nor "-".
/ [a-z0-9_]i
// inline: hashtag // inline: hashtag
hashtag hashtag