From 0ab77e851c86c651aedb4a674c371039ebeac532 Mon Sep 17 00:00:00 2001 From: Stephan Gerbeth Date: Thu, 23 Aug 2018 11:50:52 +0200 Subject: [PATCH 1/2] feat(parameters): rearranged and grouped parameters by destruct --- functions/index.js | 8 ++++---- src/index.js | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) 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/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, From 79cca4160939b380b3ba09818e50728f6c29c82e Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 23 Aug 2018 09:53:07 +0000 Subject: [PATCH 2/2] chore(release): 1.5.0 [skip ci] # [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)) --- CHANGELOG.md | 7 +++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) 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/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": {