awesome-readme-to-data
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -1,1 +0,1 @@ | ||
{"processes":{"28223f48-8f41-43e6-aaa6-8ed8590b8e24":{"parent":"99789093-3848-4fb8-9ec2-29dca556a4bd","children":[]},"884deb3f-f8cb-4c5b-9875-c01edfb30630":{"parent":"99789093-3848-4fb8-9ec2-29dca556a4bd","children":[]},"99789093-3848-4fb8-9ec2-29dca556a4bd":{"parent":null,"children":["28223f48-8f41-43e6-aaa6-8ed8590b8e24","884deb3f-f8cb-4c5b-9875-c01edfb30630","f078b942-1a53-46ce-9b0f-cc3219fe8b58"]},"f078b942-1a53-46ce-9b0f-cc3219fe8b58":{"parent":"99789093-3848-4fb8-9ec2-29dca556a4bd","children":[]}},"files":{"/Users/ivandemidov/Projects/awesome-readme-to-data/libs/tree.js":["28223f48-8f41-43e6-aaa6-8ed8590b8e24","884deb3f-f8cb-4c5b-9875-c01edfb30630"],"/Users/ivandemidov/Projects/awesome-readme-to-data/libs/header.js":["28223f48-8f41-43e6-aaa6-8ed8590b8e24","884deb3f-f8cb-4c5b-9875-c01edfb30630","f078b942-1a53-46ce-9b0f-cc3219fe8b58"],"/Users/ivandemidov/Projects/awesome-readme-to-data/libs/description.js":["28223f48-8f41-43e6-aaa6-8ed8590b8e24","884deb3f-f8cb-4c5b-9875-c01edfb30630","f078b942-1a53-46ce-9b0f-cc3219fe8b58"],"/Users/ivandemidov/Projects/awesome-readme-to-data/libs/link.js":["28223f48-8f41-43e6-aaa6-8ed8590b8e24","884deb3f-f8cb-4c5b-9875-c01edfb30630","f078b942-1a53-46ce-9b0f-cc3219fe8b58"],"/Users/ivandemidov/Projects/awesome-readme-to-data/index.js":["884deb3f-f8cb-4c5b-9875-c01edfb30630"],"/Users/ivandemidov/Projects/awesome-readme-to-data/libs/helpers.js":["884deb3f-f8cb-4c5b-9875-c01edfb30630","f078b942-1a53-46ce-9b0f-cc3219fe8b58"]},"externalIds":{}} | ||
{"processes":{"4f1560b7-2523-4a7a-8b21-cf28ccc3491c":{"parent":"81b0f1a5-07c7-4dea-b6e7-58dbdba43043","children":[]},"81b0f1a5-07c7-4dea-b6e7-58dbdba43043":{"parent":null,"children":["4f1560b7-2523-4a7a-8b21-cf28ccc3491c","a3774ee8-339b-4891-9d75-790a1c75ea56","c4002dd6-d696-43c6-9ae2-bf32016cfead"]},"a3774ee8-339b-4891-9d75-790a1c75ea56":{"parent":"81b0f1a5-07c7-4dea-b6e7-58dbdba43043","children":[]},"c4002dd6-d696-43c6-9ae2-bf32016cfead":{"parent":"81b0f1a5-07c7-4dea-b6e7-58dbdba43043","children":[]}},"files":{"/Users/ivandemidov/Projects/awesome-readme-to-data/libs/header.js":["4f1560b7-2523-4a7a-8b21-cf28ccc3491c","a3774ee8-339b-4891-9d75-790a1c75ea56","c4002dd6-d696-43c6-9ae2-bf32016cfead"],"/Users/ivandemidov/Projects/awesome-readme-to-data/libs/description.js":["4f1560b7-2523-4a7a-8b21-cf28ccc3491c","a3774ee8-339b-4891-9d75-790a1c75ea56","c4002dd6-d696-43c6-9ae2-bf32016cfead"],"/Users/ivandemidov/Projects/awesome-readme-to-data/libs/link.js":["4f1560b7-2523-4a7a-8b21-cf28ccc3491c","a3774ee8-339b-4891-9d75-790a1c75ea56","c4002dd6-d696-43c6-9ae2-bf32016cfead"],"/Users/ivandemidov/Projects/awesome-readme-to-data/libs/helpers.js":["4f1560b7-2523-4a7a-8b21-cf28ccc3491c","a3774ee8-339b-4891-9d75-790a1c75ea56"],"/Users/ivandemidov/Projects/awesome-readme-to-data/index.js":["a3774ee8-339b-4891-9d75-790a1c75ea56"],"/Users/ivandemidov/Projects/awesome-readme-to-data/libs/tree.js":["a3774ee8-339b-4891-9d75-790a1c75ea56","c4002dd6-d696-43c6-9ae2-bf32016cfead"]},"externalIds":{}} |
@@ -0,3 +1,13 @@ | ||
## <small>0.0.3 (2020-03-26)</small> | ||
* fix: parse incorrect link ([b1dc694](https://github.com/Scrum/awesome-readme-to-data/commit/b1dc694)) | ||
* test: incorrect link ([9fccb6c](https://github.com/Scrum/awesome-readme-to-data/commit/9fccb6c)) | ||
* docs: update for label ([d1b6c18](https://github.com/Scrum/awesome-readme-to-data/commit/d1b6c18)) | ||
## <small>0.0.2 (2020-03-26)</small> | ||
* 0.0.2 ([82d1769](https://github.com/Scrum/awesome-readme-to-data/commit/82d1769)) | ||
* build: update changelog ([8ae0770](https://github.com/Scrum/awesome-readme-to-data/commit/8ae0770)) | ||
* ci: drop support old node ([0597906](https://github.com/Scrum/awesome-readme-to-data/commit/0597906)) | ||
@@ -4,0 +14,0 @@ |
class Link { | ||
constructor({text}) { | ||
const [description, link] = text.match(/^(\[.+?]\(.+?\))?(.+?)$/).reverse(); | ||
const [path, name] = link.match(/^\[(.+?)]\((.+?)\)$/).reverse(); | ||
let [description, link] = text.match(/^(\[.+?]\(.+?\))?(.+?)$/).reverse(); | ||
if (link === undefined && /^(\[.+?]\(.+?\))/.test(description)) { | ||
link = description; | ||
} | ||
this.name = name; | ||
this.path = path; | ||
this.description = description; | ||
if (link !== undefined) { | ||
const [path, name] = link.match(/^\[(.+?)]\((.+?)\)$/).reverse(); | ||
this.name = name; | ||
this.path = path; | ||
} | ||
if (description !== link) { | ||
this.description = description; | ||
} | ||
} | ||
@@ -10,0 +18,0 @@ } |
{ | ||
"name": "awesome-readme-to-data", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Transform awesome readme to data", | ||
"main": "index.js", | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"dependencies": { | ||
@@ -7,0 +10,0 @@ "marked": "^0.8.2" |
@@ -60,1 +60,41 @@ const test = require('ava'); | ||
}); | ||
test('create node link without description', t => { | ||
const node = { | ||
type: 'text', | ||
text: '[link](https://link-1)' | ||
}; | ||
const expectedNode = { | ||
name: 'link', | ||
path: 'https://link-1' | ||
}; | ||
const value = new Link(node); | ||
t.is(value.constructor.name, 'Link'); | ||
t.deepEqual({...value}, expectedNode); | ||
}); | ||
test('create node link without link', t => { | ||
const node = { | ||
type: 'text', | ||
text: 'link' | ||
}; | ||
const expectedNode = { | ||
description: 'link' | ||
}; | ||
const value = new Link(node); | ||
t.is(value.constructor.name, 'Link'); | ||
t.deepEqual({...value}, expectedNode); | ||
}); | ||
test('create node link with incorrect start link', t => { | ||
const node = { | ||
type: 'text', | ||
text: 'link [test](https://test.ru) sadasd asda' | ||
}; | ||
const expectedNode = { | ||
description: 'link [test](https://test.ru) sadasd asda' | ||
}; | ||
const value = new Link(node); | ||
t.is(value.constructor.name, 'Link'); | ||
t.deepEqual({...value}, expectedNode); | ||
}); |
50939
374