diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/markdown_spec.rb | 6 | ||||
-rw-r--r-- | spec/fixtures/markdown.md.erb | 34 | ||||
-rw-r--r-- | spec/javascripts/notes_spec.js | 3 | ||||
-rw-r--r-- | spec/lib/banzai/filter/mermaid_filter_spec.rb | 12 | ||||
-rw-r--r-- | spec/lib/banzai/filter/syntax_highlight_filter_spec.rb | 2 |
5 files changed, 55 insertions, 2 deletions
diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb index b70d3060f05..cc1b187ff54 100644 --- a/spec/features/markdown_spec.rb +++ b/spec/features/markdown_spec.rb @@ -69,6 +69,12 @@ describe 'GitLab Markdown' do end end + it 'parses mermaid code block' do + aggregate_failures do + expect(doc).to have_selector('pre.code.js-render-mermaid') + end + end + it 'parses strikethroughs' do expect(doc).to have_selector(%{del:contains("and this text doesn't")}) end diff --git a/spec/fixtures/markdown.md.erb b/spec/fixtures/markdown.md.erb index 4f46e40ce7a..638cd8b07c8 100644 --- a/spec/fixtures/markdown.md.erb +++ b/spec/fixtures/markdown.md.erb @@ -268,3 +268,37 @@ However the wrapping tags can not be mixed as such - ### Videos ![My Video](/assets/videos/gitlab-demo.mp4) + +### Mermaid + +> If this is not rendered correctly, see +https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/user/markdown.md#mermaid + +It is possible to generate diagrams and flowcharts from text using [Mermaid][mermaid]. + +In order to generate a diagram or flowchart, you should write your text inside the `mermaid` block. + +Example: + + ```mermaid + graph TD; + A-->B; + A-->C; + B-->D; + C-->D; + ``` + +Becomes: + +```mermaid +graph TD; + A-->B; + A-->C; + B-->D; + C-->D; +``` + +For details see the [Mermaid official page][mermaid]. + +[mermaid]: https://mermaidjs.github.io/ "Mermaid website" + diff --git a/spec/javascripts/notes_spec.js b/spec/javascripts/notes_spec.js index 928a4b461cc..63abac222c4 100644 --- a/spec/javascripts/notes_spec.js +++ b/spec/javascripts/notes_spec.js @@ -4,8 +4,9 @@ import 'autosize'; import '~/gl_form'; import '~/lib/utils/text_utility'; -import '~/render_gfm'; import '~/render_math'; +import '~/render_mermaid'; +import '~/render_gfm'; import '~/notes'; (function() { diff --git a/spec/lib/banzai/filter/mermaid_filter_spec.rb b/spec/lib/banzai/filter/mermaid_filter_spec.rb new file mode 100644 index 00000000000..532d25e121d --- /dev/null +++ b/spec/lib/banzai/filter/mermaid_filter_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe Banzai::Filter::MermaidFilter do + include FilterSpecHelper + + it 'adds `js-render-mermaid` class to the `pre` tag' do + doc = filter("<pre class='code highlight js-syntax-highlight mermaid' lang='mermaid' v-pre='true'><code>graph TD;\n A-->B;\n</code></pre>") + result = doc.xpath('descendant-or-self::pre').first + + expect(result[:class]).to include('js-render-mermaid') + end +end diff --git a/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb b/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb index 5a23e0e70cc..9f2efa05a01 100644 --- a/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb +++ b/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb @@ -31,7 +31,7 @@ describe Banzai::Filter::SyntaxHighlightFilter do it "highlights as plaintext" do result = filter('<pre><code lang="ruby">This is a test</code></pre>') - expect(result.to_html).to eq('<pre class="code highlight" lang="" v-pre="true"><code>This is a test</code></pre>') + expect(result.to_html).to eq('<pre class="code highlight js-syntax-highlight" lang="" v-pre="true"><code>This is a test</code></pre>') end end end |