Skip to content

Feat: Allow named markdown anchor links #966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/github_changelog_generator/reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def initialize(options = {})
defaults = {
heading_level: "##",
heading_structures: [
/^## \[(?<version>.+?)\]\((?<url>.+?)\)( \((?<date>.+?)\))?$/, # rubocop:disable Lint/MixedRegexpCaptureTypes
/^## \[(?<version>.+?)\](\((?<url>.+?)\))?( \((?<date>.+?)\))?$/, # rubocop:disable Lint/MixedRegexpCaptureTypes
/^## (?<version>.+?)( \((?<date>.+?)\))?$/ # rubocop:disable Lint/MixedRegexpCaptureTypes
]
}
Expand All @@ -45,6 +45,8 @@ def initialize(options = {})
# The following heading structures are currently valid:
# - ## [v1.0.2](https://github.com/zanui/chef-thumbor/tree/v1.0.1) (2015-03-24)
# - ## [v1.0.2](https://github.com/zanui/chef-thumbor/tree/v1.0.1)
# - ## [v1.0.2] (2015-03-24)
# - ## [v1.0.2]
# - ## v1.0.2 (2015-03-24)
# - ## v1.0.2
#
Expand Down
9 changes: 9 additions & 0 deletions spec/unit/reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
it { is_expected.to include("url" => "https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.3.10") }
it { is_expected.to include("date" => "2015-03-18") }
end
context "when given a named link" do
subject { @reader.parse_heading("## [1.3.10]") }
it { is_expected.to include("version" => "1.3.10") }
end
context "when given a named link with date" do
subject { @reader.parse_heading("## [1.3.10] (2015-03-18)") }
it { is_expected.to include("version" => "1.3.10") }
it { is_expected.to include("date" => "2015-03-18") }
end
context "when no url and date is provided" do
subject { @reader.parse_heading("## foobar") }
it { is_expected.to include("version" => "foobar", "url" => nil, "date" => nil) }
Expand Down