yumechi-no-kuni/src/mfm/parse.ts
2019-01-30 14:51:30 +09:00

12 lines
383 B
TypeScript

import parser, { plainParser } from './parser';
import { MfmForest } from './types';
import { normalize } from './normalize';
export default (source: string, plainText = false): MfmForest => {
if (source == null || source == '') {
return null;
}
const raw = plainText ? plainParser.root.tryParse(source) : parser.root.tryParse(source) as MfmForest;
return normalize(raw);
};