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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
ff28edb8
Commit
ff28edb8
authored
Apr 21, 2020
by
Lee Tickett
Committed by
Bob Van Landuyt
Apr 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exclude html entities from haml lint
parent
a8855bb7
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
433 additions
and
421 deletions
+433
-421
.haml-lint_todo.yml
.haml-lint_todo.yml
+383
-420
changelogs/unreleased/exclude_html_entities_from_haml_lint.yml
...elogs/unreleased/exclude_html_entities_from_haml_lint.yml
+5
-0
haml_lint/linter/no_plain_nodes.rb
haml_lint/linter/no_plain_nodes.rb
+7
-1
spec/haml_lint/linter/no_plain_nodes_spec.rb
spec/haml_lint/linter/no_plain_nodes_spec.rb
+38
-0
No files found.
.haml-lint_todo.yml
View file @
ff28edb8
This diff is collapsed.
Click to expand it.
changelogs/unreleased/exclude_html_entities_from_haml_lint.yml
0 → 100644
View file @
ff28edb8
---
title
:
Exclude html entities from haml lint
merge_request
:
29847
author
:
Lee Tickett
type
:
fixed
haml_lint/linter/no_plain_nodes.rb
View file @
ff28edb8
...
...
@@ -51,6 +51,7 @@ module HamlLint
attributes
=
node
.
attributes_source
.
map
(
&
:last
)
attributes
.
each
{
|
attribute
|
text
=
text
.
gsub
(
attribute
,
''
)
}
text
=
strip_html_entities
(
text
)
text
.
strip
end
...
...
@@ -77,7 +78,12 @@ module HamlLint
def
text_node?
(
node
)
return
false
unless
plain_node?
(
node
)
!
node
.
text
.
empty?
text
=
strip_html_entities
(
node
.
text
)
!
text
.
empty?
end
def
strip_html_entities
(
text
)
text
.
gsub
(
/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/i
,
""
)
end
end
end
...
...
spec/haml_lint/linter/no_plain_nodes_spec.rb
View file @
ff28edb8
...
...
@@ -53,4 +53,42 @@ describe HamlLint::Linter::NoPlainNodes do
it
{
is_expected
.
to
report_lint
count:
3
}
end
context
'does not report when a html entity'
do
let
(
:haml
)
{
'%tag '
}
it
{
is_expected
.
not_to
report_lint
}
end
context
'does report when something that looks like a html entity'
do
let
(
:haml
)
{
'%tag &some text;'
}
it
{
is_expected
.
to
report_lint
}
end
context
'does not report multiline when one or more html entities'
do
%w( > © »)
.
each
do
|
elem
|
let
(
:haml
)
{
<<-
HAML
}
%tag
#{
elem
}
HAML
it
elem
do
is_expected
.
not_to
report_lint
end
end
end
context
'does report multiline when one or more html entities amidst plain text'
do
%w( Test Test> ©Hello Hello»)
.
each
do
|
elem
|
let
(
:haml
)
{
<<-
HAML
}
%tag
#{
elem
}
HAML
it
elem
do
is_expected
.
to
report_lint
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