From 3ca932844316f567f9ed091d7185ad9fafc27c51 Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Tue, 9 May 2017 14:14:24 +0200 Subject: Fix LaTeX formatting for AsciiDoc wiki --- .../ascii_doc_post_processing_filter_spec.rb | 15 +++++++++++++ spec/lib/banzai/filter/sanitization_filter_spec.rb | 16 ++++++++++++++ spec/lib/gitlab/asciidoc_spec.rb | 25 ++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 spec/lib/banzai/filter/ascii_doc_post_processing_filter_spec.rb (limited to 'spec/lib') diff --git a/spec/lib/banzai/filter/ascii_doc_post_processing_filter_spec.rb b/spec/lib/banzai/filter/ascii_doc_post_processing_filter_spec.rb new file mode 100644 index 00000000000..33b812ef425 --- /dev/null +++ b/spec/lib/banzai/filter/ascii_doc_post_processing_filter_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe Banzai::Filter::AsciiDocPostProcessingFilter, lib: true do + include FilterSpecHelper + + it "adds class for elements with data-math-style" do + result = filter('
some code
and
').to_html + expect(result).to eq('
some code
and
') + end + + it "keeps content when no data-math-style found" do + result = filter('
some code
and
').to_html + expect(result).to eq('
some code
and
') + end +end diff --git a/spec/lib/banzai/filter/sanitization_filter_spec.rb b/spec/lib/banzai/filter/sanitization_filter_spec.rb index fdbc65b5e00..fb7862f49a2 100644 --- a/spec/lib/banzai/filter/sanitization_filter_spec.rb +++ b/spec/lib/banzai/filter/sanitization_filter_spec.rb @@ -97,6 +97,22 @@ describe Banzai::Filter::SanitizationFilter, lib: true do expect(filter(act).to_html).to eq exp end + it 'allows `data-math-style` attribute on `code` and `pre` elements' do + html = <<-HTML +
something
+ something +
something
+ HTML + + output = <<-HTML +
something
+ something +
something
+ HTML + + expect(filter(html).to_html).to eq(output) + end + it 'removes `rel` attribute from `a` elements' do act = %q{Link} exp = %q{Link} diff --git a/spec/lib/gitlab/asciidoc_spec.rb b/spec/lib/gitlab/asciidoc_spec.rb index 2c7ebb15fd7..43d52b941ab 100644 --- a/spec/lib/gitlab/asciidoc_spec.rb +++ b/spec/lib/gitlab/asciidoc_spec.rb @@ -70,6 +70,31 @@ module Gitlab expect(output).to include('rel="nofollow noreferrer noopener"') end end + + context 'LaTex code' do + it 'adds class js-render-math to the output' do + input = <<~MD + :stem: latexmath + + [stem] + ++++ + \sqrt{4} = 2 + ++++ + + another part + + [latexmath] + ++++ + \beta_x \gamma + ++++ + + stem:[2+2] is 4 + MD + + expect(render(input, context)).to include('
eta_x gamma
') + expect(render(input, context)).to include('

2+2 is 4

') + end + end end def render(*args) -- cgit v1.2.3