Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parse(input, currentTime, fileName) {
let text = TemplateLoader.normalizeText(input);
// Roundtrip the sample through the Commonmark parser
text = this.getTemplate().getParserManager().roundtripMarkdown(text);
// Set the current time and UTC Offset
const now = Util.setCurrentTime(currentTime);
const utcOffset = now.utcOffset();
let parser = this.getTemplate().getParserManager().getParser();
try {
parser.feed(text);
} catch(err) {
const fileLocation = ErrorUtil.locationOfError(err);
throw new ParseException(err.message, fileLocation, fileName, err.message, 'cicero-core');
}
if (parser.results.length !== 1) {
const head = JSON.stringify(parser.results[0]);
parser.results.forEach(function (element) {
if (head !== JSON.stringify(element)) {
const err = `Ambiguous text. Got ${parser.results.length} ASTs for text: ${text}`;
throw new ParseException(err, null, fileName, err, 'cicero-core' );