summaryrefslogtreecommitdiff
path: root/src/mfm/parse.ts
blob: 0343ff09d8fa8ccc21b6e4095984381959d3c4a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { mfmLanguage } from './language';
import { MfmForest } from './types';
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));
}