Skip to content

Commit 26af0a5

Browse files
fix(eslint): auto fix
1 parent fd0caa0 commit 26af0a5

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/index.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const ansiToSVG = require('ansi-to-svg');
22
const emphasize = require('emphasize');
33
const path = require('path');
4+
45
const options = {
56
fontSize: 12,
67
lineHeight: 25.6,
@@ -24,20 +25,26 @@ function highlightCode(code, lang = '') {
2425
return emphasize.highlightAuto(code);
2526
}
2627

27-
function modifySVG(svg) {
28-
return svg.replace(/viewBox="([0-9.]+), ([0-9.]+), ([0-9.]+), ([0-9.]+)"/, (match, g1, g2, g3, g4) => {
29-
return `height="${g4}" preserveAspectRatio="xMinYMax slice" viewBox="${g1}, ${g2}, 898, ${g4}"`;
30-
}).replace(/(<rect x="0" y="0" width=")([0-9.]+)(")/, (match, g1, g2, g3) => {
31-
return [g1, 898, g3].join('');
32-
});
28+
function modifySVG(svg) {
29+
return svg
30+
.replace(
31+
/viewBox="([0-9.]+), ([0-9.]+), ([0-9.]+), ([0-9.]+)"/,
32+
(match, g1, g2, g3, g4) => `height="${g4}" preserveAspectRatio="xMinYMax slice" viewBox="${g1}, ${g2}, 898, ${g4}"`
33+
)
34+
.replace(/(<rect x="0" y="0" width=")([0-9.]+)(")/, (match, g1, g2, g3) => [g1, 898, g3].join(''));
3335
}
3436

3537
function codeToSVG(code, range, { lang, theme = '3024.night' }) {
3638
const extractedCode = extract(code, range);
3739
const highlightedCode = highlightCode(extractedCode, lang);
38-
return modifySVG(ansiToSVG(highlightedCode.value, Object.assign(options, {
39-
colors: path.resolve(__dirname, `../schemes/${theme}.itermcolors`)
40-
})));
40+
return modifySVG(
41+
ansiToSVG(
42+
highlightedCode.value,
43+
Object.assign(options, {
44+
colors: path.resolve(__dirname, `../schemes/${theme}.itermcolors`)
45+
})
46+
)
47+
);
4148
}
4249

4350
module.exports = codeToSVG;

0 commit comments

Comments
 (0)