This commit is contained in:
marihachi 2021-03-24 01:03:57 +09:00
parent 9099f54bde
commit 1a6f927b83

View file

@ -12,6 +12,72 @@ export function parsePlain(input: string): MfmNode[] {
return nodes;
}
function nodeStringify(node: MfmNode): string {
switch(node.type) {
// block
case 'quote': {
return toString(node.children).split('\n').map(line => `>${line}`).join('\n');
}
case 'search': {
break;
}
case 'blockCode': {
break;
}
case 'mathBlock': {
break;
}
case 'center': {
break;
}
// inline
case 'emoji': {
break;
}
case 'bold': {
break;
}
case 'small': {
break;
}
case 'italic': {
break;
}
case 'strike': {
break;
}
case 'inlineCode': {
break;
}
case 'mathInline': {
break;
}
case 'mention': {
break;
}
case 'hashtag': {
break;
}
case 'url': {
break;
}
case 'link': {
break;
}
case 'fn': {
break;
}
case 'text': {
return node.props.text;
}
}
return '';
}
export function toString(nodes: MfmNode[]): string {
return nodes.map(node => nodeStringify(node)).join('');
}
export {
MfmNode,
MfmBlock,