diff --git a/CHANGELOG.md b/CHANGELOG.md index 59be411..7bd3bd8 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [1.5.0](https://github.com/basics/code-snippet-to-svg/compare/v1.4.0...v1.5.0) (2018-08-23) + + +### Features + +* **parameters:** rearranged and grouped parameters by destruct ([0ab77e8](https://github.com/basics/code-snippet-to-svg/commit/0ab77e8)) + # [1.4.0](https://github.com/basics/code-snippet-to-svg/compare/v1.3.3...v1.4.0) (2018-08-23) diff --git a/functions/index.js b/functions/index.js index 530c2e9..749bc0e 100644 --- a/functions/index.js +++ b/functions/index.js @@ -14,11 +14,11 @@ function getMinMax(value = '1') { return value.split('-'); } -function getCodeAsSVG(path, query) { - const url = `https://${query.host || githubRawUrl}${path}`; +function getCodeAsSVG(path, { host = githubRawUrl, range, ...config }) { + const url = `https://${host}${path}`; return request({ uri: url }).then((code) => { - const [min, max] = getMinMax(query.range); - return codeToSVG(code, min, max, query); + const [min, max] = getMinMax(range); + return codeToSVG(code, { min, max }, config); }); } diff --git a/package-lock.json b/package-lock.json index c1d4aff..f73747d 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@js-basics/code-snippet-to-svg", - "version": "1.4.0", + "version": "1.5.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 556cab7..72ccf62 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@js-basics/code-snippet-to-svg", - "version": "1.4.0", + "version": "1.5.0", "description": "service to convert syntax highlighted code into svg by url", "main": "./lib/index.js", "directories": { diff --git a/src/index.js b/src/index.js index f16b379..05fe70c 100755 --- a/src/index.js +++ b/src/index.js @@ -2,7 +2,7 @@ const ansiToSVG = require('ansi-to-svg'); const emphasize = require('emphasize'); const path = require('path'); -function extract(content, min = 1, max) { +function extract(content, { min = 1, max }) { return content .split('\n') .slice(min - 1, max) @@ -16,8 +16,8 @@ function highlightCode(code, lang = '') { return emphasize.highlightAuto(code); } -function codeToSVG(code, min, max, { lang, theme = '3024.night' }) { - const extractedCode = extract(code, min, max); +function codeToSVG(code, range, { lang, theme = '3024.night' }) { + const extractedCode = extract(code, range); const highlightedCode = highlightCode(extractedCode, lang); return ansiToSVG(highlightedCode.value, { fontSize: 16,