From e29b244aeab08ea36fb385c7beb2ad0560217039 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 13 Oct 2024 10:37:19 +0800 Subject: =?UTF-8?q?bump:=20@babel/cli=207.25.6=20=E2=86=92=207.25.7,=20@ba?= =?UTF-8?q?bel/core=207.25.2=20=E2=86=92=207.25.8,=20@babel/preset-env=207?= =?UTF-8?q?.25.4=20=E2=86=92=207.25.8,=20postcss=208.4.41=20=E2=86=92=208.?= =?UTF-8?q?4.47,=20swup=204.7.0=20=E2=86=92=204.8.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- node_modules/postcss/lib/css-syntax-error.js | 61 +++++++++++++++++++++------- 1 file changed, 47 insertions(+), 14 deletions(-) (limited to 'node_modules/postcss/lib/css-syntax-error.js') diff --git a/node_modules/postcss/lib/css-syntax-error.js b/node_modules/postcss/lib/css-syntax-error.js index 16930332..275a4f64 100644 --- a/node_modules/postcss/lib/css-syntax-error.js +++ b/node_modules/postcss/lib/css-syntax-error.js @@ -52,37 +52,70 @@ class CssSyntaxError extends Error { let css = this.source if (color == null) color = pico.isColorSupported - if (terminalHighlight) { - if (color) css = terminalHighlight(css) - } - - let lines = css.split(/\r?\n/) - let start = Math.max(this.line - 3, 0) - let end = Math.min(this.line + 2, lines.length) - let maxWidth = String(end).length - - let mark, aside + let aside = text => text + let mark = text => text + let highlight = text => text if (color) { let { bold, gray, red } = pico.createColors(true) mark = text => bold(red(text)) aside = text => gray(text) - } else { - mark = aside = str => str + if (terminalHighlight) { + highlight = text => terminalHighlight(text) + } } + let lines = css.split(/\r?\n/) + let start = Math.max(this.line - 3, 0) + let end = Math.min(this.line + 2, lines.length) + let maxWidth = String(end).length + return lines .slice(start, end) .map((line, index) => { let number = start + 1 + index let gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | ' if (number === this.line) { + if (line.length > 160) { + let padding = 20 + let subLineStart = Math.max(0, this.column - padding) + let subLineEnd = Math.max( + this.column + padding, + this.endColumn + padding + ) + let subLine = line.slice(subLineStart, subLineEnd) + + let spacing = + aside(gutter.replace(/\d/g, ' ')) + + line + .slice(0, Math.min(this.column - 1, padding - 1)) + .replace(/[^\t]/g, ' ') + + return ( + mark('>') + + aside(gutter) + + highlight(subLine) + + '\n ' + + spacing + + mark('^') + ) + } + let spacing = aside(gutter.replace(/\d/g, ' ')) + line.slice(0, this.column - 1).replace(/[^\t]/g, ' ') - return mark('>') + aside(gutter) + line + '\n ' + spacing + mark('^') + + return ( + mark('>') + + aside(gutter) + + highlight(line) + + '\n ' + + spacing + + mark('^') + ) } - return ' ' + aside(gutter) + line + + return ' ' + aside(gutter) + highlight(line) }) .join('\n') } -- cgit v1.2.3