qiita-markdown 0.20.1 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of qiita-markdown might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +3 -2
- data/CHANGELOG.md +5 -0
- data/README.md +15 -14
- data/lib/qiita/markdown.rb +2 -1
- data/lib/qiita/markdown/filters/{code.rb → code_block.rb} +1 -1
- data/lib/qiita/markdown/filters/final_sanitizer.rb +4 -0
- data/lib/qiita/markdown/filters/inline_code_color.rb +43 -0
- data/lib/qiita/markdown/processor.rb +2 -1
- data/lib/qiita/markdown/version.rb +1 -1
- data/spec/qiita/markdown/filters/inline_code_color_spec.rb +205 -0
- data/spec/qiita/markdown/processor_spec.rb +82 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4ebdec684801c23c2b2183ea2498383180d4382
|
4
|
+
data.tar.gz: ebaf06c2afa12f825f6b21a122e36705da59bf13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e237616c63dfb7d0a6f332c4b8327afcf39bfa3ea285767890efb49fcb43ffa1b7563b8943248fd5f8948abc4875d462c3382268f53b27214bd6e2d42a318dcb
|
7
|
+
data.tar.gz: 7c7d5e9a117e28d883ec45c2e7cab9dba35b39ad468ca16a372f7403a6b2f9c74fd74b2e151f42e1b497d525701a46c6c224e46a548fb481ccc7374f54473fe6
|
data/.rubocop_todo.yml
CHANGED
@@ -53,7 +53,7 @@ Style/FileName:
|
|
53
53
|
Style/MutableConstant:
|
54
54
|
Exclude:
|
55
55
|
- 'lib/qiita/markdown/filters/checkbox.rb'
|
56
|
-
- 'lib/qiita/markdown/filters/
|
56
|
+
- 'lib/qiita/markdown/filters/code_block.rb'
|
57
57
|
- 'lib/qiita/markdown/filters/sanitize.rb'
|
58
58
|
- 'lib/qiita/markdown/filters/simplify.rb'
|
59
59
|
- 'lib/qiita/markdown/filters/syntax_highlight.rb'
|
@@ -67,7 +67,7 @@ Style/MutableConstant:
|
|
67
67
|
# SupportedStyles: skip_modifier_ifs, always
|
68
68
|
Style/Next:
|
69
69
|
Exclude:
|
70
|
-
- 'lib/qiita/markdown/filters/
|
70
|
+
- 'lib/qiita/markdown/filters/code_block.rb'
|
71
71
|
- 'lib/qiita/markdown/filters/image_link.rb'
|
72
72
|
|
73
73
|
# Offense count: 11
|
@@ -95,6 +95,7 @@ Style/PerlBackrefs:
|
|
95
95
|
Style/RegexpLiteral:
|
96
96
|
Exclude:
|
97
97
|
- 'lib/qiita/markdown/filters/mention.rb'
|
98
|
+
- 'lib/qiita/markdown/filters/inline_code_color.rb'
|
98
99
|
|
99
100
|
# Offense count: 3
|
100
101
|
# Cop supports --auto-correct.
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -56,20 +56,21 @@ processor.call(text)
|
|
56
56
|
`.new` and `#call` can take optional context as a Hash with following keys:
|
57
57
|
|
58
58
|
```
|
59
|
-
:allowed_usernames
|
60
|
-
:asset_path
|
61
|
-
:asset_root
|
62
|
-
:base_url
|
63
|
-
:default_language
|
64
|
-
:emoji_names
|
65
|
-
:emoji_url_generator
|
66
|
-
|
67
|
-
:hostname
|
68
|
-
:
|
69
|
-
:
|
70
|
-
|
71
|
-
:
|
72
|
-
:
|
59
|
+
:allowed_usernames - A list of usernames allowed to be username. (Array<String>)
|
60
|
+
:asset_path - URL path to link to emoji sprite. (String)
|
61
|
+
:asset_root - Base URL to link to emoji sprite. (String)
|
62
|
+
:base_url - Used to construct links to user profile pages for each. (String)
|
63
|
+
:default_language - Default language used if no language detected from code. (String)
|
64
|
+
:emoji_names - A list of allowed emoji names. (Array<String>)
|
65
|
+
:emoji_url_generator - #call'able object that accepts emoji name as argument and returns emoji image URL. (#call)
|
66
|
+
The original implementation is used when the generator returned a falsey value.
|
67
|
+
:hostname - FQDN. Used to check whether or not each URL of `href` attributes is external site. (String)
|
68
|
+
:inline_code_color_class_name - Class name for inline code color. (String)
|
69
|
+
:language_aliases - Alias table for some language names. (Hash)
|
70
|
+
:markdown - A hash for enabling / disabling optional Markdown syntax. (Hash)
|
71
|
+
Currently only :footnotes (default: true) is supported.
|
72
|
+
:rule - Sanitization rule table. (Hash)
|
73
|
+
:script - A flag to allow to embed script element. (Boolean)
|
73
74
|
```
|
74
75
|
|
75
76
|
```ruby
|
data/lib/qiita/markdown.rb
CHANGED
@@ -8,7 +8,7 @@ require "pygments"
|
|
8
8
|
require "sanitize"
|
9
9
|
|
10
10
|
require "qiita/markdown/filters/checkbox"
|
11
|
-
require "qiita/markdown/filters/
|
11
|
+
require "qiita/markdown/filters/code_block"
|
12
12
|
require "qiita/markdown/filters/emoji"
|
13
13
|
require "qiita/markdown/filters/external_link"
|
14
14
|
require "qiita/markdown/filters/final_sanitizer"
|
@@ -16,6 +16,7 @@ require "qiita/markdown/filters/footnote"
|
|
16
16
|
require "qiita/markdown/filters/greenmat"
|
17
17
|
require "qiita/markdown/filters/group_mention"
|
18
18
|
require "qiita/markdown/filters/image_link"
|
19
|
+
require "qiita/markdown/filters/inline_code_color"
|
19
20
|
require "qiita/markdown/filters/mention"
|
20
21
|
require "qiita/markdown/filters/simplify"
|
21
22
|
require "qiita/markdown/filters/syntax_highlight"
|
@@ -12,7 +12,7 @@ module Qiita
|
|
12
12
|
# 3. Adds detected code data into `result[:codes]`.
|
13
13
|
#
|
14
14
|
# You can pass language aliases table via context[:language_aliases].
|
15
|
-
class
|
15
|
+
class CodeBlock < HTML::Pipeline::Filter
|
16
16
|
def call
|
17
17
|
result[:codes] ||= []
|
18
18
|
doc.search("pre").each do |pre|
|
@@ -85,6 +85,9 @@ module Qiita
|
|
85
85
|
"src",
|
86
86
|
"type",
|
87
87
|
],
|
88
|
+
"span" => [
|
89
|
+
"style",
|
90
|
+
],
|
88
91
|
"td" => [
|
89
92
|
"style",
|
90
93
|
],
|
@@ -129,6 +132,7 @@ module Qiita
|
|
129
132
|
css: {
|
130
133
|
properties: [
|
131
134
|
"text-align",
|
135
|
+
"background-color",
|
132
136
|
],
|
133
137
|
},
|
134
138
|
elements: [
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Qiita
|
2
|
+
module Markdown
|
3
|
+
module Filters
|
4
|
+
class InlineCodeColor < HTML::Pipeline::Filter
|
5
|
+
DEFAULT_CLASS_NAME = "inline-code-color".freeze
|
6
|
+
|
7
|
+
REGEXPS = Regexp.union(
|
8
|
+
/\#(?:\h{3}|\h{6})/,
|
9
|
+
/rgba?\(\s*(?:\d+(?:\,|\s)\s*){2}\d+\s*\)/,
|
10
|
+
/rgba?\(\s*(?:\d+%(?:\,|\s)\s*){2}\d+%\s*\)/,
|
11
|
+
/rgba?\(\s*(?:\d+\,\s*){3}\d*\.?\d+%?\s*\)/,
|
12
|
+
/rgba?\(\s*(?:\d+\s*){2}\d+\s*\/\s*\d?\.?\d+%?\s*\)/,
|
13
|
+
/rgba?\(\s*(?:\d+%\s*){2}\d+%\s*\/\s*\d?\.?\d+%?\s*\)/,
|
14
|
+
/hsla?\(\s*\d+(?:deg|rad|grad|turn)?\,\s*\d+%\,\s*\d+%\s*\)/,
|
15
|
+
/hsla?\(\s*\d+(?:deg|rad|grad|turn)?\s+\d+%\s+\d+%\s*\)/,
|
16
|
+
/hsla?\(\s*\d+(?:deg|rad|grad|turn)?\,\s*(?:\d+%\,\s*){2}\d?\.?\d+%?\s*\)/,
|
17
|
+
/hsla?\(\s*\d+(?:deg|rad|grad|turn)?\s+\d+%\s+\d+%\s*\/\s*\d?\.?\d+%?\s*\)/,
|
18
|
+
)
|
19
|
+
|
20
|
+
COLOR_CODE_PATTERN = /\A\s*(#{REGEXPS})\s*\z/
|
21
|
+
|
22
|
+
def call
|
23
|
+
doc.search(".//code").each do |node|
|
24
|
+
if (color = node.inner_text) =~ COLOR_CODE_PATTERN
|
25
|
+
node.add_child(color_element(color.strip))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
doc
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def color_element(color)
|
34
|
+
%(<span class=#{inline_code_color_class_name} style="background-color: #{color};"></span>)
|
35
|
+
end
|
36
|
+
|
37
|
+
def inline_code_color_class_name
|
38
|
+
context[:inline_code_color_class_name] || DEFAULT_CLASS_NAME
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -13,7 +13,7 @@ module Qiita
|
|
13
13
|
Filters::UserInputSanitizer,
|
14
14
|
Filters::ImageLink,
|
15
15
|
Filters::Footnote,
|
16
|
-
Filters::
|
16
|
+
Filters::CodeBlock,
|
17
17
|
Filters::Checkbox,
|
18
18
|
Filters::Toc,
|
19
19
|
Filters::Emoji,
|
@@ -21,6 +21,7 @@ module Qiita
|
|
21
21
|
Filters::Mention,
|
22
22
|
Filters::GroupMention,
|
23
23
|
Filters::ExternalLink,
|
24
|
+
Filters::InlineCodeColor,
|
24
25
|
Filters::FinalSanitizer,
|
25
26
|
]
|
26
27
|
end
|
@@ -0,0 +1,205 @@
|
|
1
|
+
describe Qiita::Markdown::Filters::InlineCodeColor do
|
2
|
+
subject(:filter) do
|
3
|
+
described_class.new(html)
|
4
|
+
end
|
5
|
+
|
6
|
+
let(:html) do
|
7
|
+
"<p><code>#{color}</code></p>"
|
8
|
+
end
|
9
|
+
|
10
|
+
shared_examples "adds span element for its color" do |color|
|
11
|
+
let(:color) { color }
|
12
|
+
|
13
|
+
it "adds span element for its color" do
|
14
|
+
expect(filter.call.to_s).to eq(%(<p><code>#{color}<span class="inline-code-color" style="background-color: #{color};"></span></code></p>))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
shared_examples "does not add span element" do |color|
|
19
|
+
let(:color) { color }
|
20
|
+
|
21
|
+
it "does not add span element" do
|
22
|
+
expect(filter.call.to_s).to eq(%(<p><code>#{color}</code></p>))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when contents of code is hexadecimal color" do
|
27
|
+
%w[
|
28
|
+
#000
|
29
|
+
#f03
|
30
|
+
#F03
|
31
|
+
#fff
|
32
|
+
#FFF
|
33
|
+
#000000
|
34
|
+
#ff0033
|
35
|
+
#FF0033
|
36
|
+
#ffffff
|
37
|
+
#FFFFFF
|
38
|
+
].each do |color|
|
39
|
+
context "when contents of code is #{color}" do
|
40
|
+
include_examples "adds span element for its color", color
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when contents of code is not hexadecimal color" do
|
46
|
+
%w[
|
47
|
+
#-1-1-1
|
48
|
+
#ggg
|
49
|
+
#GGG
|
50
|
+
#gggggg
|
51
|
+
#gggGGG
|
52
|
+
#GGGGGG
|
53
|
+
].each do |color|
|
54
|
+
context "when contents of code is #{color}" do
|
55
|
+
include_examples "does not add span element", color
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "when contents of code is rgb color" do
|
61
|
+
[
|
62
|
+
"rgb(255,0,51)",
|
63
|
+
"rgb(255, 0, 51)",
|
64
|
+
"rgb(100%,0%,20%)",
|
65
|
+
"rgb(100%, 0%, 20%)",
|
66
|
+
"rgb(255,0,0,0.4)",
|
67
|
+
"rgb(255, 0, 0, 0.4)",
|
68
|
+
"rgb(255,0,0,.4)",
|
69
|
+
"rgb(255, 0, 0, .4)",
|
70
|
+
"rgb(255,0,0,40%)",
|
71
|
+
"rgb(255, 0, 0, 40%)",
|
72
|
+
"rgb(255 0 0/0.4)",
|
73
|
+
"rgb(255 0 0 / 0.4)",
|
74
|
+
"rgb(255 0 0/.4)",
|
75
|
+
"rgb(255 0 0 / .4)",
|
76
|
+
"rgb(255 0 0/40%)",
|
77
|
+
"rgb(255 0 0 / 40%)",
|
78
|
+
].each do |color|
|
79
|
+
context "when contents of code is #{color}" do
|
80
|
+
include_examples "adds span element for its color", color
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "when contents of code is not rgb color" do
|
86
|
+
[
|
87
|
+
"rgb(0)",
|
88
|
+
"rgb(0, 0)",
|
89
|
+
"rgb(0, 0, 0%)",
|
90
|
+
"rgb(0, 0, 0, 0, 0)",
|
91
|
+
].each do |color|
|
92
|
+
context "when contents of code is #{color}" do
|
93
|
+
include_examples "does not add span element", color
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "when contents of code is rgba color" do
|
99
|
+
[
|
100
|
+
"rgba(255,0,0,0)",
|
101
|
+
"rgba(255, 0, 0, 0)",
|
102
|
+
"rgba(255,0,0,0.1)",
|
103
|
+
"rgba(255, 0, 0, 0.1)",
|
104
|
+
"rgba(255,0,0,.4)",
|
105
|
+
"rgba(255, 0, 0, .4)",
|
106
|
+
"rgba(255,0,0,1)",
|
107
|
+
"rgba(255, 0, 0, 1)",
|
108
|
+
"rgba(255 0 0/0.4)",
|
109
|
+
"rgba(255 0 0 / 0.4)",
|
110
|
+
"rgba(255 0 0/.4)",
|
111
|
+
"rgba(255 0 0 / .4)",
|
112
|
+
"rgba(255 0 0/40%)",
|
113
|
+
"rgba(255 0 0 / 40%)",
|
114
|
+
].each do |color|
|
115
|
+
context "when contents of code is #{color}" do
|
116
|
+
include_examples "adds span element for its color", color
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context "when contents of code is not rgba color" do
|
122
|
+
[
|
123
|
+
"rgba(0)",
|
124
|
+
"rgba(0, 0)",
|
125
|
+
"rgba(0, 0, 0%)",
|
126
|
+
"rgba(0, 0, 0, 0, 0)",
|
127
|
+
].each do |color|
|
128
|
+
context "when contents of code is #{color}" do
|
129
|
+
include_examples "does not add span element", color
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context "when contents of code is hsl color" do
|
135
|
+
[
|
136
|
+
"hsl(0,100%,50%)",
|
137
|
+
"hsl(0, 100%, 50%)",
|
138
|
+
"hsl(360,100%,50%)",
|
139
|
+
"hsl(360, 100%, 50%)",
|
140
|
+
"hsl(120 60% 70%)",
|
141
|
+
"hsl(120deg 60% 70%)",
|
142
|
+
"hsl(240,100%,50%,0.05)",
|
143
|
+
"hsl(240, 100%, 50%, 0.05)",
|
144
|
+
"hsl(240,100%,50%,.05)",
|
145
|
+
"hsl(240, 100%, 50%, .05)",
|
146
|
+
"hsl(240,100%,50%,5%)",
|
147
|
+
"hsl(240, 100%, 50%, 5%)",
|
148
|
+
"hsl(240 100% 50%/0.05)",
|
149
|
+
"hsl(240 100% 50% / 0.05)",
|
150
|
+
"hsl(240 100% 50%/.05)",
|
151
|
+
"hsl(240 100% 50% / .05)",
|
152
|
+
"hsl(240 100% 50%/5%)",
|
153
|
+
"hsl(240 100% 50% / 5%)",
|
154
|
+
].each do |color|
|
155
|
+
context "when contents of code is #{color}" do
|
156
|
+
include_examples "adds span element for its color", color
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
context "when contents of code is not hsl color" do
|
162
|
+
[
|
163
|
+
"hsl(0)",
|
164
|
+
"hsl(0, 0)",
|
165
|
+
"hsl(0, 0, 0)",
|
166
|
+
"hsl(0, 0, 0, 0)",
|
167
|
+
].each do |color|
|
168
|
+
context "when contents of code is #{color}" do
|
169
|
+
include_examples "does not add span element", color
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
context "when contents of code is hsla color" do
|
175
|
+
[
|
176
|
+
"hsla(240,100%,50%,0.05)",
|
177
|
+
"hsla(240, 100%, 50%, 0.05)",
|
178
|
+
"hsla(240,100%,50%,.05)",
|
179
|
+
"hsla(240, 100%, 50%, .05)",
|
180
|
+
"hsla(240 100% 50%/0.05)",
|
181
|
+
"hsla(240 100% 50% / 0.05)",
|
182
|
+
"hsla(240 100% 50%/5%)",
|
183
|
+
"hsla(240 100% 50% / 5%)",
|
184
|
+
"hsla(240deg 100% 50% / 5%)",
|
185
|
+
"hsla(240deg,100%,50%, 0.4)",
|
186
|
+
].each do |color|
|
187
|
+
context "when contents of code is #{color}" do
|
188
|
+
include_examples "adds span element for its color", color
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
context "when contents of code is not hsla color" do
|
193
|
+
[
|
194
|
+
"hsla(0)",
|
195
|
+
"hsla(0, 0)",
|
196
|
+
"hsla(0, 0, 0)",
|
197
|
+
"hsla(0, 0, 0, 0)",
|
198
|
+
].each do |color|
|
199
|
+
context "when contents of code is #{color}" do
|
200
|
+
include_examples "does not add span element", color
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
@@ -971,6 +971,66 @@ describe Qiita::Markdown::Processor do
|
|
971
971
|
should eq "<blockquote>\n<p>foo</p>\n</blockquote>\n"
|
972
972
|
end
|
973
973
|
end
|
974
|
+
|
975
|
+
context "with inline code containing hexadecimal color only" do
|
976
|
+
let(:markdown) do
|
977
|
+
"`#FF0000`"
|
978
|
+
end
|
979
|
+
|
980
|
+
it "returns code element with its color" do
|
981
|
+
should eq "<p><code>#FF0000<span class=\"inline-code-color\" style=\"background-color: #FF0000;\"></span></code></p>\n"
|
982
|
+
end
|
983
|
+
|
984
|
+
context "with class name of inline code color parameter" do
|
985
|
+
let(:context) do
|
986
|
+
super().merge(inline_code_color_class_name: "qiita-inline-code-color")
|
987
|
+
end
|
988
|
+
|
989
|
+
it "returns returns code element with its color whose class name is parameter value" do
|
990
|
+
should eq "<p><code>#FF0000<span class=\"qiita-inline-code-color\" style=\"background-color: #FF0000;\"></span></code></p>\n"
|
991
|
+
end
|
992
|
+
end
|
993
|
+
end
|
994
|
+
|
995
|
+
context "with inline code containing rgb color only" do
|
996
|
+
let(:markdown) do
|
997
|
+
"`rgb(255, 0, 0)`"
|
998
|
+
end
|
999
|
+
|
1000
|
+
it "returns code element with its color" do
|
1001
|
+
should eq "<p><code>rgb(255, 0, 0)<span class=\"inline-code-color\" style=\"background-color: rgb(255, 0, 0);\"></span></code></p>\n"
|
1002
|
+
end
|
1003
|
+
|
1004
|
+
context "with class name of inline code color parameter" do
|
1005
|
+
let(:context) do
|
1006
|
+
super().merge(inline_code_color_class_name: "qiita-inline-code-color")
|
1007
|
+
end
|
1008
|
+
|
1009
|
+
it "returns returns code element with its color whose class name is parameter value" do
|
1010
|
+
should eq "<p><code>rgb(255, 0, 0)<span class=\"qiita-inline-code-color\" style=\"background-color: rgb(255, 0, 0);\"></span></code></p>\n"
|
1011
|
+
end
|
1012
|
+
end
|
1013
|
+
end
|
1014
|
+
|
1015
|
+
context "with inline code containing hsl color only" do
|
1016
|
+
let(:markdown) do
|
1017
|
+
"`hsl(0, 100%, 50%)`"
|
1018
|
+
end
|
1019
|
+
|
1020
|
+
it "returns code element with its color" do
|
1021
|
+
should eq "<p><code>hsl(0, 100%, 50%)<span class=\"inline-code-color\" style=\"background-color: hsl(0, 100%, 50%);\"></span></code></p>\n"
|
1022
|
+
end
|
1023
|
+
|
1024
|
+
context "with class name of inline code color parameter" do
|
1025
|
+
let(:context) do
|
1026
|
+
super().merge(inline_code_color_class_name: "qiita-inline-code-color")
|
1027
|
+
end
|
1028
|
+
|
1029
|
+
it "returns returns code element with its color whose class name is parameter value" do
|
1030
|
+
should eq "<p><code>hsl(0, 100%, 50%)<span class=\"qiita-inline-code-color\" style=\"background-color: hsl(0, 100%, 50%);\"></span></code></p>\n"
|
1031
|
+
end
|
1032
|
+
end
|
1033
|
+
end
|
974
1034
|
end
|
975
1035
|
|
976
1036
|
shared_examples_for "script element" do |allowed:|
|
@@ -1190,6 +1250,24 @@ describe Qiita::Markdown::Processor do
|
|
1190
1250
|
end
|
1191
1251
|
end
|
1192
1252
|
|
1253
|
+
shared_examples_for "background-color" do |allowed:|
|
1254
|
+
context "with style attribute" do
|
1255
|
+
let(:markdown) do
|
1256
|
+
"<span style=\"background-color: #000000\"></span>"
|
1257
|
+
end
|
1258
|
+
|
1259
|
+
if allowed
|
1260
|
+
it "does not sanitize span element" do
|
1261
|
+
should eq "<p><span style=\"background-color: #000000\"></span></p>\n"
|
1262
|
+
end
|
1263
|
+
else
|
1264
|
+
it "sanitizes span element" do
|
1265
|
+
should eq "<p></p>\n"
|
1266
|
+
end
|
1267
|
+
end
|
1268
|
+
end
|
1269
|
+
end
|
1270
|
+
|
1193
1271
|
context "without script and strict context" do
|
1194
1272
|
let(:context) do
|
1195
1273
|
super().merge(script: false, strict: false)
|
@@ -1202,6 +1280,7 @@ describe Qiita::Markdown::Processor do
|
|
1202
1280
|
include_examples "input element", allowed: true
|
1203
1281
|
include_examples "data-attributes", allowed: false
|
1204
1282
|
include_examples "class attribute", allowed: true
|
1283
|
+
include_examples "background-color", allowed: true
|
1205
1284
|
end
|
1206
1285
|
|
1207
1286
|
context "with script context" do
|
@@ -1216,6 +1295,7 @@ describe Qiita::Markdown::Processor do
|
|
1216
1295
|
include_examples "input element", allowed: true
|
1217
1296
|
include_examples "data-attributes", allowed: true
|
1218
1297
|
include_examples "class attribute", allowed: true
|
1298
|
+
include_examples "background-color", allowed: true
|
1219
1299
|
end
|
1220
1300
|
|
1221
1301
|
context "with strict context" do
|
@@ -1230,6 +1310,7 @@ describe Qiita::Markdown::Processor do
|
|
1230
1310
|
include_examples "input element", allowed: false
|
1231
1311
|
include_examples "data-attributes", allowed: false
|
1232
1312
|
include_examples "class attribute", allowed: false
|
1313
|
+
include_examples "background-color", allowed: false
|
1233
1314
|
end
|
1234
1315
|
|
1235
1316
|
context "with script and strict context" do
|
@@ -1244,6 +1325,7 @@ describe Qiita::Markdown::Processor do
|
|
1244
1325
|
include_examples "input element", allowed: false
|
1245
1326
|
include_examples "data-attributes", allowed: false
|
1246
1327
|
include_examples "class attribute", allowed: false
|
1328
|
+
include_examples "background-color", allowed: false
|
1247
1329
|
end
|
1248
1330
|
end
|
1249
1331
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qiita-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gemoji
|
@@ -257,7 +257,7 @@ files:
|
|
257
257
|
- lib/qiita/markdown.rb
|
258
258
|
- lib/qiita/markdown/base_processor.rb
|
259
259
|
- lib/qiita/markdown/filters/checkbox.rb
|
260
|
-
- lib/qiita/markdown/filters/
|
260
|
+
- lib/qiita/markdown/filters/code_block.rb
|
261
261
|
- lib/qiita/markdown/filters/emoji.rb
|
262
262
|
- lib/qiita/markdown/filters/external_link.rb
|
263
263
|
- lib/qiita/markdown/filters/final_sanitizer.rb
|
@@ -265,6 +265,7 @@ files:
|
|
265
265
|
- lib/qiita/markdown/filters/greenmat.rb
|
266
266
|
- lib/qiita/markdown/filters/group_mention.rb
|
267
267
|
- lib/qiita/markdown/filters/image_link.rb
|
268
|
+
- lib/qiita/markdown/filters/inline_code_color.rb
|
268
269
|
- lib/qiita/markdown/filters/mention.rb
|
269
270
|
- lib/qiita/markdown/filters/simplify.rb
|
270
271
|
- lib/qiita/markdown/filters/syntax_highlight.rb
|
@@ -279,6 +280,7 @@ files:
|
|
279
280
|
- lib/qiita/markdown/version.rb
|
280
281
|
- qiita-markdown.gemspec
|
281
282
|
- spec/qiita/markdown/filters/greenmat_spec.rb
|
283
|
+
- spec/qiita/markdown/filters/inline_code_color_spec.rb
|
282
284
|
- spec/qiita/markdown/greenmat/html_toc_renderer_spec.rb
|
283
285
|
- spec/qiita/markdown/processor_spec.rb
|
284
286
|
- spec/qiita/markdown/summary_processor_spec.rb
|
@@ -309,6 +311,7 @@ specification_version: 4
|
|
309
311
|
summary: Qiita-specified markdown processor.
|
310
312
|
test_files:
|
311
313
|
- spec/qiita/markdown/filters/greenmat_spec.rb
|
314
|
+
- spec/qiita/markdown/filters/inline_code_color_spec.rb
|
312
315
|
- spec/qiita/markdown/greenmat/html_toc_renderer_spec.rb
|
313
316
|
- spec/qiita/markdown/processor_spec.rb
|
314
317
|
- spec/qiita/markdown/summary_processor_spec.rb
|