diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb index 3528200e12bdf445e7d1c01ee6eb473f954847d3..57d0123650539b3c04bdcac678ba7eb9dff50f23 100644 --- a/spec/features/markdown_spec.rb +++ b/spec/features/markdown_spec.rb @@ -62,7 +62,7 @@ describe 'GitLab Markdown' do # Given a header ID, goes to that element's parent (the header), then to its # second sibling (the body). def get_section(id) - @doc.at_css("##{id}").parent.next.next + @doc.at_css("##{id}").parent.next_element end # it 'writes to a file' do @@ -161,6 +161,19 @@ describe 'GitLab Markdown' do end end + describe 'Edge Cases' do + it 'allows markup inside link elements' do + expect(@doc.at_css('a[href="#link-emphasis"]').to_html). + to eq %{text} + + expect(@doc.at_css('a[href="#link-strong"]').to_html). + to eq %{text} + + expect(@doc.at_css('a[href="#link-code"]').to_html). + to eq %{text} + end + end + describe 'EmojiFilter' do it 'parses Emoji' do expect(@doc).to have_selector('img.emoji', count: 10) @@ -176,7 +189,7 @@ describe 'GitLab Markdown' do end describe 'AutolinkFilter' do - let(:list) { get_section('autolinkfilter').parent.search('ul') } + let(:list) { get_section('autolinkfilter').next_element } def item(index) list.at_css("li:nth-child(#{index})") diff --git a/spec/fixtures/markdown.md.erb b/spec/fixtures/markdown.md.erb index 0c1407585572d3e57ce10af744c665c344daae7d..6b79aad8f866b5e4319da40a8e02bd909dae8879 100644 --- a/spec/fixtures/markdown.md.erb +++ b/spec/fixtures/markdown.md.erb @@ -94,6 +94,14 @@ The problem with SanitizationFilter is that it can be too aggressive. | `1 < 3 & 5` | 1 < 3 & 5 | 1 < 3 & 5 | | `` | <foo> | | +### Edge Cases + +Markdown should be usable inside a link. Let's try! + +- [_text_](#link-emphasis) +- [**text**](#link-strong) +- [`text`](#link-code) + ### EmojiFilter Because life would be :zzz: without Emoji, right? :rocket: