Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
def6446d
Commit
def6446d
authored
Mar 03, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace `[[_TOC_]]` tag even if `toc` result is blank
parent
82bc6c62
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
6 deletions
+8
-6
lib/banzai/filter/gollum_tags_filter.rb
lib/banzai/filter/gollum_tags_filter.rb
+5
-3
spec/lib/banzai/filter/gollum_tags_filter_spec.rb
spec/lib/banzai/filter/gollum_tags_filter_spec.rb
+2
-2
spec/lib/banzai/pipeline/wiki_pipeline_spec.rb
spec/lib/banzai/pipeline/wiki_pipeline_spec.rb
+1
-1
No files found.
lib/banzai/filter/gollum_tags_filter.rb
View file @
def6446d
...
@@ -26,6 +26,10 @@ module Banzai
...
@@ -26,6 +26,10 @@ module Banzai
# * [[http://example.com/images/logo.png]]
# * [[http://example.com/images/logo.png]]
# * [[http://example.com/images/logo.png|alt=Logo]]
# * [[http://example.com/images/logo.png|alt=Logo]]
#
#
# - Insert a Table of Contents list:
#
# * [[_TOC_]]
#
# Based on Gollum::Filter::Tags
# Based on Gollum::Filter::Tags
#
#
# Context options:
# Context options:
...
@@ -61,8 +65,6 @@ module Banzai
...
@@ -61,8 +65,6 @@ module Banzai
# before this one, it will be converted into `[[<em>TOC</em>]]`, so it
# before this one, it will be converted into `[[<em>TOC</em>]]`, so it
# needs special-case handling
# needs special-case handling
if
toc_tag?
(
node
)
if
toc_tag?
(
node
)
next
unless
result
[
:toc
].
present?
process_toc_tag
(
node
)
process_toc_tag
(
node
)
else
else
content
=
node
.
content
content
=
node
.
content
...
@@ -85,7 +87,7 @@ module Banzai
...
@@ -85,7 +87,7 @@ module Banzai
# Replace an entire `[[<em>TOC</em>]]` node with the result generated by
# Replace an entire `[[<em>TOC</em>]]` node with the result generated by
# TableOfContentsFilter
# TableOfContentsFilter
def
process_toc_tag
(
node
)
def
process_toc_tag
(
node
)
node
.
parent
.
parent
.
replace
(
result
[
:toc
])
node
.
parent
.
parent
.
replace
(
result
[
:toc
]
.
presence
||
''
)
end
end
# Process a single tag into its final HTML form.
# Process a single tag into its final HTML form.
...
...
spec/lib/banzai/filter/gollum_tags_filter_spec.rb
View file @
def6446d
...
@@ -95,10 +95,10 @@ describe Banzai::Filter::GollumTagsFilter, lib: true do
...
@@ -95,10 +95,10 @@ describe Banzai::Filter::GollumTagsFilter, lib: true do
end
end
it
'handles an empty ToC result'
do
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
)
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
end
end
end
spec/lib/banzai/pipeline/wiki_pipeline_spec.rb
View file @
def6446d
...
@@ -46,7 +46,7 @@ describe Banzai::Pipeline::WikiPipeline do
...
@@ -46,7 +46,7 @@ describe Banzai::Pipeline::WikiPipeline do
aggregate_failures
do
aggregate_failures
do
expect
(
output
).
not_to
include
(
'<ul>'
)
expect
(
output
).
not_to
include
(
'<ul>'
)
expect
(
output
).
to
include
(
'[[<em>TOC</em>]]'
)
expect
(
output
).
not_
to
include
(
'[[<em>TOC</em>]]'
)
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment