gatsbyjs/gatsby · error
Invalid match specified: "${line.trim()}"
Error message
Invalid match specified: "${line.trim()}" What it means
Directive-parser warning in gatsby-remark-prismjs: for a `line`/`range` highlight directive, the range portion could not be parsed (rangeParser returned no entries, or the range segment was malformed), so the requested lines are not highlighted/flagged. Only that directive is ignored; highlighting of the block continues.
Source
Thrown at packages/gatsby-remark-prismjs/src/directives.js:103
case `line`:
actions.flag(feature, index, flagSource)
actions.stripComment(index)
break
case `range`:
actions.hide(index)
if (directiveRange) {
const strippedDirectiveRange = directiveRange.slice(1, -1)
const range = rangeParser(strippedDirectiveRange)
if (range.length > 0) {
range.forEach(relativeIndex => {
actions.flag(feature, index + relativeIndex, flagSource)
})
break
}
}
console.warn(`Invalid match specified: "${line.trim()}"`)
break
}
}
module.exports = function highlightLineRange(code, highlights = []) {
if (highlights.length > 0 || HIGHLIGHT_DIRECTIVE.test(code)) {
// HACK split multiline spans with line separators inside into multiple spans
// separated by line separator - this fixes line highlighting behaviour for
// - plain-text in jsx,
// - tripple-quoted-string in python,
// - comment in c-like languages (including javascript), etc.
code = code.replace(MULTILINE_TOKEN_SPAN, (match, token) =>
match.replace(/\n/g, `</span>\n<span class="token ${token}">`)
)
}
const split = code.split(`\n`)
const lines = split.map(code => {View on GitHub (pinned to e85d62f177)
Solutions
- Fix the directive range syntax, e.g. {1,3-5} after the language tag
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/gatsby-remark-prismjs/src/directives.js:103 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of gatsbyjs/gatsby@e85d62f177 (2026-08-26).
Data as JSON: /api/errors/0c045095806ccd6f.
Report an issue: GitHub.