Skip to content

Commit 8446df9

Browse files
Elad Ben-Israelungoldman
authored andcommitted
feat: allow H1 version headers in changelog (#26)
[conventional-changelog] currently produces H1 headers for major version bumps and H2 headers for minor/patch bumps. This might change in the future but it would help to relax the parser so it will be able to process those types of headers as well. Added unit test. Fixes #14
1 parent 78f3c2d commit 8446df9

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## Unreleased Changes
9+
10+
### Features
11+
12+
- allow version headers in CHANGELOG to use either H1 (#) or H2 (##) headers (#14) - @eladb
13+
814
## [2.5.1](https://github.com/ungoldman/changelog-parser/compare/v2.5.0...v2.5.1) - 2018-12-05
915

1016
### Fixes

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function handleLine (line) {
5656
}
5757

5858
// new version found!
59-
if (line.match(/^## ?[^#]/)) {
59+
if (line.match(/^##? ?[^#]/)) {
6060
if (this.current && this.current.title) pushCurrent(this)
6161

6262
this.current = versionFactory()

test/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ A cool description (optional).
1515
* Update API
1616
* Fix bug #1
1717

18+
# 2.3.0 - 2018-12-18
19+
20+
### Added
21+
22+
- Some changelog generators such as [standard-version](https://github.com/conventional-changelog/standard-version) would produce H1s for major versions and H2s for minor versions. We want the parser to be able to parse both.
23+
1824
## 2.2.3-pre.1 - 2013-02-14
1925

2026
### Added

test/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ var expected = {
4242
]
4343
}
4444
},
45+
{ version: '2.3.0',
46+
title: '2.3.0 - 2018-12-18',
47+
'date': '2018-12-18',
48+
body: '### Added' + EOL + EOL + '- Some changelog generators such as [standard-version](https://github.com/conventional-changelog/standard-version) would produce H1s for major versions and H2s for minor versions. We want the parser to be able to parse both.',
49+
parsed: {
50+
_: [
51+
'Some changelog generators such as standard-version would produce H1s for major versions and H2s for minor versions. We want the parser to be able to parse both.'
52+
],
53+
Added: [
54+
'Some changelog generators such as standard-version would produce H1s for major versions and H2s for minor versions. We want the parser to be able to parse both.'
55+
]
56+
}
57+
},
4558
{ version: '2.2.3-pre.1',
4659
title: '2.2.3-pre.1 - 2013-02-14',
4760
'date': '2013-02-14',

0 commit comments

Comments
 (0)