Fix return value of parsePlain API

This commit is contained in:
marihachi 2021-03-28 14:48:45 +09:00
parent d82b12146a
commit ecca995a20
2 changed files with 4 additions and 2 deletions

View file

@ -1,5 +1,5 @@
import peg from 'pegjs'; import peg from 'pegjs';
import { MfmNode } from './node'; import { MfmNode, MfmPlainNode } from './node';
import { stringifyNode, stringifyTree } from './util'; import { stringifyNode, stringifyTree } from './util';
const parser: peg.Parser = require('./parser'); const parser: peg.Parser = require('./parser');
@ -8,7 +8,7 @@ export function parse(input: string): MfmNode[] {
return nodes; return nodes;
} }
export function parsePlain(input: string): MfmNode[] { export function parsePlain(input: string): MfmPlainNode[] {
const nodes = parser.parse(input, { startRule: 'plainParser' }); const nodes = parser.parse(input, { startRule: 'plainParser' });
return nodes; return nodes;
} }

View file

@ -1,5 +1,7 @@
export type MfmNode = MfmBlock | MfmInline; export type MfmNode = MfmBlock | MfmInline;
export type MfmPlainNode = MfmUnicodeEmoji | MfmEmojiCode | MfmText;
export type MfmBlock = MfmQuote | MfmSearch | MfmCodeBlock | MfmMathBlock | MfmCenter; export type MfmBlock = MfmQuote | MfmSearch | MfmCodeBlock | MfmMathBlock | MfmCenter;
const blockTypes: MfmNode['type'][] = [ 'quote', 'search', 'blockCode', 'mathBlock', 'center' ]; const blockTypes: MfmNode['type'][] = [ 'quote', 'search', 'blockCode', 'mathBlock', 'center' ];