summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2016-03-03 12:36:36 -0500
committerRobert Speicher <rspeicher@gmail.com>2016-03-03 12:41:40 -0500
commitdef6446dad808f2ff0f725df7a08f81365719586 (patch)
treef22d3f41c733ee73052da434b5191234506325bc
parent82bc6c6229b626dae74a12a56243c89aa8348cc3 (diff)
downloadgitlab-ce-rs-wiki-pipeline-spec.tar.gz
Replace `[[_TOC_]]` tag even if `toc` result is blankrs-wiki-pipeline-spec
-rw-r--r--lib/banzai/filter/gollum_tags_filter.rb8
-rw-r--r--spec/lib/banzai/filter/gollum_tags_filter_spec.rb4
-rw-r--r--spec/lib/banzai/pipeline/wiki_pipeline_spec.rb2
3 files changed, 8 insertions, 6 deletions
diff --git a/lib/banzai/filter/gollum_tags_filter.rb b/lib/banzai/filter/gollum_tags_filter.rb
index bcf5297e382..f31f921903b 100644
--- a/lib/banzai/filter/gollum_tags_filter.rb
+++ b/lib/banzai/filter/gollum_tags_filter.rb
@@ -26,6 +26,10 @@ module Banzai
# * [[http://example.com/images/logo.png]]
# * [[http://example.com/images/logo.png|alt=Logo]]
#
+ # - Insert a Table of Contents list:
+ #
+ # * [[_TOC_]]
+ #
# Based on Gollum::Filter::Tags
#
# Context options:
@@ -61,8 +65,6 @@ module Banzai
# before this one, it will be converted into `[[<em>TOC</em>]]`, so it
# needs special-case handling
if toc_tag?(node)
- next unless result[:toc].present?
-
process_toc_tag(node)
else
content = node.content
@@ -85,7 +87,7 @@ module Banzai
# Replace an entire `[[<em>TOC</em>]]` node with the result generated by
# TableOfContentsFilter
def process_toc_tag(node)
- node.parent.parent.replace(result[:toc])
+ node.parent.parent.replace(result[:toc].presence || '')
end
# Process a single tag into its final HTML form.
diff --git a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
index 8c71889caf0..5e23c5c319a 100644
--- a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
+++ b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
@@ -95,10 +95,10 @@ describe Banzai::Filter::GollumTagsFilter, lib: true do
end
it 'handles an empty ToC result' do
- input = output = "<p>[[<em>TOC</em>]]</p>"
+ input = "<p>[[<em>TOC</em>]]</p>"
doc = described_class.call(input, project_wiki: project_wiki)
- expect(doc.to_html).to eq output
+ expect(doc.to_html).to eq ''
end
end
end
diff --git a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb
index f42c11cedd4..3e25406e498 100644
--- a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb
+++ b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb
@@ -46,7 +46,7 @@ describe Banzai::Pipeline::WikiPipeline do
aggregate_failures do
expect(output).not_to include('<ul>')
- expect(output).to include('[[<em>TOC</em>]]')
+ expect(output).not_to include('[[<em>TOC</em>]]')
end
end
end