misskey/src/mfm/parse.ts

20 lines
460 B
TypeScript

import { mfmLanguage } from './language';
import { MfmForest } from './prelude';
import { normalize } from './normalize';
export function parse(source: string): MfmForest {
if (source == null || source == '') {
return null;
}
return normalize(mfmLanguage.root.tryParse(source));
}
export function parsePlain(source: string): MfmForest {
if (source == null || source == '') {
return null;
}
return normalize(mfmLanguage.plain.tryParse(source));
}