(parse, text, options)
| 380 | } |
| 381 | |
| 382 | function parseWithParser(parse, text, options) { |
| 383 | const { frontMatter, content: textToParse } = parseFrontMatter(text); |
| 384 | |
| 385 | let result; |
| 386 | |
| 387 | try { |
| 388 | result = parse(textToParse, { |
| 389 | // Prevent file access https://github.com/postcss/postcss/blob/4f4e2932fc97e2c117e1a4b15f0272ed551ed59d/lib/previous-map.js#L18 |
| 390 | map: false, |
| 391 | }); |
| 392 | } catch (/** @type {any} */ error) { |
| 393 | const { name, reason, line, column } = error; |
| 394 | /* c8 ignore 3 */ |
| 395 | if (typeof line !== "number") { |
| 396 | throw error; |
| 397 | } |
| 398 | |
| 399 | throw createError(`${name}: ${reason}`, { |
| 400 | loc: { start: { line, column } }, |
| 401 | cause: error, |
| 402 | }); |
| 403 | } |
| 404 | |
| 405 | options.originalText = text; |
| 406 | result = parseNestedCSS(addTypePrefix(result, "css-"), options); |
| 407 | |
| 408 | calculateLoc(result, text); |
| 409 | |
| 410 | if (frontMatter) { |
| 411 | result.frontMatter = { |
| 412 | ...frontMatter, |
| 413 | type: "front-matter", |
| 414 | source: { |
| 415 | startOffset: frontMatter.start.index, |
| 416 | endOffset: frontMatter.end.index, |
| 417 | }, |
| 418 | }; |
| 419 | } |
| 420 | |
| 421 | return result; |
| 422 | } |
| 423 | |
| 424 | function parseCss(text, options = {}) { |
| 425 | return parseWithParser(postcssParse.default, text, options); |
no test coverage detected
searching dependent graphs…