Newer
Older
export type MfmNode = MfmBlock | MfmInline;
export type MfmBlock = MfmQuote | MfmSearch | MfmCodeBlock | MfmMathBlock | MfmCenter;
const blockTypes: MfmNode['type'][] = [ 'quote', 'search', 'blockCode', 'mathBlock', 'center' ];
export function isMfmBlock(node: MfmNode): node is MfmBlock {
return blockTypes.includes(node.type);
}
children: MfmNode[];
};
export type MfmSearch = {
type: 'search';
props: {
};
export type MfmCodeBlock = {
type: 'blockCode';
props: {
code: string;
lang: string | null;
};
};
export type MfmMathBlock = {
type: 'mathBlock';
props: {
formula: string;
};
};
export type MfmCenter = {
type: 'center';
export type MfmInline = MfmUnicodeEmoji | MfmEmojiCode | MfmBold | MfmSmall | MfmItalic | MfmStrike |
MfmInlineCode | MfmMathInline | MfmMention | MfmHashtag | MfmUrl | MfmLink | MfmFn | MfmText;
export type MfmUnicodeEmoji = {
type: 'unicodeEmoji';
props: {
name: string;
};
children?: [];
};
children: MfmInline[];
};
export type MfmSmall = {
type: 'small';
children: MfmInline[];
};
export type MfmItalic = {
type: 'italic';
children: MfmInline[];
};
export type MfmStrike = {
type: 'strike';
children: MfmInline[];
};
export type MfmInlineCode = {
type: 'inlineCode';
props: {
code: string;
};
};
export type MfmMathInline = {
type: 'mathInline';
props: {
formula: string;
};
};
export type MfmMention = {
type: 'mention';
props: {
username: string;
host: string | null;
acct: string;
};
};
export type MfmHashtag = {
type: 'hashtag';
props: {
hashtag: string;
};
};
export type MfmUrl = {
type: 'url';
props: {
url: string;
};
};
export type MfmLink = {
type: 'link';
props: {
silent: boolean;
url: string;
};
children: MfmInline[];
};
export type MfmFn = {
type: 'fn';
props: {
name: string;
args: Record<string, string | true>;
};
children: MfmInline[];
};
export type MfmText = {
type: 'text';
props: {
text: string;
};