├── .gitignore ├── Sources └── SwiftHTMLParser │ ├── Helpers │ ├── RegexError.swift │ └── RegexHelper.swift │ ├── Parser │ ├── Tags │ │ ├── XMLTags.swift │ │ ├── SVGTags.swift │ │ └── KnownHTMLTags.swift │ ├── ParseFormat.swift │ ├── Models │ │ ├── Nodes │ │ │ ├── Node.swift │ │ │ ├── NodeType.swift │ │ │ ├── DocumentTypeNode.swift │ │ │ ├── TextNode.swift │ │ │ ├── Comment.swift │ │ │ ├── CData.swift │ │ │ └── Element.swift │ │ ├── Attribute.swift │ │ └── Tag.swift │ ├── ParseError.swift │ ├── LookaheadValidator.swift │ ├── CDATAParser.swift │ ├── HTMLParser.swift │ ├── CommentParser.swift │ ├── ScriptParser.swift │ ├── AttributeParser.swift │ └── TagParser.swift │ ├── ProjectConfig.swift │ ├── Extensions │ ├── CharacterExtensions.swift │ ├── StringExtensions.swift │ └── Appendable.swift │ └── Traverser │ ├── Selectors │ ├── NodeSelectors │ │ ├── CDataSelector.swift │ │ ├── TextNodeSelector.swift │ │ ├── CommentSelector.swift │ │ └── ElementSelector.swift │ ├── NodeSelector.swift │ ├── AttributeSelector.swift │ ├── SelectorBuilders │ │ ├── PositionIntSelectorBuilder.swift │ │ ├── IdStringSelectorBuilder.swift │ │ ├── TextStringSelectorBuilder.swift │ │ ├── ValueStringSelectorBuilder.swift │ │ └── TagNameStringSelectorBuilder.swift │ ├── IntSelector.swift │ ├── StringSelector.swift │ └── ClassSelector.swift │ └── HTMLTraverser.swift ├── Dockerfile ├── Tests ├── TestFiles │ ├── Mock │ │ ├── Elements │ │ │ ├── element-unclosed-end-tag.html │ │ │ ├── elements-simple.html │ │ │ ├── elemnent-stray-end-html-tag.html │ │ │ ├── empty-element.html │ │ │ ├── elemnent-stray-end-tag.html │ │ │ ├── elements-quotes.html │ │ │ └── element-name-on-new-line.html │ │ ├── Attributes │ │ │ ├── attributes-tabs.html │ │ │ ├── attributes-quotes.html │ │ │ ├── attributes-simple.html │ │ │ └── attributes-multiple-value-class.html │ │ ├── Javascript │ │ │ ├── javascript-simple.html │ │ │ ├── javascript-comments.html │ │ │ ├── javascript-quotes.html │ │ │ └── javascript-quotes-with-escape-characters.html │ │ ├── Comments │ │ │ ├── conditional-comments-salvageable.html │ │ │ ├── declarations.html │ │ │ └── comments.html │ │ ├── SVG │ │ │ └── svg-simple.html │ │ └── Documentation │ │ │ └── simple.html │ ├── TestFileURLs.swift │ └── RealWorld │ │ └── weather-forcast.xml └── SwiftHTMLParserTests │ ├── TestHelper.swift │ ├── AppendableTests.swift │ ├── SVGParserTests.swift │ ├── CommentParserTests.swift │ ├── DocumentationTests.swift │ ├── JavascriptParserTests.swift │ ├── PerformanceTests.swift │ ├── AttributeParserTests.swift │ ├── ElementTraverserTests.swift │ └── ElementTests.swift ├── Package.swift ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | /*.xcodeproj 5 | /.swiftpm 6 | -------------------------------------------------------------------------------- /Sources/SwiftHTMLParser/Helpers/RegexError.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RegexError.swift 3 | // SwiftHTMLParser 4 | // 5 | // Created by Reid Nantes on 2018-12-05. 6 | // 7 | 8 | import Foundation 9 | -------------------------------------------------------------------------------- /Sources/SwiftHTMLParser/Parser/Tags/XMLTags.swift: -------------------------------------------------------------------------------- 1 | // 2 | // XMLTags.swift 3 | // SwiftHTMLParser 4 | // 5 | // Created by Reid Nantes on 2018-12-13. 6 | // 7 | 8 | import Foundation 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # 1 2 | FROM vapor/swift:5.1-bionic 3 | # 2 4 | WORKDIR /package 5 | # 3 6 | COPY . ./ 7 | # 4 8 | RUN swift package resolve 9 | RUN swift package clean 10 | # 5 11 | #RUN swift test --enable-test-discovery 12 | CMD ["swift", "test", "--enable-test-discovery"] 13 | -------------------------------------------------------------------------------- /Sources/SwiftHTMLParser/Parser/ParseFormat.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ParseFormat.swift 3 | // SwiftHTMLParser 4 | // 5 | // Created by Reid Nantes on 2018-12-13. 6 | // 7 | 8 | import Foundation 9 | 10 | public enum ParseFormat { 11 | case html 12 | case xml 13 | case svg 14 | } 15 | -------------------------------------------------------------------------------- /Sources/SwiftHTMLParser/ProjectConfig.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TestConfig.swift 3 | // SwiftHTMLParser 4 | // 5 | // Created by Reid Nantes on 2018-12-04. 6 | // 7 | 8 | import Foundation 9 | 10 | struct ProjectConfig { 11 | 12 | // for Debugging 13 | static let shouldPrintTags = false 14 | static let shouldPrintWarnings = false 15 | } 16 | -------------------------------------------------------------------------------- /Sources/SwiftHTMLParser/Parser/Models/Nodes/Node.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Node.swift 3 | // SwiftHTMLParser 4 | // 5 | // Created by Reid Nantes on 2018-12-08. 6 | // 7 | 8 | import Foundation 9 | 10 | public protocol Node { 11 | var nodeType: NodeType { get } 12 | var startIndex: String.Index { get } 13 | var endIndex: String.Index { get } 14 | } 15 | -------------------------------------------------------------------------------- /Tests/TestFiles/Mock/Elements/element-unclosed-end-tag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |This is the first paragraph.
9 | 10 |This is the second paragraph.
13 | 14 | 15 | -------------------------------------------------------------------------------- /Tests/TestFiles/Mock/Elements/elements-simple.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |This is the first paragraph.
9 |This is the second paragraph.
10 |This is the third paragraph.
11 | 12 | 13 | -------------------------------------------------------------------------------- /Tests/TestFiles/Mock/Elements/elemnent-stray-end-html-tag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |This is the first paragraph.
9 | 10 |This is the second paragraph.
12 |