Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
MIME Normalizer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Code
JS Toolbox
MIME Normalizer
Commits
5ecb5b02
Commit
5ecb5b02
authored
4 years ago
by
Igor Markin
Browse files
Options
Downloads
Patches
Plain Diff
Add missing build files
parent
942b7c3b
No related branches found
No related tags found
1 merge request
!5
Rework with parse 5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dist/HTMLNormalizer/strategies/nodesAmendingFunctions.d.ts
+1
-0
1 addition, 0 deletions
dist/HTMLNormalizer/strategies/nodesAmendingFunctions.d.ts
dist/HTMLNormalizer/strategies/nodesAmendingFunctions.js
+36
-0
36 additions, 0 deletions
dist/HTMLNormalizer/strategies/nodesAmendingFunctions.js
with
37 additions
and
0 deletions
dist/HTMLNormalizer/strategies/nodesAmendingFunctions.d.ts
0 → 100644
+
1
−
0
View file @
5ecb5b02
export
declare
const
unwindTags
:
(
node
:
Element
|
Document
,
tagName
:
string
)
=>
void
;
This diff is collapsed.
Click to expand it.
dist/HTMLNormalizer/strategies/nodesAmendingFunctions.js
0 → 100644
+
36
−
0
View file @
5ecb5b02
"
use strict
"
;
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
unwindTags
=
void
0
;
const
unwindTags
=
(
node
,
tagName
)
=>
{
const
tags
=
node
.
getElementsByTagName
(
tagName
);
//Sort tags by depth to start unwinding the deepest ones, which does not contain nested spans
const
tagsDepths
=
{};
Array
.
from
(
tags
).
forEach
((
span
)
=>
{
let
descendant
=
span
;
let
parent
=
descendant
.
parentNode
;
let
depth
=
0
;
while
(
parent
&&
descendant
!==
parent
)
{
descendant
=
parent
;
parent
=
descendant
.
parentNode
;
depth
++
;
}
if
(
!
tagsDepths
[
depth
])
{
tagsDepths
[
depth
]
=
[];
}
tagsDepths
[
depth
].
push
(
span
);
});
Object
.
keys
(
tagsDepths
)
.
sort
((
a
,
b
)
=>
parseInt
(
b
)
-
parseInt
(
a
))
.
forEach
((
depth
)
=>
{
tagsDepths
[
depth
].
forEach
((
span
)
=>
{
let
child
=
span
.
firstChild
;
const
parent
=
span
.
parentNode
;
while
(
child
)
{
parent
.
insertBefore
(
child
.
cloneNode
(
true
),
span
);
child
=
child
.
nextSibling
;
}
span
.
parentNode
.
removeChild
(
span
);
});
});
};
exports
.
unwindTags
=
unwindTags
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment