sharkey/src/mfm/parse.ts
2019-01-30 15:27:54 +09:00

20 lines
435 B
TypeScript

import parser from './parser';
import { MfmForest } from './types';
import { normalize } from './normalize';
export default (source: string): MfmForest => {
if (source == null || source == '') {
return null;
}
return normalize(parser.root.tryParse(source));
};
export function parsePlain(source: string): MfmForest {
if (source == null || source == '') {
return null;
}
return normalize(parser.plain.tryParse(source));
}