Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
c9b11322
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c9b11322
编写于
3月 01, 2016
作者:
R
Robert Speicher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add FilterArray class to Banzai
上级
6aa50165
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
76 addition
and
13 deletion
+76
-13
lib/banzai/filter_array.rb
lib/banzai/filter_array.rb
+27
-0
lib/banzai/pipeline/base_pipeline.rb
lib/banzai/pipeline/base_pipeline.rb
+1
-1
lib/banzai/pipeline/broadcast_message_pipeline.rb
lib/banzai/pipeline/broadcast_message_pipeline.rb
+1
-1
lib/banzai/pipeline/combined_pipeline.rb
lib/banzai/pipeline/combined_pipeline.rb
+1
-1
lib/banzai/pipeline/gfm_pipeline.rb
lib/banzai/pipeline/gfm_pipeline.rb
+1
-1
lib/banzai/pipeline/plain_markdown_pipeline.rb
lib/banzai/pipeline/plain_markdown_pipeline.rb
+1
-1
lib/banzai/pipeline/post_process_pipeline.rb
lib/banzai/pipeline/post_process_pipeline.rb
+1
-1
lib/banzai/pipeline/reference_extraction_pipeline.rb
lib/banzai/pipeline/reference_extraction_pipeline.rb
+1
-1
lib/banzai/pipeline/single_line_pipeline.rb
lib/banzai/pipeline/single_line_pipeline.rb
+1
-1
lib/banzai/pipeline/wiki_pipeline.rb
lib/banzai/pipeline/wiki_pipeline.rb
+2
-5
spec/lib/banzai/filter_array_spec.rb
spec/lib/banzai/filter_array_spec.rb
+39
-0
未找到文件。
lib/banzai/filter_array.rb
0 → 100644
浏览文件 @
c9b11322
module
Banzai
class
FilterArray
<
Array
# Insert a value immediately after another value
#
# If the preceding value does not exist, the new value is added to the end
# of the Array.
def
insert_after
(
after_value
,
value
)
i
=
index
(
after_value
)
||
length
-
1
insert
(
i
+
1
,
value
)
end
# Insert a value immediately before another value
#
# If the succeeding value does not exist, the new value is added to the
# beginning of the Array.
def
insert_before
(
before_value
,
value
)
i
=
index
(
before_value
)
||
-
1
if
i
<
0
unshift
(
value
)
else
insert
(
i
,
value
)
end
end
end
end
lib/banzai/pipeline/base_pipeline.rb
浏览文件 @
c9b11322
...
...
@@ -4,7 +4,7 @@ module Banzai
module
Pipeline
class
BasePipeline
def
self
.
filters
[]
FilterArray
[]
end
def
self
.
transform_context
(
context
)
...
...
lib/banzai/pipeline/broadcast_message_pipeline.rb
浏览文件 @
c9b11322
...
...
@@ -2,7 +2,7 @@ module Banzai
module
Pipeline
class
BroadcastMessagePipeline
<
DescriptionPipeline
def
self
.
filters
@filters
||=
[
@filters
||=
FilterArray
[
Filter
::
MarkdownFilter
,
Filter
::
SanitizationFilter
,
...
...
lib/banzai/pipeline/combined_pipeline.rb
浏览文件 @
c9b11322
...
...
@@ -10,7 +10,7 @@ module Banzai
end
def
self
.
filters
pipelines
.
flat_map
(
&
:filters
)
FilterArray
.
new
(
pipelines
.
flat_map
(
&
:filters
)
)
end
def
self
.
transform_context
(
context
)
...
...
lib/banzai/pipeline/gfm_pipeline.rb
浏览文件 @
c9b11322
...
...
@@ -2,7 +2,7 @@ module Banzai
module
Pipeline
class
GfmPipeline
<
BasePipeline
def
self
.
filters
@filters
||=
[
@filters
||=
FilterArray
[
Filter
::
SyntaxHighlightFilter
,
Filter
::
SanitizationFilter
,
...
...
lib/banzai/pipeline/plain_markdown_pipeline.rb
浏览文件 @
c9b11322
...
...
@@ -2,7 +2,7 @@ module Banzai
module
Pipeline
class
PlainMarkdownPipeline
<
BasePipeline
def
self
.
filters
[
FilterArray
[
Filter
::
MarkdownFilter
]
end
...
...
lib/banzai/pipeline/post_process_pipeline.rb
浏览文件 @
c9b11322
...
...
@@ -2,7 +2,7 @@ module Banzai
module
Pipeline
class
PostProcessPipeline
<
BasePipeline
def
self
.
filters
[
FilterArray
[
Filter
::
RelativeLinkFilter
,
Filter
::
RedactorFilter
]
...
...
lib/banzai/pipeline/reference_extraction_pipeline.rb
浏览文件 @
c9b11322
...
...
@@ -2,7 +2,7 @@ module Banzai
module
Pipeline
class
ReferenceExtractionPipeline
<
BasePipeline
def
self
.
filters
[
FilterArray
[
Filter
::
ReferenceGathererFilter
]
end
...
...
lib/banzai/pipeline/single_line_pipeline.rb
浏览文件 @
c9b11322
...
...
@@ -2,7 +2,7 @@ module Banzai
module
Pipeline
class
SingleLinePipeline
<
GfmPipeline
def
self
.
filters
@filters
||=
[
@filters
||=
FilterArray
[
Filter
::
SanitizationFilter
,
Filter
::
EmojiFilter
,
...
...
lib/banzai/pipeline/wiki_pipeline.rb
浏览文件 @
c9b11322
...
...
@@ -4,11 +4,8 @@ module Banzai
module
Pipeline
class
WikiPipeline
<
FullPipeline
def
self
.
filters
@filters
||=
begin
filters
=
super
toc
=
filters
.
index
(
Filter
::
TableOfContentsFilter
)
filters
.
insert
(
toc
+
1
,
Filter
::
GollumTagsFilter
)
end
@filters
||=
super
.
insert_after
(
Filter
::
TableOfContentsFilter
,
Filter
::
GollumTagsFilter
)
end
end
end
...
...
spec/lib/banzai/filter_array_spec.rb
0 → 100644
浏览文件 @
c9b11322
require
'spec_helper'
describe
Banzai
::
FilterArray
do
describe
'#insert_after'
do
it
'inserts an element after a provided element'
do
filters
=
described_class
.
new
(
%w(a b c)
)
filters
.
insert_after
(
'b'
,
'1'
)
expect
(
filters
).
to
eq
%w(a b 1 c)
end
it
'inserts an element at the end when the provided element does not exist'
do
filters
=
described_class
.
new
(
%w(a b c)
)
filters
.
insert_after
(
'd'
,
'1'
)
expect
(
filters
).
to
eq
%w(a b c 1)
end
end
describe
'#insert_before'
do
it
'inserts an element before a provided element'
do
filters
=
described_class
.
new
(
%w(a b c)
)
filters
.
insert_before
(
'b'
,
'1'
)
expect
(
filters
).
to
eq
%w(a 1 b c)
end
it
'inserts an element at the beginning when the provided element does not exist'
do
filters
=
described_class
.
new
(
%w(a b c)
)
filters
.
insert_before
(
'd'
,
'1'
)
expect
(
filters
).
to
eq
%w(1 a b c)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录