diff --git a/.jazzy.yaml b/.jazzy.yaml index 9fab102..115f74d 100644 --- a/.jazzy.yaml +++ b/.jazzy.yaml @@ -1,5 +1,5 @@ module: HTMLKit -module_version: 1.0.0 +module_version: 1.1.0 author: Iskandar Abudiab author_url: https://twitter.com/iabudiab github_url: https://github.com/iabudiab/HTMLKit @@ -27,10 +27,12 @@ custom_categories: - HTMLDocumentType - HTMLDocumentFragment - HTMLDocumentPosition + - HTMLCharacterData - HTMLText - HTMLComment - HTMLTemplate - HTMLDOMTokenList + - HTMLRange - name: Iteration & Filtering children: diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e8cb29..37ffbba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Change Log +## [1.1.0](https://github.com/iabudiab/HTMLKit/releases/tag/1.1.0) + +Released on 2017.01.14 + +### Added + +- `DOM Ranges` implementation ([spec](https://dom.spec.whatwg.org/#ranges)) +- `HTMLChatacterData` as base class for `HTMLText` & `HTMLComment` + - `HTMLText` and `HTMLComment` no longer extend `HTMLNode` directly +- `splitText` implementation for `HTMLText` nodes +- `index` property for `HTMLNode` +- `cloneNodeDeep` method for `HTMLNode` + +### Deprecated + +- `appendString` method in `HTMLText` in favor of `appendData` from the supperclass `HTMLCharacterData` + + ## [1.0.0](https://github.com/iabudiab/HTMLKit/releases/tag/1.0.0) Released on 2016.09.28 @@ -61,7 +79,6 @@ This release passes all tokenizer and tree construction html5lib-tests as of 201 - `` is completely removed from the spec now, therefore it is dropped from the implementation - `Tokenizer` and `Tree-Construction` tests are now generated dynamically - Test failures are collected by a `XCTestObservation` for better reporting - - `` is completely removed from the spec now, therefore it is dropped from the implementation - `Tokenizer` and `Tree-Construction` tests are now generated dynamically - Test failures are collected by a `XCTestObservation` for better reporting diff --git a/HTMLKit.podspec b/HTMLKit.podspec index 8025949..13c58c1 100644 --- a/HTMLKit.podspec +++ b/HTMLKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "HTMLKit" - s.version = "1.0.0" + s.version = "1.1.0" s.summary = "HTMLKit, an Objective-C framework for your everyday HTML needs." s.license = "MIT" s.homepage = "https://github.com/iabudiab/HTMLKit" @@ -16,7 +16,7 @@ Pod::Spec.new do |s| s.source_files = "Sources", "Sources/**/*.{h,m}" s.private_header_files = [ - 'Sources/**/*{HTMLToken,HTMLTokens,HTMLTagToken,HTMLCharacterToken,HTMLCommentToken,HTMLDOCTYPEToken,HTMLEOFToken,HTMLTokenizer,HTMLTokenizerCharacters,HTMLTokenizerEntities,HTMLTokenizerStates,HTMLElementAdjustment,HTMLElementTypes,HTMLInputStreamReader,HTMLListOfActiveFormattingElements,HTMLNodeTraversal,HTMLParseErrorToken,HTMLParserInsertionModes,HTMLStackOfOpenElements,HTMLNode+Private,HTMLMarker,CSSCodePoints,CSSInputStream}.h' + 'Sources/**/*{HTMLToken,HTMLTokens,HTMLTagToken,HTMLCharacterToken,HTMLCommentToken,HTMLDOCTYPEToken,HTMLEOFToken,HTMLTokenizer,HTMLTokenizerCharacters,HTMLTokenizerEntities,HTMLTokenizerStates,HTMLElementAdjustment,HTMLElementTypes,HTMLInputStreamReader,HTMLListOfActiveFormattingElements,HTMLParseErrorToken,HTMLParserInsertionModes,HTMLStackOfOpenElements,HTMLMarker,HTMLNode+Private,HTMLDocument+Private,HTMLCharacterData+Private,HTMLRange+Private,HTMLParser+Private,HTMLNodeIterator+Private,HTMLNodeTraversal,HTMLDOMUtils,CSSCodePoints,CSSInputStream}.h' ] s.requires_arc = true diff --git a/HTMLKit.xcodeproj/project.pbxproj b/HTMLKit.xcodeproj/project.pbxproj index f1bfc2c..fcd465f 100644 --- a/HTMLKit.xcodeproj/project.pbxproj +++ b/HTMLKit.xcodeproj/project.pbxproj @@ -7,6 +7,10 @@ objects = { /* Begin PBXBuildFile section */ + 62056C4F1E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 62056C4E1E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 62056C501E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 62056C4E1E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 62056C511E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 62056C4E1E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 62056C521E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 62056C4E1E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 62132E5A1C01F83200084175 /* CSSSelectorTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 62132E581C01F83200084175 /* CSSSelectorTest.m */; }; 62132E5D1C021FF200084175 /* css-tests in Resources */ = {isa = PBXBuildFile; fileRef = 62132E5B1C021FF200084175 /* css-tests */; }; 6216ACFD1C28DCC80074CAB4 /* CSSExtensionSelectorsParsingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6216ACFC1C28DCC80074CAB4 /* CSSExtensionSelectorsParsingTests.m */; }; @@ -15,10 +19,6 @@ 621CC4921DEA704000D1992A /* HTMLDocument+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC48F1DEA704000D1992A /* HTMLDocument+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 621CC4931DEA704000D1992A /* HTMLDocument+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC48F1DEA704000D1992A /* HTMLDocument+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 621CC4941DEA704000D1992A /* HTMLDocument+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC48F1DEA704000D1992A /* HTMLDocument+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 621CC49B1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC4991DEA71D800D1992A /* HTMLNodeIterator+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 621CC49C1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC4991DEA71D800D1992A /* HTMLNodeIterator+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 621CC49D1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC4991DEA71D800D1992A /* HTMLNodeIterator+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 621CC49E1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC4991DEA71D800D1992A /* HTMLNodeIterator+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 621CC4A51DEA721A00D1992A /* HTMLParser+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC4A31DEA721A00D1992A /* HTMLParser+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 621CC4A61DEA721A00D1992A /* HTMLParser+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC4A31DEA721A00D1992A /* HTMLParser+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 621CC4A71DEA721A00D1992A /* HTMLParser+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC4A31DEA721A00D1992A /* HTMLParser+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -579,6 +579,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 62056C4E1E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "HTMLNodeIterator+Private.h"; path = "include/HTMLNodeIterator+Private.h"; sourceTree = ""; }; 62079BE71AF56F1E00D3B402 /* CSSSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSSelector.h; path = include/CSSSelector.h; sourceTree = ""; }; 620C87791BD44CBE00FB3EEE /* CSSCompoundSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSCompoundSelector.h; path = include/CSSCompoundSelector.h; sourceTree = ""; }; 620C877A1BD44CBE00FB3EEE /* CSSCompoundSelector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSCompoundSelector.m; sourceTree = ""; }; @@ -588,9 +589,8 @@ 62132E581C01F83200084175 /* CSSSelectorTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSSelectorTest.m; sourceTree = ""; }; 62132E5B1C021FF200084175 /* css-tests */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "css-tests"; sourceTree = ""; }; 6216ACFC1C28DCC80074CAB4 /* CSSExtensionSelectorsParsingTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSExtensionSelectorsParsingTests.m; sourceTree = ""; }; - 621CC48F1DEA704000D1992A /* HTMLDocument+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HTMLDocument+Private.h"; sourceTree = ""; }; - 621CC4991DEA71D800D1992A /* HTMLNodeIterator+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HTMLNodeIterator+Private.h"; sourceTree = ""; }; - 621CC4A31DEA721A00D1992A /* HTMLParser+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HTMLParser+Private.h"; sourceTree = ""; }; + 621CC48F1DEA704000D1992A /* HTMLDocument+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "HTMLDocument+Private.h"; path = "include/HTMLDocument+Private.h"; sourceTree = ""; }; + 621CC4A31DEA721A00D1992A /* HTMLParser+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "HTMLParser+Private.h"; path = "include/HTMLParser+Private.h"; sourceTree = ""; }; 621FBE591BDAD68700BC9555 /* CSSSelectorParserTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSSelectorParserTests.m; sourceTree = ""; }; 621FBE5C1BDAD90200BC9555 /* CSSCombinatorSelectorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSCombinatorSelectorTests.m; sourceTree = ""; }; 6223211D1A969B9300BACED5 /* HTMLElementTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HTMLElementTypes.h; path = include/HTMLElementTypes.h; sourceTree = ""; }; @@ -665,7 +665,7 @@ 624B37211B250BB50010BDDF /* CSSCodePoints.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CSSCodePoints.h; path = include/CSSCodePoints.h; sourceTree = ""; }; 624B9FB11AE0313300646C4C /* HTMLStringCategoryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTMLStringCategoryTests.m; sourceTree = ""; }; 624B9FB41AE0391400646C4C /* HTMLOrderedDictionaryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTMLOrderedDictionaryTests.m; sourceTree = ""; }; - 624C77781DE9D05E00DD6DFA /* HTMLCharacterData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLCharacterData.h; sourceTree = ""; }; + 624C77781DE9D05E00DD6DFA /* HTMLCharacterData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLCharacterData.h; path = include/HTMLCharacterData.h; sourceTree = ""; }; 624C77791DE9D05E00DD6DFA /* HTMLCharacterData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTMLCharacterData.m; sourceTree = ""; }; 624FC3791AE591D80015DDF9 /* HTMLNodesTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTMLNodesTests.m; sourceTree = ""; }; 62567F4E1C0CB5750025D458 /* HTMLDOMTokenList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLDOMTokenList.h; path = include/HTMLDOMTokenList.h; sourceTree = ""; }; @@ -690,8 +690,8 @@ 625EE4591CBB171300F2CC8E /* HTMLKitTestUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLKitTestUtil.h; sourceTree = ""; }; 625EE45A1CBB171300F2CC8E /* HTMLKitTestUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTMLKitTestUtil.m; sourceTree = ""; }; 626652F81C03D30F00C3F121 /* HTMLKitErrorDomain.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HTMLKitErrorDomain.h; path = include/HTMLKitErrorDomain.h; sourceTree = ""; }; - 626679CD1DEA3DAF004353E7 /* HTMLCharacterData+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HTMLCharacterData+Private.h"; sourceTree = ""; }; - 626BE1E01DF3819500C49514 /* HTMLDOMUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLDOMUtils.h; sourceTree = ""; }; + 626679CD1DEA3DAF004353E7 /* HTMLCharacterData+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "HTMLCharacterData+Private.h"; path = "include/HTMLCharacterData+Private.h"; sourceTree = ""; }; + 626BE1E01DF3819500C49514 /* HTMLDOMUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLDOMUtils.h; path = include/HTMLDOMUtils.h; sourceTree = ""; }; 626BE1E11DF3819500C49514 /* HTMLDOMUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTMLDOMUtils.m; sourceTree = ""; }; 6279F87119E17DC700F12EE5 /* HTMLParserInsertionModes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HTMLParserInsertionModes.h; path = include/HTMLParserInsertionModes.h; sourceTree = ""; }; 6279F87219E1808D00F12EE5 /* HTMLElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLElement.h; path = include/HTMLElement.h; sourceTree = ""; }; @@ -719,7 +719,7 @@ 62AE594819F9948A0043F069 /* HTMLCharacterToken.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTMLCharacterToken.m; sourceTree = ""; }; 62D8345719FB1AC4009205A9 /* HTML5LibTokenizerTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTML5LibTokenizerTest.h; sourceTree = ""; }; 62D8345819FB1AC4009205A9 /* HTML5LibTokenizerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTML5LibTokenizerTest.m; sourceTree = ""; }; - 62D91C211DE218A500BEFADE /* HTMLRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLRange.h; sourceTree = ""; }; + 62D91C211DE218A500BEFADE /* HTMLRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLRange.h; path = include/HTMLRange.h; sourceTree = ""; }; 62D91C221DE218A500BEFADE /* HTMLRange.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTMLRange.m; sourceTree = ""; }; 62E0BA961E25456700E4D193 /* HTMLCharacterDataTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTMLCharacterDataTests.m; sourceTree = ""; }; 62E7CAAE19CDFFB500465A83 /* HTMLTokenizerCharacters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HTMLTokenizerCharacters.h; path = include/HTMLTokenizerCharacters.h; sourceTree = ""; }; @@ -732,7 +732,7 @@ 62F501631BC9576B0069F47B /* CSSNthExpressionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSNthExpressionParser.h; path = include/CSSNthExpressionParser.h; sourceTree = ""; }; 62F501641BC9576B0069F47B /* CSSNthExpressionParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSNthExpressionParser.m; sourceTree = ""; }; 62F6586F1BD83C8E0045F137 /* CSSNThExpressionSelectorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSNThExpressionSelectorTests.m; sourceTree = ""; }; - 62F7E5A01DEB63F900DEF09B /* HTMLRange+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HTMLRange+Private.h"; sourceTree = ""; }; + 62F7E5A01DEB63F900DEF09B /* HTMLRange+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "HTMLRange+Private.h"; path = "include/HTMLRange+Private.h"; sourceTree = ""; }; 62F873E919E088C90062683C /* HTMLParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLParser.h; path = include/HTMLParser.h; sourceTree = ""; }; 62F873EA19E088C90062683C /* HTMLParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTMLParser.m; sourceTree = ""; }; 62FA04E11BCC360D009ABF98 /* CSSCombinatorSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSCombinatorSelector.h; path = include/CSSCombinatorSelector.h; sourceTree = ""; }; @@ -1011,9 +1011,9 @@ 621CC48F1DEA704000D1992A /* HTMLDocument+Private.h */, 625D0F011C2717DE00D7BEB0 /* HTMLNode+Private.h */, 626679CD1DEA3DAF004353E7 /* HTMLCharacterData+Private.h */, - 621CC4991DEA71D800D1992A /* HTMLNodeIterator+Private.h */, 62F7E5A01DEB63F900DEF09B /* HTMLRange+Private.h */, 621CC4A31DEA721A00D1992A /* HTMLParser+Private.h */, + 62056C4E1E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h */, 624717161B22333200C11912 /* HTMLNodeTraversal.h */, 624717171B22333200C11912 /* HTMLNodeTraversal.m */, 626BE1E01DF3819500C49514 /* HTMLDOMUtils.h */, @@ -1195,7 +1195,6 @@ 62ECBF001C0B69FF00AF847B /* HTMLTreeWalker.h in Headers */, 62ECBF011C0B69FF00AF847B /* HTMLNodeTraversal.h in Headers */, 62F7E5A21DEB63F900DEF09B /* HTMLRange+Private.h in Headers */, - 621CC49B1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */, 62ECBF021C0B69FF00AF847B /* HTMLNodeFilter.h in Headers */, 62ECBF031C0B69FF00AF847B /* HTMLKitDOMExceptions.h in Headers */, 62ECBF041C0B69FF00AF847B /* HTMLNamespaces.h in Headers */, @@ -1213,6 +1212,7 @@ 62ECBF101C0B6A0100AF847B /* CSSSelectorBlock.h in Headers */, 62ECBF111C0B6A0200AF847B /* CSSTypeSelector.h in Headers */, 62ECBF121C0B6A0200AF847B /* CSSAttributeSelector.h in Headers */, + 62056C4F1E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h in Headers */, 62ECBF131C0B6A0200AF847B /* CSSPseudoClassSelector.h in Headers */, 62ECBF141C0B6A0200AF847B /* CSSNthExpressionSelector.h in Headers */, 62ECBF151C0B6A0200AF847B /* CSSPseudoFunctionSelector.h in Headers */, @@ -1284,8 +1284,8 @@ 62857CA11D398973008DC254 /* HTMLNode.h in Headers */, 62857CD41D3989BF008DC254 /* CSSCodePoints.h in Headers */, 62857C871D398927008DC254 /* HTMLElementTypes.h in Headers */, - 621CC49E1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */, 62857C711D398907008DC254 /* HTMLTokenizerEntities.h in Headers */, + 62056C521E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h in Headers */, 62857C6C1D3988EE008DC254 /* HTMLKitErrorDomain.h in Headers */, 62857CD51D3989BF008DC254 /* CSSInputStream.h in Headers */, 62857C741D398907008DC254 /* HTMLCharacterToken.h in Headers */, @@ -1357,8 +1357,8 @@ 62857D5B1D39A41D008DC254 /* HTMLElementTypes.h in Headers */, 62857D881D39A47F008DC254 /* CSSSelector.h in Headers */, 62857D4F1D39A40A008DC254 /* HTMLTokenizerEntities.h in Headers */, - 621CC49D1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */, 62857D901D39A47F008DC254 /* CSSCompoundSelector.h in Headers */, + 62056C511E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h in Headers */, 62857D4A1D39A3F4008DC254 /* HTMLKitErrorDomain.h in Headers */, 62857D7C1D39A452008DC254 /* HTMLQuirksMode.h in Headers */, 62857D791D39A44E008DC254 /* HTMLNodeFilter.h in Headers */, @@ -1412,7 +1412,6 @@ 62ECBFC61C0B6D4300AF847B /* CSSCombinatorSelector.h in Headers */, 62F7E5A31DEB63F900DEF09B /* HTMLRange+Private.h in Headers */, 626BE1E31DF3819500C49514 /* HTMLDOMUtils.h in Headers */, - 621CC49C1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */, 625D0F041C2717DE00D7BEB0 /* HTMLNode+Private.h in Headers */, 62ECBFC71C0B6D4300AF847B /* CSSCompoundSelector.h in Headers */, 62ECBFB11C0B6D3C00AF847B /* HTMLNodeTraversal.h in Headers */, @@ -1432,6 +1431,7 @@ 62ECBFA01C0B6D3900AF847B /* HTMLStackOfOpenElements.h in Headers */, 62ECBFA11C0B6D3900AF847B /* HTMLListOfActiveFormattingElements.h in Headers */, 62ECBFA21C0B6D3900AF847B /* HTMLElementTypes.h in Headers */, + 62056C501E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h in Headers */, 62ECBFA31C0B6D3900AF847B /* HTMLElementAdjustment.h in Headers */, 62ECBFA41C0B6D3900AF847B /* HTMLParserInsertionModes.h in Headers */, 62ECBFA51C0B6D3900AF847B /* HTMLMarker.h in Headers */, diff --git a/HTMLKit.xcodeproj/xcshareddata/xcschemes/HTMLKit-macOS.xcscheme b/HTMLKit.xcodeproj/xcshareddata/xcschemes/HTMLKit-macOS.xcscheme index a7178bb..e115eb8 100644 --- a/HTMLKit.xcodeproj/xcshareddata/xcschemes/HTMLKit-macOS.xcscheme +++ b/HTMLKit.xcodeproj/xcshareddata/xcschemes/HTMLKit-macOS.xcscheme @@ -26,7 +26,8 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> diff --git a/HTMLKit.xcodeproj/xcshareddata/xcschemes/HTMLKit-tvOS.xcscheme b/HTMLKit.xcodeproj/xcshareddata/xcschemes/HTMLKit-tvOS.xcscheme index 883c1b3..fc392c9 100644 --- a/HTMLKit.xcodeproj/xcshareddata/xcschemes/HTMLKit-tvOS.xcscheme +++ b/HTMLKit.xcodeproj/xcshareddata/xcschemes/HTMLKit-tvOS.xcscheme @@ -26,7 +26,8 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> diff --git a/HTMLKit.xcodeproj/xcshareddata/xcschemes/HTMLKit-watchOS.xcscheme b/HTMLKit.xcodeproj/xcshareddata/xcschemes/HTMLKit-watchOS.xcscheme index 2c81d4b..1fe0add 100644 --- a/HTMLKit.xcodeproj/xcshareddata/xcschemes/HTMLKit-watchOS.xcscheme +++ b/HTMLKit.xcodeproj/xcshareddata/xcschemes/HTMLKit-watchOS.xcscheme @@ -26,7 +26,8 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> diff --git a/README.md b/README.md index 0783c74..fdf1e55 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,12 @@ An Objective-C framework for your everyday HTML needs. [![Platform](https://img.shields.io/cocoapods/p/HTMLKit.svg?style=flat)](http://cocoadocs.org/docsets/HTMLKit) [![License MIT](https://img.shields.io/badge/license-MIT-4481C7.svg?style=flat)](https://opensource.org/licenses/MIT) +- [Quick Overview](#overview) +- [Installation](#installation) +- [Parsing](#parsing) +- [The DOM](#the-dom) +- [CSS3 Selectors](#css3-selectors) + # Quick Overview HTMLKit is a [WHATWG specification](https://html.spec.whatwg.org/multipage/)-compliant framework for parsing and serializing HTML documents and document fragments for iOS and OSX. HTMLKit parses real-world HTML the same way modern web browsers would. @@ -33,7 +39,7 @@ Check out the playground! # Installation -### Carthage +## Carthage [Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. @@ -56,7 +62,7 @@ Then run the following command to build the framework and drag the built `HTMLKi $ carthage update ``` -### CocoaPods +## CocoaPods [CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. @@ -72,7 +78,7 @@ To add `HTMLKit` as a dependency into your project using CocoaPods just add the use_frameworks! target 'MyTarget' do - pod 'HTMLKit', '~> 0.9' + pod 'HTMLKit', '~> 1.1' end ``` @@ -82,14 +88,14 @@ Then, run the following command: $ pod install ``` -### Swift Package Manager +## Swift Package Manager [Swift Package Manager](https://github.com/apple/swift-package-manager) is the package manager for the Swift programming language. Add `HTMLKit` to your `Package.swift` dependecies: ```swift -.Package(url: "https://github.com/iabudiab/HTMLKit", majorVersion: 0, minor: 9) +.Package(url: "https://github.com/iabudiab/HTMLKit", majorVersion: 1) ``` Then run: @@ -98,7 +104,7 @@ Then run: $ swift build ``` -### Manually +## Manually 1- Add `HTMLKit` as git submodule @@ -110,9 +116,9 @@ $ git submodule add https://github.com/iabudiab/HTMLKit.git 3- In the General panel of your target add `HTMLKit.framework` under the `Embedded Binaries` -# Features +# Parsing -# Parsing Documents +## Parsing Documents Given some HTML content, you can parse it either via the `HTMLParser` or instatiate a `HTMLDocument` directly: @@ -127,7 +133,7 @@ HTMLDocument *document = [parser parseDocument]; HTMLDocument *document = [HTMLDocument documentWithString:htmlString]; ``` -# Parsing Fragments +## Parsing Fragments You can also prase HTML content as a document fragment with a specified context element: @@ -150,7 +156,7 @@ nodes = [parser parseFragmentWithContextElement:bodyContext]; # The DOM -Here are some of the things you can do: +The DOM tree can be manipulated in several ways, here are just a few: * Create new elements and assign attributes @@ -174,7 +180,7 @@ NSArray *nodes = @[ [body appendNodes:nodes]; ``` -* Enumerate child elements and perform DOM manipulation +* Enumerate child elements and perform DOM editing ```objective-c [body enumerateChildElementsUsingBlock:^(HTMLElement *element, NSUInteger idx, BOOL *stop) { @@ -194,6 +200,12 @@ NSArray *nodes = @[ [body.lastChild removeFromParentNode]; ``` +* Manipulate the HTML directly + +```objective-c +greenDiv.innerHTML = @"
  • item 1
  • item 2"; +``` + * Navigate to child and sibling nodes ```objective-c @@ -201,12 +213,6 @@ HTMLNode *firstChild = body.firstChild; HTMLNode *greenDiv = firstChild.nextSibling; ``` -* Manipulate the HTML directly - -```objective-c -greenDiv.innerHTML = @"
    • item 1
    • item 2"; -``` - * Iterate the DOM tree with custom filters ```objective-c @@ -222,6 +228,17 @@ for (HTMLElement *element in [body nodeIteratorWithShowOptions:HTMLNodeFilterSho } ``` +* Create and manipulate DOM Ranges + +```objective-c +HTMLDocument *document = [HTMLDocument documentWithString:@"

      HTMLKit

      Hello there!

      "]; +HTMLRange *range = [[HTMLRange alloc] initWithDocument:document]; + +HTMLNode *paragraph = [document querySelector:@"#foo"]; +[range selectNode:paragraph]; +[range extractContents]; +``` + # CSS3 Selectors All CSS3 Selectors are supported except for the pseudo-elements (`::first-line`, `::first-letter`, ...etc.). You can use them the way you always have: diff --git a/Sources/HTMLKit-Info.plist b/Sources/HTMLKit-Info.plist index ecef4c7..7fde877 100644 --- a/Sources/HTMLKit-Info.plist +++ b/Sources/HTMLKit-Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.0 + 1.1.0 CFBundleSignature ???? CFBundleVersion diff --git a/Sources/HTMLCharacterData+Private.h b/Sources/include/HTMLCharacterData+Private.h similarity index 100% rename from Sources/HTMLCharacterData+Private.h rename to Sources/include/HTMLCharacterData+Private.h diff --git a/Sources/HTMLCharacterData.h b/Sources/include/HTMLCharacterData.h similarity index 100% rename from Sources/HTMLCharacterData.h rename to Sources/include/HTMLCharacterData.h diff --git a/Sources/include/HTMLDOM.h b/Sources/include/HTMLDOM.h index c269c14..567062b 100644 --- a/Sources/include/HTMLDOM.h +++ b/Sources/include/HTMLDOM.h @@ -11,6 +11,7 @@ #import "HTMLDocumentType.h" #import "HTMLDocumentFragment.h" #import "HTMLElement.h" +#import "HTMLCharacterData.h" #import "HTMLComment.h" #import "HTMLText.h" #import "HTMLTemplate.h" diff --git a/Sources/HTMLDOMUtils.h b/Sources/include/HTMLDOMUtils.h similarity index 100% rename from Sources/HTMLDOMUtils.h rename to Sources/include/HTMLDOMUtils.h diff --git a/Sources/HTMLDocument+Private.h b/Sources/include/HTMLDocument+Private.h similarity index 100% rename from Sources/HTMLDocument+Private.h rename to Sources/include/HTMLDocument+Private.h diff --git a/Sources/HTMLNodeIterator+Private.h b/Sources/include/HTMLNodeIterator+Private.h similarity index 100% rename from Sources/HTMLNodeIterator+Private.h rename to Sources/include/HTMLNodeIterator+Private.h diff --git a/Sources/HTMLParser+Private.h b/Sources/include/HTMLParser+Private.h similarity index 100% rename from Sources/HTMLParser+Private.h rename to Sources/include/HTMLParser+Private.h diff --git a/Sources/HTMLRange+Private.h b/Sources/include/HTMLRange+Private.h similarity index 100% rename from Sources/HTMLRange+Private.h rename to Sources/include/HTMLRange+Private.h diff --git a/Sources/HTMLRange.h b/Sources/include/HTMLRange.h similarity index 100% rename from Sources/HTMLRange.h rename to Sources/include/HTMLRange.h diff --git a/Sources/module.modulemap b/Sources/module.modulemap index 5f6af82..6eca8e6 100644 --- a/Sources/module.modulemap +++ b/Sources/module.modulemap @@ -16,8 +16,6 @@ module HTMLKit { header "HTMLInputStreamReader.h" header "HTMLListOfActiveFormattingElements.h" header "HTMLMarker.h" - header "HTMLNodeTraversal.h" - header "HTMLDOMUtils.h" header "HTMLParseErrorToken.h" header "HTMLParserInsertionModes.h" header "HTMLStackOfOpenElements.h" @@ -29,9 +27,12 @@ module HTMLKit { header "HTMLTokenizerStates.h" header "HTMLTokens.h" header "HTMLNode+Private.h" + header "HTMLDocument+Private.h" header "HTMLCharacterData+Private.h" header "HTMLRange+Private.h" header "HTMLNodeIterator+Private.h" header "HTMLParser+Private.h" + header "HTMLNodeTraversal.h" + header "HTMLDOMUtils.h" } }