MCPcopy Create free account
hub / github.com/prettier/prettier / parse

Function parse

src/language-yaml/parser-yaml.js:13–38  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

11const parseOptions = { uniqueKeys: false };
12
13function parse(text) {
14 let root;
15 try {
16 root = parseYaml(text, parseOptions);
17 } catch (error) {
18 if (error instanceof YAMLSyntaxError) {
19 throw createError(error.message, {
20 loc: error.position,
21 cause: error,
22 });
23 }
24
25 /* c8 ignore next */
26 throw error;
27 }
28
29 /**
30 * suppress `comment not printed` error
31 *
32 * comments are handled in printer-yaml.js without using `printComment`
33 * so that it'll always throw errors even if we printed it correctly
34 */
35 delete root.comments;
36
37 return root;
38}
39
40export const yaml = {
41 astFormat: "yaml",

Callers 2

parseEmptyJsonFunction · 0.90
parseWithOptionsFunction · 0.90

Calls 1

createErrorFunction · 0.85

Tested by

no test coverage detected