Commit 00c48b8e authored by Dmitriy Zaporozhets (DZ)'s avatar Dmitriy Zaporozhets (DZ)

Merge branch '24423-footnotes-with-w-in-the-anchor-don-t-render-as-footnotes' into 'master'

Footnotes with "w" in the anchor don't render as footnotes!

See merge request gitlab-org/gitlab!70612
parents 88df1a88 57c5bad1
...@@ -154,7 +154,7 @@ gem 'html-pipeline', '~> 2.13.2' ...@@ -154,7 +154,7 @@ gem 'html-pipeline', '~> 2.13.2'
gem 'deckar01-task_list', '2.3.1' gem 'deckar01-task_list', '2.3.1'
gem 'gitlab-markup', '~> 1.7.1' gem 'gitlab-markup', '~> 1.7.1'
gem 'github-markup', '~> 1.7.0', require: 'github/markup' gem 'github-markup', '~> 1.7.0', require: 'github/markup'
gem 'commonmarker', '~> 0.21' gem 'commonmarker', '~> 0.23.2'
gem 'kramdown', '~> 2.3.1' gem 'kramdown', '~> 2.3.1'
gem 'RedCloth', '~> 4.3.2' gem 'RedCloth', '~> 4.3.2'
gem 'rdoc', '~> 6.3.2' gem 'rdoc', '~> 6.3.2'
......
...@@ -200,8 +200,7 @@ GEM ...@@ -200,8 +200,7 @@ GEM
open4 (~> 1.3) open4 (~> 1.3)
coderay (1.1.3) coderay (1.1.3)
colored2 (3.1.2) colored2 (3.1.2)
commonmarker (0.21.0) commonmarker (0.23.2)
ruby-enum (~> 0.5)
concurrent-ruby (1.1.9) concurrent-ruby (1.1.9)
connection_pool (2.2.2) connection_pool (2.2.2)
contracts (0.11.0) contracts (0.11.0)
...@@ -1116,8 +1115,6 @@ GEM ...@@ -1116,8 +1115,6 @@ GEM
rubocop-rspec (1.44.1) rubocop-rspec (1.44.1)
rubocop (~> 0.87) rubocop (~> 0.87)
rubocop-ast (>= 0.7.1) rubocop-ast (>= 0.7.1)
ruby-enum (0.8.0)
i18n
ruby-fogbugz (0.2.1) ruby-fogbugz (0.2.1)
crack (~> 0.4) crack (~> 0.4)
ruby-magic (0.4.0) ruby-magic (0.4.0)
...@@ -1414,7 +1411,7 @@ DEPENDENCIES ...@@ -1414,7 +1411,7 @@ DEPENDENCIES
capybara-screenshot (~> 1.0.22) capybara-screenshot (~> 1.0.22)
carrierwave (~> 1.3) carrierwave (~> 1.3)
charlock_holmes (~> 0.7.7) charlock_holmes (~> 0.7.7)
commonmarker (~> 0.21) commonmarker (~> 0.23.2)
concurrent-ruby (~> 1.1) concurrent-ruby (~> 1.1)
connection_pool (~> 2.0) connection_pool (~> 2.0)
countries (~> 3.0) countries (~> 3.0)
......
...@@ -133,8 +133,9 @@ RSpec.describe 'GitLab Markdown', :aggregate_failures do ...@@ -133,8 +133,9 @@ RSpec.describe 'GitLab Markdown', :aggregate_failures do
expect(doc.at_css('td:contains("Baz")')['align']).to eq 'left' expect(doc.at_css('td:contains("Baz")')['align']).to eq 'left'
end end
# note that 2 are from the hardcoded <sup>, and 2 from footnotes
aggregate_failures 'permits superscript elements' do aggregate_failures 'permits superscript elements' do
expect(doc).to have_selector('sup', count: 2) expect(doc).to have_selector('sup', count: 4)
end end
aggregate_failures 'permits subscript elements' do aggregate_failures 'permits subscript elements' do
...@@ -148,6 +149,11 @@ RSpec.describe 'GitLab Markdown', :aggregate_failures do ...@@ -148,6 +149,11 @@ RSpec.describe 'GitLab Markdown', :aggregate_failures do
aggregate_failures "removes `href` from `a` elements if it's fishy" do aggregate_failures "removes `href` from `a` elements if it's fishy" do
expect(doc).not_to have_selector('a[href*="javascript"]') expect(doc).not_to have_selector('a[href*="javascript"]')
end end
aggregate_failures 'permits footnotes' do
expect(doc).to have_selector('section.footnotes ol li p:contains("Footnote 1")')
expect(doc).to have_selector('section.footnotes ol li p:contains("Footnote with w")')
end
end end
describe 'Escaping' do describe 'Escaping' do
......
...@@ -52,6 +52,15 @@ Redcarpet supports this superscript syntax ( x^2 ). ...@@ -52,6 +52,15 @@ Redcarpet supports this superscript syntax ( x^2 ).
This (C<sub>6</sub>H<sub>12</sub>O<sub>6</sub>) is an example of subscripts in Markdown. This (C<sub>6</sub>H<sub>12</sub>O<sub>6</sub>) is an example of subscripts in Markdown.
### Footnotes
This is footnote 1.[^f1]
A footnote with a `w` was failing.[^f2-w]
[^f1]: Footnote 1
[^f2-w]: Footnote with w
### Next step ### Next step
After the Markdown has been turned into HTML, it gets passed through... After the Markdown has been turned into HTML, it gets passed through...
......
...@@ -34,15 +34,16 @@ RSpec.describe Banzai::Pipeline::FullPipeline do ...@@ -34,15 +34,16 @@ RSpec.describe Banzai::Pipeline::FullPipeline do
let(:identifier) { html[/.*fnref1-(\d+).*/, 1] } let(:identifier) { html[/.*fnref1-(\d+).*/, 1] }
let(:footnote_markdown) do let(:footnote_markdown) do
<<~EOF <<~EOF
first[^1] and second[^second] first[^1] and second[^second] and twenty[^twenty]
[^1]: one [^1]: one
[^second]: two [^second]: two
[^twenty]: twenty
EOF EOF
end end
let(:filtered_footnote) do let(:filtered_footnote) do
<<~EOF <<~EOF
<p dir="auto">first<sup class="footnote-ref"><a href="#fn1-#{identifier}" id="fnref1-#{identifier}">1</a></sup> and second<sup class="footnote-ref"><a href="#fn2-#{identifier}" id="fnref2-#{identifier}">2</a></sup></p> <p dir="auto">first<sup class="footnote-ref"><a href="#fn1-#{identifier}" id="fnref1-#{identifier}">1</a></sup> and second<sup class="footnote-ref"><a href="#fn2-#{identifier}" id="fnref2-#{identifier}">2</a></sup> and twenty<sup class="footnote-ref"><a href="#fn3-#{identifier}" id="fnref3-#{identifier}">3</a></sup></p>
<section class="footnotes"><ol> <section class="footnotes"><ol>
<li id="fn1-#{identifier}"> <li id="fn1-#{identifier}">
...@@ -51,6 +52,9 @@ RSpec.describe Banzai::Pipeline::FullPipeline do ...@@ -51,6 +52,9 @@ RSpec.describe Banzai::Pipeline::FullPipeline do
<li id="fn2-#{identifier}"> <li id="fn2-#{identifier}">
<p>two <a href="#fnref2-#{identifier}" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1">↩</gl-emoji></a></p> <p>two <a href="#fnref2-#{identifier}" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1">↩</gl-emoji></a></p>
</li> </li>
<li id="fn3-#{identifier}">
<p>twenty <a href="#fnref3-#{identifier}" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1">↩</gl-emoji></a></p>
</li>
</ol></section> </ol></section>
EOF EOF
end end
......
...@@ -41,7 +41,7 @@ module MarkdownMatchers ...@@ -41,7 +41,7 @@ module MarkdownMatchers
set_default_markdown_messages set_default_markdown_messages
match do |actual| match do |actual|
expect(actual).to have_selector('gl-emoji', count: 10) expect(actual).to have_selector('gl-emoji', count: 12)
emoji_element = actual.at_css('gl-emoji') emoji_element = actual.at_css('gl-emoji')
expect(emoji_element['data-name'].to_s).not_to be_empty expect(emoji_element['data-name'].to_s).not_to be_empty
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment