(text)
| 69 | }; |
| 70 | |
| 71 | function parse(text) { |
| 72 | const { frontMatter, content: textToParse } = parseFrontMatter(text); |
| 73 | |
| 74 | let ast; |
| 75 | try { |
| 76 | ast = parseGlimmer(textToParse, glimmerParseOptions); |
| 77 | } catch (error) { |
| 78 | const location = getErrorLocation(error); |
| 79 | |
| 80 | if (location) { |
| 81 | const message = getErrorMessage(error); |
| 82 | |
| 83 | throw createError(message, { loc: location, cause: error }); |
| 84 | } |
| 85 | |
| 86 | /* c8 ignore next */ |
| 87 | throw error; |
| 88 | } |
| 89 | |
| 90 | if (frontMatter) { |
| 91 | /** @type {GlimmerFrontMatter} */ |
| 92 | const glimmerFrontMatter = { |
| 93 | ...frontMatter, |
| 94 | type: "FrontMatter", |
| 95 | loc: { |
| 96 | start: { |
| 97 | ...frontMatter.start, |
| 98 | offset: frontMatter.start.index, |
| 99 | }, |
| 100 | end: { |
| 101 | ...frontMatter.end, |
| 102 | offset: frontMatter.end.index, |
| 103 | }, |
| 104 | }, |
| 105 | }; |
| 106 | // @ts-expect-error -- not a real "Node" |
| 107 | ast.body.unshift(glimmerFrontMatter); |
| 108 | } |
| 109 | |
| 110 | return ast; |
| 111 | } |
| 112 | |
| 113 | function getErrorMessage(error) { |
| 114 | const { message } = error; |
nothing calls this directly
no test coverage detected