@parcel/codeframe 2.13.2 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/codeframe",
3
- "version": "2.13.2",
3
+ "version": "2.14.0",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -34,5 +34,5 @@
34
34
  "slice-ansi": "^4.0.0",
35
35
  "string-width": "^4.2.0"
36
36
  },
37
- "gitHead": "4d27ec8b8bd1792f536811fef86e74a31fa0e704"
37
+ "gitHead": "2306f8f14e8cf7d7c2d94ef5c6e52f9754dd5be8"
38
38
  }
package/src/codeframe.js CHANGED
@@ -129,11 +129,19 @@ export default function codeFrame(
129
129
 
130
130
  // Split input into lines and highlight syntax
131
131
  let lines = code.split(NEWLINE);
132
- let syntaxHighlightedLines = (
133
- opts.syntaxHighlighting ? highlightSyntax(code, opts.language) : code
134
- )
135
- .replace(TAB_REPLACE_REGEX, TAB_REPLACEMENT)
136
- .split(NEWLINE);
132
+ let visibleLines = lines
133
+ .slice(startLine, endLineIndex + 1)
134
+ .map(l => l.replace(TAB_REPLACE_REGEX, TAB_REPLACEMENT));
135
+ if (opts.syntaxHighlighting) {
136
+ visibleLines = highlightSyntax(
137
+ visibleLines.join('\n'),
138
+ opts.language,
139
+ ).split(NEWLINE);
140
+ }
141
+ let syntaxHighlightedLines = lines
142
+ .slice(0, startLine)
143
+ .concat(visibleLines)
144
+ .concat(lines.slice(endLineIndex + 2));
137
145
 
138
146
  // Loop over all lines and create codeframe
139
147
  let resultLines = [];