Skip to content

Commit d3c05af

Browse files
authored
Merge pull request #320 from f0i/changelog-parser
[cli] add support for subheadings in changelog
2 parents ae1299c + 8a5e56f commit d3c05af

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

cli/helpers/find-changelog-entry.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ import {toMarkdown} from 'mdast-util-to-markdown';
44
export function findChangelogEntry(changelog : string, version : string) : string {
55
let tree = fromMarkdown(changelog);
66
let found = false;
7+
let depth = 0;
78
let nodes = [];
89

910
for (let node of tree.children) {
1011
if (found) {
11-
if (node.type === 'heading') {
12+
if (node.type === 'heading' && node.depth <= depth) {
1213
break;
1314
}
1415
else {
1516
nodes.push(node);
1617
}
1718
}
1819
else if (node.type === 'heading' && toMarkdown(node).match(new RegExp(`\\b${version}\\b`))) {
20+
depth = node.depth;
1921
found = true;
2022
}
2123
}

0 commit comments

Comments
 (0)