lib/grammar.tt in parse_a_changelog-1.0.2 vs lib/grammar.tt in parse_a_changelog-1.1.0

- old
+ new

@@ -2,85 +2,93 @@ rule changelog changelog_header unreleased_section releases_section diff_section? end rule changelog_header - '# Changelog' "\n" - 'All notable changes to this project will be documented in this file.' "\n" - "\n" - 'The format is based on [Keep a Changelog](http' 's'? '://keepachangelog.com/en/1.0.0/)' "\n" - 'and this project adheres to [Semantic Versioning](http' 's'? '://semver.org/spec/v2.0.0.html).' "\n" - "\n" + '# Changelog' new_line + 'All notable changes to this project will be documented in this file.' new_line + new_line + 'The format is based on [Keep a Changelog](http' 's'? '://keepachangelog.com/en/1.0.0/)' new_line + 'and this project adheres to [Semantic Versioning](http' 's'? '://semver.org/spec/v2.0.0.html).' new_line + new_line end rule unreleased_section - unreleased_header change_section? ("\n" change_section)* + unreleased_header change_section? (new_line change_section)* end rule unreleased_header - '## ' '['? 'Unreleased' ']'? "\n" + '## ' '['? 'Unreleased' ']'? new_line end rule change_section change_header change+ end rule change_header - '### ' ('Added' / 'Changed' / 'Deprecated' / 'Removed' / 'Fixed' / 'Security') "\n" + '### ' ('Added' / 'Changed' / 'Deprecated' / 'Removed' / 'Fixed' / 'Security') new_line end rule change - ('- ' / ' ') (!"\n" .)+ "\n"? + ('- ' / ' ') (!new_line .)+ new_line? end rule releases_section release* end rule release - "\n" release_header change_section? ("\n" change_section)* + new_line release_header change_section? (new_line change_section)* end rule release_header - '## ' '['? release_version ']'? ' - ' release_date "\n" + '## ' '['? release_version ']'? ' - ' release_date new_line end rule release_version - [0-9]+ '.' [0-9]+ '.' [0-9]+ pre_release_version + [0-9]+ '.' [0-9]+ '.' [0-9]+ pre_release_version metadata end rule pre_release_version - ( '-' [0-9A-Za-z-]+ pre_release_group* ) / '' + ( '-' [0-9A-Za-z-]+ dot_separated_group* ) / '' end - rule pre_release_group + rule metadata + ( '+' [0-9A-Za-z-]+ dot_separated_group* ) / '' + end + + rule dot_separated_group '.' [0-9A-Za-z-]+ end rule release_date [0-9] [0-9] [0-9] [0-9] '-' [0-9] [0-9] '-' [0-9] [0-9] end rule diff_section - "\n" unreleased_diff release_diff* initial_release? + new_line unreleased_diff release_diff* initial_release? end rule unreleased_diff - '[Unreleased]: ' release_url "\n" + '[Unreleased]: ' release_url new_line end rule initial_release - '[' release_version ']: ' 'https://github.com/' (!'/' .)+ '/' (!'/' .)+ '/releases/tag/v' release_version "\n" + '[' release_version ']: ' 'https://github.com/' (!'/' .)+ '/' (!'/' .)+ '/releases/tag/v' release_version new_line end rule release_diff - '[' release_version ']: ' release_url "\n" + '[' release_version ']: ' release_url new_line end rule release_url 'https://github.com/' (!'/' .)+ '/' (!'/' .)+ '/compare/' diff_version '...' diff_version end rule diff_version 'HEAD' / ( 'v' release_version ) + end + + rule new_line + "\n" end end