Skip to content

Commit

Permalink
Ignore void elements.
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan P.C. McQuen <[email protected]>
  • Loading branch information
Ryan P.C. McQuen committed Sep 20, 2017
1 parent dd0ed17 commit 8147103
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# unclosedTagFinder
[![GitHub license](https://img.shields.io/badge/license-GPLv2-blue.svg)](https://raw.githubusercontent.com/ryanpcmcquen/unclosedTagFinder/master/LICENSE)
[![GitHub version](https://img.shields.io/badge/version-0.2.1-orange.svg)](https://github.com/ryanpcmcquen/unclosedTagFinder/releases)
[![GitHub version](https://img.shields.io/badge/version-0.3.0-orange.svg)](https://github.com/ryanpcmcquen/unclosedTagFinder/releases)
[![GitHub issues](https://img.shields.io/github/issues/ryanpcmcquen/unclosedTagFinder.svg)](https://github.com/ryanpcmcquen/unclosedTagFinder/issues)
[![Twitter](https://img.shields.io/twitter/url/https/github.com/ryanpcmcquen/unclosedTagFinder.svg?style=social)](https://twitter.com/intent/tweet?text=Hey%2C%20check%20this%20out%3A%20https%3A%2F%2Fgithub.com%2Fryanpcmcquen%2FunclosedTagFinder&url=%5Bobject%20Object%5D)

Expand All @@ -25,7 +25,7 @@ TODO:

- [x] Read file input.
- [x] Accomodate tag names with attributes.
- [ ] Ignore self closing tags.
- [x] Ignore self closing tags.
- [ ] Read remote files.
- [ ] Accomodate multiple files.
- [x] Accomodate user input.
Expand Down
1 change: 1 addition & 0 deletions foo.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!doctype html>
<html>
<div>
<br>
<span class="bar">Foo
</div>
</html>
15 changes: 12 additions & 3 deletions unclosedTagFinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,28 @@
'''
Filter out void elements:
https://www.w3.org/TR/html/syntax.html#void-elements
area, base, br, col, embed, hr, img, input, keygen, link, menuitem, meta, param, source, track, wbr
'''
voidElementsRegex = '</?(?!area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)'
devoidedTagList = list(
filter(
lambda tag: re.match(
voidElementsRegex,
tag
),
tagList
)
)

openingTagList = list(
filter(
lambda tag: re.match('<[^/]', tag),
tagList
devoidedTagList
)
)
closingTagList = list(
filter(
lambda tag: re.match('</', tag),
tagList
devoidedTagList
)
)

Expand Down

0 comments on commit 8147103

Please sign in to comment.