Markdown headings can have trailing hashes

https://daringfireball.net/projects/markdown/syntax#header

May as well allow trailing =s as well though
https://ruby.github.io/rdoc/RDoc/Markup.html#class-RDoc::Markup-label-Headers
doesn't mention, I've seen in the wild and even added to text
documents myself when forgetting that I'm not editing mediawiki
markup
This commit is contained in:
Mike Linksvayer 2018-08-27 12:00:25 -07:00
parent 4f56b83883
commit 04cd733607
2 changed files with 9 additions and 1 deletions

View File

@ -11,7 +11,7 @@ module Licensee
UNDERLINE_REGEX = /\n[-=]+/m UNDERLINE_REGEX = /\n[-=]+/m
CONTENT_REGEX = /^ CONTENT_REGEX = /^
(?: # Header lookbehind (?: # Header lookbehind
[\#=]+\s#{TITLE_REGEX} # Start of hashes or rdoc header [\#=]+\s#{TITLE_REGEX}\s*[\#=]* # Start of hashes or rdoc header
| |
#{TITLE_REGEX}#{UNDERLINE_REGEX} # Start of underlined header #{TITLE_REGEX}#{UNDERLINE_REGEX} # Start of underlined header
)$ )$

View File

@ -107,6 +107,14 @@ RSpec.describe Licensee::ProjectFiles::ReadmeFile do
end end
end end
context 'With trailing hashes' do
let(:content) { "## License ##\n\nhello world" }
it 'returns the license' do
expect(license).to eql('hello world')
end
end
context 'Rdoc' do context 'Rdoc' do
let(:content) { "== License:\n\nhello world" } let(:content) { "== License:\n\nhello world" }