Compare commits
68 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f80b0bbe2 | |||
| f794e04b9f | |||
| 0ffecea0f3 | |||
| 62fef829d3 | |||
| 21dd607ec6 | |||
| 7ae337471c | |||
| 730b8a3239 | |||
| 33a8238513 | |||
| 769113ec0e | |||
| 4970976485 | |||
| 38fef77be5 | |||
| 754b7191b9 | |||
| 56cc5b1a3e | |||
| ccecc4106d | |||
| 39dda3aaf5 | |||
| a136976462 | |||
| 8aabc94fdb | |||
| 322b42b9d1 | |||
| c2acbb6344 | |||
| a6e4aac937 | |||
| 899438fa24 | |||
| 137fa8617e | |||
| 70abd998f7 | |||
| bb948e0ef8 | |||
| b0bad5068f | |||
| a01f1c1c5b | |||
| 6967798823 | |||
| 58b60dd390 | |||
| 4441b7decd | |||
| 0b2681f8a8 | |||
| 1e07acd032 | |||
| 432df997b3 | |||
| c9d72646bc | |||
| 1af25abadb | |||
| 75138cc35f | |||
| 93401e4054 | |||
| 266621edf2 | |||
| 25ad5a3f82 | |||
| cac1e4cedd | |||
| abc847a33b | |||
| 4680a66fd1 | |||
| 465b78dbba | |||
| a64ff8782e | |||
| e03a384aa7 | |||
| 6d2cb09082 | |||
| 222bfa03e1 | |||
| 6254e8a578 | |||
| 01be0acc0a | |||
| 58f0b88ff8 | |||
| b90e673dc0 | |||
| 22f293e718 | |||
| 4511335e9b | |||
| dd2d29b8f0 | |||
| f267958e83 | |||
| b94a80bd24 | |||
| 1df0c4ce1f | |||
| ac49520ad9 | |||
| ee6dbff8d5 | |||
| f004e6328c | |||
| f8255c861a | |||
| 4592037aba | |||
| 948c07e4ae | |||
| 41d9d98201 | |||
| 8199f647f4 | |||
| 977737d538 | |||
| b8d17162d5 | |||
| 27e1ed2bda | |||
| c169f0ed07 |
+42
@@ -0,0 +1,42 @@
|
||||
language: objective-c
|
||||
osx_image: xcode7.3
|
||||
|
||||
branches:
|
||||
except:
|
||||
- gh-pages
|
||||
|
||||
install:
|
||||
- gem install xcpretty
|
||||
|
||||
env:
|
||||
global:
|
||||
- LC_CTYPE=en_US.UTF-8
|
||||
- LANG=en_US.UTF-8
|
||||
- WORKSPACE=HTMLKit.xcworkspace
|
||||
- IOS_FRAMEWORK_SCHEME=HTMLKit-iOS
|
||||
- OSX_FRAMEWORK_SCHEME=HTMLKit-OSX
|
||||
- WATCHOS_FRAMEWORK_SCHEME="HTMLKit-watchOS"
|
||||
- TVOS_FRAMEWORK_SCHEME="HTMLKit-tvOS"
|
||||
- IOS_SDK=iphonesimulator9.3
|
||||
- OSX_SDK=macosx10.11
|
||||
- WATCHOS_SDK=watchsimulator2.2
|
||||
- TVOS_SDK=appletvsimulator9.2
|
||||
matrix:
|
||||
- DESTINATION="OS=9.0,name=iPhone 6" SIMULATOR="iPhone 6 (9.0)" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK"
|
||||
- DESTINATION="OS=9.1,name=iPhone 6 Plus" SIMULATOR="iPhone 6 Plus (9.1)" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK"
|
||||
- DESTINATION="OS=9.2,name=iPhone 6S" SIMULATOR="iPhone 6S (9.2)" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK"
|
||||
- DESTINATION="OS=9.3,name=iPhone 6S Plus" SIMULATOR="iPhone 6S Plus (9.3)" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK"
|
||||
- DESTINATION="arch=x86_64" SIMULATOR="" SCHEME="$OSX_FRAMEWORK_SCHEME" SDK="$OSX_SDK"
|
||||
- DESTINATION="OS=2.2,name=Apple Watch - 42mm" SIMULATOR="Apple Watch - 42mm (2.2)" SCHEME="$WATCHOS_FRAMEWORK_SCHEME" SDK="$WATCHOS_SDK"
|
||||
- DESTINATION="OS=9.2,name=Apple TV 1080p" SIMULATOR="Apple TV 1080p (9.2)" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="$TVOS_SDK"
|
||||
|
||||
script:
|
||||
- set -o pipefail
|
||||
- xcodebuild -version
|
||||
- xcodebuild -showsdks
|
||||
- SIMULATOR_ID=$(xcrun instruments -s devices | grep -io "$SIMULATOR \[.*\]" | grep -o "\[.*\]" | sed "s/^\[\(.*\)\]$/\1/")
|
||||
- open -b com.apple.iphonesimulator --args -CurrentDeviceUDID $SIMULATOR_ID
|
||||
- xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO clean build | xcpretty -c
|
||||
- if [ "$SDK" != "$WATCHOS_SDK" ]; then
|
||||
xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO test | xcpretty -c;
|
||||
fi
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
# Change Log
|
||||
|
||||
## [0.9.3](https://github.com/iabudiab/HTMLKit/releases/tag/0.9.3)
|
||||
|
||||
Released on 2016.07.16
|
||||
|
||||
This release passes all html5lib-tests as of 2016.07.16
|
||||
|
||||
### Added
|
||||
|
||||
- `watchOS` and `tvOS` targets
|
||||
- Updated HTML5Lib-Tests submodule (c305da7)
|
||||
|
||||
## [0.9.2](https://github.com/iabudiab/HTMLKit/releases/tag/0.9.2)
|
||||
|
||||
Released on 2016.05.18
|
||||
|
||||
This release passes all html5lib-tests as of 2016.05.18
|
||||
|
||||
### Added
|
||||
|
||||
- Handling for `<menu>` and `<menuitem>`
|
||||
- Changelog
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated adoption agency algorithm according to the latest specification, see:
|
||||
- [whatwg/html@22ce3c3](https://github.com/whatwg/html/commit/22ce3c3)
|
||||
- [Mozilla Bug 901319](https://bugzilla.mozilla.org/show_bug.cgi?id=901319)
|
||||
- [Chrome Issue 268121](https://bugs.chromium.org/p/chromium/issues/detail?id=268121)
|
||||
- [WebKit Bug 119478](https://bugs.webkit.org/show_bug.cgi?id=119478)
|
||||
- `<isindex>` 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
|
||||
|
||||
- `<isindex>` 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
|
||||
|
||||
### Fixed
|
||||
|
||||
- Parser now checks the qualified name instead of the local name when handling elements in the `MathML` and `SVG` namespaces
|
||||
|
||||
|
||||
## [0.9.1](https://github.com/iabudiab/HTMLKit/releases/tag/0.9.1)
|
||||
|
||||
Released on 2016.01.29
|
||||
|
||||
### Added
|
||||
|
||||
- Travis-CI integration.
|
||||
- CocoaPods spec.
|
||||
|
||||
|
||||
### Changed
|
||||
|
||||
- Warnings are treated as errors.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Warnings related to format specifier and loss of precision due to NS(U)-integer usage.
|
||||
- Replaced `@returns` with `@return` throughout the documentation to play nicely with Jazzy.
|
||||
- Some README examples used Swift syntax.
|
||||
|
||||
## [0.9.0](https://github.com/iabudiab/HTMLKit/releases/tag/0.9.0)
|
||||
|
||||
Released on 2015.12.23
|
||||
|
||||
This is the first public release of `HTMLKit`.
|
||||
|
||||
### Added
|
||||
|
||||
- `iOS` & `OSX` Frameworks.
|
||||
- Source code documentation.
|
||||
- CSS Selectors extension (analogous to jQuery selectors).
|
||||
- `DOMTokenList` for malipulating `HTMLElements` attributes as a list, e.g. `class`.
|
||||
- Handling for `<ruby>` elements in the Parser implementation.
|
||||
- Updated HTML5Lib-Tests submodule (56c435f)
|
||||
- Xcode Playground with Swift documentation.
|
||||
|
||||
### Removed
|
||||
|
||||
- Unused namespaces.
|
||||
- Historical node types.
|
||||
|
||||
|
||||
### Fixed
|
||||
|
||||
- `lt`, `gt` & `eq` CSS Selectors method declarations.
|
||||
|
||||
## [0.3.0](https://github.com/iabudiab/HTMLKit/releases/tag/0.3.0)
|
||||
|
||||
Released on 2015.11.29
|
||||
|
||||
### Added
|
||||
|
||||
- CSS3 Selectors support.
|
||||
- Nullability annotations.
|
||||
- `HTMLNode` properties for previous and next sibling elements.
|
||||
- `HTMLNode` methods for accessing child elements (analogous to child nodes).
|
||||
- `NSCharacterSet` category for HTML-related character sets.
|
||||
|
||||
### Fixed
|
||||
|
||||
- `InputStreaReader`'s reconsume-logic that is required by the CSS Parser.
|
||||
|
||||
## [0.2.0](https://github.com/iabudiab/HTMLKit/releases/tag/0.1.0)
|
||||
|
||||
Released on 2015.06.06
|
||||
|
||||
### Added
|
||||
|
||||
- `HTMLDocument` methods to access `root`, `head` & `body` elements.
|
||||
- `innerHTML` implementation for the `HTMLElement`.
|
||||
- `HTMLNode` methods to append, prepend, check containment and descendancy of nodes.
|
||||
- `HTMLNode` methods to enumerate child nodes.
|
||||
- Implementations for `NodeIterator` and `NodeFilter`
|
||||
- Implementation for `TreeWalker`
|
||||
- Validation for DOM manipulations.
|
||||
- Tests for the DOM implementation.
|
||||
|
||||
### Changed
|
||||
|
||||
- `type` property renamed to `nodeType` in `HTMLNode`.
|
||||
- `firstChildNode` and `lastChildNode` renamed to `firtChild` and `lastChild` in `HTMLNode`.
|
||||
|
||||
### Removed
|
||||
|
||||
- `baseURI` proeprty from `HTMLNode`
|
||||
- `HTMLNodeTreeEnumerator` is superseded by the `HTMLNodeIterator`.
|
||||
|
||||
## [0.1.0](https://github.com/iabudiab/HTMLKit/releases/tag/0.1.0)
|
||||
|
||||
Released on 2015.04.20
|
||||
|
||||
### Added
|
||||
|
||||
- Initial release.
|
||||
- Initial DOM implementation.
|
||||
- Tokenizer and Parser pass all [HTML5Lib](https://github.com/html5lib/html5lib-tests) tokenizer and tree construction tests except for `<ruby>` elements.
|
||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 116 KiB |
@@ -0,0 +1,23 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "HTMLKit"
|
||||
s.version = "0.9.3"
|
||||
s.summary = "HTMLKit, an Objective-C framework for your everyday HTML needs."
|
||||
s.license = "MIT"
|
||||
s.homepage = "https://github.com/iabudiab/HTMLKit"
|
||||
s.author = "iabudiab"
|
||||
s.social_media_url = "https://twitter.com/_iabudiab"
|
||||
|
||||
s.ios.deployment_target = "8.0"
|
||||
s.osx.deployment_target = "10.9"
|
||||
s.watchos.deployment_target = "2.0"
|
||||
s.tvos.deployment_target = "9.0"
|
||||
|
||||
s.source = { :git => "https://github.com/iabudiab/HTMLKit.git", :tag => s.version }
|
||||
|
||||
s.source_files = "HTMLKit", "HTMLKit/**/*.{h,m}"
|
||||
s.private_header_files = [
|
||||
'HTMLKit/**/*{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'
|
||||
]
|
||||
|
||||
s.requires_arc = true
|
||||
end
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0730"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "62857CE91D39A262008DC254"
|
||||
BuildableName = "HTMLKit.framework"
|
||||
BlueprintName = "HTMLKit-tvOS"
|
||||
ReferencedContainer = "container:HTMLKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "62857CF21D39A262008DC254"
|
||||
BuildableName = "HTMLKit-tvOSTests.xctest"
|
||||
BlueprintName = "HTMLKit-tvOSTests"
|
||||
ReferencedContainer = "container:HTMLKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
<SkippedTests>
|
||||
<Test
|
||||
Identifier = "HTMLKitParserPerformance">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "HTMLKitTokenizerPerformance">
|
||||
</Test>
|
||||
</SkippedTests>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "62857CE91D39A262008DC254"
|
||||
BuildableName = "HTMLKit.framework"
|
||||
BlueprintName = "HTMLKit-tvOS"
|
||||
ReferencedContainer = "container:HTMLKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "62857CE91D39A262008DC254"
|
||||
BuildableName = "HTMLKit.framework"
|
||||
BlueprintName = "HTMLKit-tvOS"
|
||||
ReferencedContainer = "container:HTMLKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "62857CE91D39A262008DC254"
|
||||
BuildableName = "HTMLKit.framework"
|
||||
BlueprintName = "HTMLKit-tvOS"
|
||||
ReferencedContainer = "container:HTMLKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0730"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "62857C4D1D398642008DC254"
|
||||
BuildableName = "HTMLKit.framework"
|
||||
BlueprintName = "HTMLKit-watchOS"
|
||||
ReferencedContainer = "container:HTMLKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "62857C4D1D398642008DC254"
|
||||
BuildableName = "HTMLKit.framework"
|
||||
BlueprintName = "HTMLKit-watchOS"
|
||||
ReferencedContainer = "container:HTMLKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "62857C4D1D398642008DC254"
|
||||
BuildableName = "HTMLKit.framework"
|
||||
BlueprintName = "HTMLKit-watchOS"
|
||||
ReferencedContainer = "container:HTMLKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Intializes and returns a CSS class selector.
|
||||
|
||||
@param className The class name to match.
|
||||
@returns A new instance of class selector.
|
||||
@return A new instance of class selector.
|
||||
*/
|
||||
+ (instancetype)classSelector:(NSString *)className;
|
||||
|
||||
@@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Intializes and returns a CSS id selector.
|
||||
|
||||
@param elementId The element id to match.
|
||||
@returns A new instance of id selector.
|
||||
@return A new instance of id selector.
|
||||
*/
|
||||
+ (instancetype)idSelector:(NSString *)elementId;
|
||||
|
||||
@@ -51,7 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Intializes and returns a CSS has-attribute selector.
|
||||
|
||||
@param attributeName The attribute name to match.
|
||||
@returns A new instance of has-attribute selector.
|
||||
@return A new instance of has-attribute selector.
|
||||
*/
|
||||
+ (instancetype)hasAttributeSelector:(NSString *)attributeName;
|
||||
|
||||
@@ -61,7 +61,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@param type The selector type.
|
||||
@param name The attribute name to match.
|
||||
@param value The value to match.
|
||||
@returns A new instance of attribute selector.
|
||||
@return A new instance of attribute selector.
|
||||
*/
|
||||
- (instancetype)initWithType:(CSSAttributeSelectorType)type
|
||||
attributeName:(NSString *)name
|
||||
|
||||
@@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes and returns a CSS child-of-element selector, e.g. 'div > p'
|
||||
|
||||
@param selector The selector matching the parent element.
|
||||
@returns A new instance of the child of element selector.
|
||||
@return A new instance of the child of element selector.
|
||||
*/
|
||||
+ (instancetype)childOfElementCombinator:(CSSSelector *)selector;
|
||||
|
||||
@@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes and returns a CSS descendant-of-element selector, e.g. 'div p'
|
||||
|
||||
@param selector The selector matching the ancestor element.
|
||||
@returns A new instance of the descendant of element selector.
|
||||
@return A new instance of the descendant of element selector.
|
||||
*/
|
||||
+ (instancetype)descendantOfElementCombinator:(CSSSelector *)selector;
|
||||
|
||||
@@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes and returns a CSS adjacent sibling selector, e.g. 'p + a'
|
||||
|
||||
@param selector The selector matching the adjacent sibling element.
|
||||
@returns A new instance of the adjacent sibling selector.
|
||||
@return A new instance of the adjacent sibling selector.
|
||||
*/
|
||||
+ (instancetype)adjacentSiblingCombinator:(CSSSelector *)selector;
|
||||
|
||||
@@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes and returns a CSS general sibling selector, e.g. 'p ~ a'
|
||||
|
||||
@param selector The selector matching the general sibling element.
|
||||
@returns A new instance of the general sibling selector.
|
||||
@return A new instance of the general sibling selector.
|
||||
*/
|
||||
+ (instancetype)generalSiblingCombinator:(CSSSelector *)selector;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes and returns a new compound selector matching only elements that match all of the specified selectors.
|
||||
|
||||
@param selectors The selectors list.
|
||||
@returns A new instance of the All-Of selector.
|
||||
@return A new instance of the All-Of selector.
|
||||
*/
|
||||
+ (instancetype)andSelector:(NSArray<CSSSelector *> *)selectors;
|
||||
|
||||
@@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes and returns a new compound selector matching all elements that match at least one of the specified selectors.
|
||||
|
||||
@param selectors The selectors list.
|
||||
@returns A new instance of the Any-Of selector.
|
||||
@return A new instance of the Any-Of selector.
|
||||
*/
|
||||
+ (instancetype)orSelector:(NSArray<CSSSelector *> *)selectors;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
http://www.w3.org/TR/css-syntax-3/#consume-a-string-token
|
||||
http://www.w3.org/TR/css-syntax-3/#would-start-an-identifier
|
||||
|
||||
@returns A consumed identifier, `nil` if the stream doesn't start with a valid identifier.
|
||||
@return A consumed identifier, `nil` if the stream doesn't start with a valid identifier.
|
||||
*/
|
||||
- (NSString *)consumeIdentifier;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
Consumes characters until the specified code-point is met.
|
||||
|
||||
@param endingCodePoint The code-point at which the input stream stops consuming.
|
||||
@returns The consumed string, `nil` nothing was consumed.
|
||||
@return The consumed string, `nil` nothing was consumed.
|
||||
*/
|
||||
- (NSString *)consumeStringWithEndingCodePoint:(UTF32Char)endingCodePoint;
|
||||
|
||||
@@ -48,14 +48,14 @@
|
||||
http://www.w3.org/TR/css-syntax-3/#consume-an-escaped-code-point
|
||||
http://www.w3.org/TR/css-syntax-3/#starts-with-a-valid-escape
|
||||
|
||||
@returns The value of the escaped code-point.
|
||||
@return The value of the escaped code-point.
|
||||
*/
|
||||
- (UTF32Char)consumeEscapedCodePoint;
|
||||
|
||||
/**
|
||||
Consumes a CSS selector combinator.
|
||||
|
||||
@returns The consumed combinator, `nil` if nothing was consumed.
|
||||
@return The consumed combinator, `nil` if nothing was consumed.
|
||||
*/
|
||||
- (NSString *)consumeCombinator;
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
}
|
||||
|
||||
NSScanner *scanner = [NSScanner scannerWithString:(__bridge NSString *)(hexString)];
|
||||
UTF32Char number;
|
||||
unsigned int number;
|
||||
[scanner scanHexInt:&number];
|
||||
|
||||
return isValidEscapedCodePoint(number) ? number : REPLACEMENT_CHARACTER;
|
||||
|
||||
@@ -31,7 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes a new CSS nth-child selector, e.g. ':nth-child(2n+3)'
|
||||
|
||||
@param expression The nth-expression.
|
||||
@returns Nth-Child selector for the specified expression.
|
||||
@return Nth-Child selector for the specified expression.
|
||||
|
||||
@see CSSNthExpression
|
||||
*/
|
||||
@@ -41,7 +41,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes a new CSS nth-last-child selector, e.g. ':nth-last-child(2n+3)'
|
||||
|
||||
@param expression The nth-expression.
|
||||
@returns Nth-Last-Child selector for the specified expression.
|
||||
@return Nth-Last-Child selector for the specified expression.
|
||||
|
||||
@see CSSNthExpression
|
||||
*/
|
||||
@@ -51,7 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes a new CSS nth-of-type selector, e.g. ':nth-of-type(2n+3)'
|
||||
|
||||
@param expression The nth-expression.
|
||||
@returns Nth-Of-Type selector for the specified expression.
|
||||
@return Nth-Of-Type selector for the specified expression.
|
||||
|
||||
@see CSSNthExpression
|
||||
*/
|
||||
@@ -61,7 +61,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes a new CSS nth-last-of-type selector, e.g. ':nth-last-of-type(2n+3)'
|
||||
|
||||
@param expression The nth-expression.
|
||||
@returns Nth-Last-Of-Type selector for the specified expression.
|
||||
@return Nth-Last-Of-Type selector for the specified expression.
|
||||
|
||||
@see CSSNthExpression
|
||||
*/
|
||||
|
||||
@@ -27,13 +27,13 @@ NSString * _Nonnull NSStringFromNthExpression(CSSNthExpression expression)
|
||||
}
|
||||
|
||||
if (expression.an == 0) {
|
||||
return [NSString stringWithFormat:@"%ld", expression.b];
|
||||
return [NSString stringWithFormat:@"%ld", (long)expression.b];
|
||||
}
|
||||
if (expression.b == 0) {
|
||||
return [NSString stringWithFormat:@"%ldn", expression.an];
|
||||
return [NSString stringWithFormat:@"%ldn", (long)expression.an];
|
||||
}
|
||||
|
||||
return [NSString stringWithFormat:@"%ldn%+ld", expression.an, expression.b];
|
||||
return [NSString stringWithFormat:@"%ldn%+ld", (long)expression.an, (long)expression.b];
|
||||
}
|
||||
|
||||
#pragma mark - Implementation
|
||||
|
||||
@@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@param className The pseudo class name.
|
||||
@param selector The underlying selector.
|
||||
@returns A new instance of a pseudo-class selector.
|
||||
@return A new instance of a pseudo-class selector.
|
||||
*/
|
||||
- (instancetype)initWithClassName:(NSString *)className selector:(CSSSelector *)selector;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes and returns a CSS nagation selector, e.g. ':not(div)'
|
||||
|
||||
@param selector The selector which should be negated.
|
||||
@returns A new instance of the negation selector.
|
||||
@return A new instance of the negation selector.
|
||||
*/
|
||||
+ (instancetype)notSelector:(CSSSelector *)selector;
|
||||
|
||||
@@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@discussion 'div:has(p)' matches all <div> elements which have a descendant <p> element.
|
||||
|
||||
@param selector The selector matching a descendant element.
|
||||
@returns A new instance of the has-descendant selector.
|
||||
@return A new instance of the has-descendant selector.
|
||||
*/
|
||||
+ (instancetype)hasSelector:(CSSSelector *)selector;
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ extern NSString * _Nonnull NSStringFromNthExpression(CSSNthExpression expression
|
||||
Initializes and returns a new instance of CSS Selector.
|
||||
|
||||
@param string The selector string which will be parsed.
|
||||
@returns A new instance of a parsed CSS Selector, `nil` if the string is not a valid selector string.
|
||||
@return A new instance of a parsed CSS Selector, `nil` if the string is not a valid selector string.
|
||||
*/
|
||||
+ (nullable instancetype)selectorWithString:(NSString *)stirng;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@param name The name of the selector.
|
||||
@param block The block that should match desired elements.
|
||||
@returns A new instance of the block-based selector.
|
||||
@return A new instance of the block-based selector.
|
||||
*/
|
||||
- (instancetype)initWithName:(NSString *)name block:(BOOL (^)(HTMLElement *))block;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@param string The CSS3 selector string.
|
||||
@param error If an error occurs, upon return contains an `NSError` object that describes the problem.
|
||||
@returns A parsed CSSSelector, `nil` if an error occurred.
|
||||
@return A parsed CSSSelector, `nil` if an error occurred.
|
||||
|
||||
@see CSSelector
|
||||
*/
|
||||
|
||||
+28
-28
@@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/**
|
||||
Universal CSS selector: '*'
|
||||
|
||||
@returns The universal CSS selector.
|
||||
@return The universal CSS selector.
|
||||
*/
|
||||
extern CSSSelector * universalSelector();
|
||||
|
||||
@@ -32,7 +32,7 @@ extern CSSSelector * universalSelector();
|
||||
CSS type selector, e.g. 'div', 'p', ...etc.
|
||||
|
||||
@param type The element type.
|
||||
@returns Type selector for the specified type.
|
||||
@return Type selector for the specified type.
|
||||
*/
|
||||
extern CSSSelector * typeSelector(NSString *type);
|
||||
|
||||
@@ -42,7 +42,7 @@ extern CSSSelector * typeSelector(NSString *type);
|
||||
CSS id selector, e.g. '#someId'
|
||||
|
||||
@param elementId The element id.
|
||||
@returns Id selector for the specified element id.
|
||||
@return Id selector for the specified element id.
|
||||
*/
|
||||
extern CSSSelector * idSelector(NSString *elementId);
|
||||
|
||||
@@ -50,7 +50,7 @@ extern CSSSelector * idSelector(NSString *elementId);
|
||||
CSS class selector, e.g. '.someClass'
|
||||
|
||||
@param className The class name.
|
||||
@returns Class selector for the specified class name.
|
||||
@return Class selector for the specified class name.
|
||||
*/
|
||||
extern CSSSelector * classSelector(NSString *className);
|
||||
|
||||
@@ -58,7 +58,7 @@ extern CSSSelector * classSelector(NSString *className);
|
||||
CSS has-attribute selector, e.g. '[href]'
|
||||
|
||||
@param attribute The attribute.
|
||||
@returns Has-Attribute selector for the specified attribute.
|
||||
@return Has-Attribute selector for the specified attribute.
|
||||
*/
|
||||
extern CSSSelector * hasAttributeSelector(NSString *attribute);
|
||||
|
||||
@@ -68,7 +68,7 @@ extern CSSSelector * hasAttributeSelector(NSString *attribute);
|
||||
@param type The attribute selector type.
|
||||
@param attribute The attribute.
|
||||
@param value The value of the attribute.
|
||||
@returns Attribute selector.
|
||||
@return Attribute selector.
|
||||
|
||||
@see CSSAttributeSelectorType
|
||||
*/
|
||||
@@ -82,7 +82,7 @@ extern CSSSelector * attributeSelector(CSSAttributeSelectorType type,
|
||||
CSS nth-child selector, e.g. ':nth-child(2n+3)'
|
||||
|
||||
@param expression The nth-expression.
|
||||
@returns Nth-Child selector for the specified expression.
|
||||
@return Nth-Child selector for the specified expression.
|
||||
|
||||
@see CSSNthExpression
|
||||
*/
|
||||
@@ -92,7 +92,7 @@ extern CSSSelector * nthChildSelector(CSSNthExpression expression);
|
||||
CSS nth-last-child selector, e.g. ':nth-last-child(2n+3)'
|
||||
|
||||
@param expression The nth-expression.
|
||||
@returns Nth-Last-Child selector for the specified expression.
|
||||
@return Nth-Last-Child selector for the specified expression.
|
||||
|
||||
@see CSSNthExpression
|
||||
*/
|
||||
@@ -102,7 +102,7 @@ extern CSSSelector * nthLastChildSelector(CSSNthExpression expression);
|
||||
CSS nth-of-type selector, e.g. ':nth-of-type(2n+3)'
|
||||
|
||||
@param expression The nth-expression.
|
||||
@returns Nth-Of-Type selector for the specified expression.
|
||||
@return Nth-Of-Type selector for the specified expression.
|
||||
|
||||
@see CSSNthExpression
|
||||
*/
|
||||
@@ -112,7 +112,7 @@ extern CSSSelector * nthOfTypeSelector(CSSNthExpression expression);
|
||||
CSS nth-last-of-type selector, e.g. ':nth-last-of-type(2n+3)'
|
||||
|
||||
@param expression The nth-expression.
|
||||
@returns Nth-Last-Of-Type selector for the specified expression.
|
||||
@return Nth-Last-Of-Type selector for the specified expression.
|
||||
|
||||
@see CSSNthExpression
|
||||
*/
|
||||
@@ -123,7 +123,7 @@ extern CSSSelector * nthLastOfTypeSelector(CSSNthExpression expression);
|
||||
|
||||
This is analogous to ':nth-child(2n+1)'
|
||||
|
||||
@returns Odd-Child selector.
|
||||
@return Odd-Child selector.
|
||||
*/
|
||||
extern CSSSelector * oddSelector();
|
||||
|
||||
@@ -132,49 +132,49 @@ extern CSSSelector * oddSelector();
|
||||
|
||||
This is analogous to ':nth-child(2n)'
|
||||
|
||||
@returns Even-Child selector.
|
||||
@return Even-Child selector.
|
||||
*/
|
||||
extern CSSSelector * evenSlector();
|
||||
|
||||
/**
|
||||
CSS first-child selector: ':nth-child(1)'
|
||||
|
||||
@returns First-Child selector.
|
||||
@return First-Child selector.
|
||||
*/
|
||||
extern CSSSelector * firstChildSelector();
|
||||
|
||||
/**
|
||||
CSS first-child selector: ':nth-last-child(1)'
|
||||
|
||||
@returns First-Child selector.
|
||||
@return First-Child selector.
|
||||
*/
|
||||
extern CSSSelector * lastChildSelector();
|
||||
|
||||
/**
|
||||
CSS first-of-type selector: ':nth-first-of-type(1)'
|
||||
|
||||
@returns First-Of-Type selector.
|
||||
@return First-Of-Type selector.
|
||||
*/
|
||||
extern CSSSelector * firstOfTypeSelector();
|
||||
|
||||
/**
|
||||
CSS last-of-type selector: ':nth-last-of-type(1)'
|
||||
|
||||
@returns Last-Of-Type selector.
|
||||
@return Last-Of-Type selector.
|
||||
*/
|
||||
extern CSSSelector * lastOfTypeSelector();
|
||||
|
||||
/**
|
||||
CSS only-child selector: ':first-child:last-child'
|
||||
|
||||
@returns Only-Child selector.
|
||||
@return Only-Child selector.
|
||||
*/
|
||||
extern CSSSelector * onlyChildSelector();
|
||||
|
||||
/**
|
||||
CSS only-of-type selector: ':first-of-type:last-of-type'
|
||||
|
||||
@returns Only-Of-Type selector.
|
||||
@return Only-Of-Type selector.
|
||||
*/
|
||||
extern CSSSelector * onlyOfTypeSelector();
|
||||
|
||||
@@ -184,7 +184,7 @@ extern CSSSelector * onlyOfTypeSelector();
|
||||
CSS child-of-element selector, e.g. 'div > p'
|
||||
|
||||
@param selector The selector matching the parent element.
|
||||
@returns A child of element selector.
|
||||
@return A child of element selector.
|
||||
*/
|
||||
extern CSSSelector * childOfElementSelector(CSSSelector *selector);
|
||||
|
||||
@@ -192,7 +192,7 @@ extern CSSSelector * childOfElementSelector(CSSSelector *selector);
|
||||
CSS descendant-of-element selector, e.g. 'div p'
|
||||
|
||||
@param selector The selector matching the ancestor element.
|
||||
@returns A descendant of element selector.
|
||||
@return A descendant of element selector.
|
||||
*/
|
||||
extern CSSSelector * descendantOfElementSelector(CSSSelector *selector);
|
||||
|
||||
@@ -200,7 +200,7 @@ extern CSSSelector * descendantOfElementSelector(CSSSelector *selector);
|
||||
CSS adjacent sibling selector, e.g. 'p + a'
|
||||
|
||||
@param selector The selector matching the adjacent sibling element.
|
||||
@returns A adjacent sibling selector.
|
||||
@return A adjacent sibling selector.
|
||||
*/
|
||||
extern CSSSelector * adjacentSiblingSelector(CSSSelector *selector);
|
||||
|
||||
@@ -208,7 +208,7 @@ extern CSSSelector * adjacentSiblingSelector(CSSSelector *selector);
|
||||
CSS general sibling selector, e.g. 'p ~ a'
|
||||
|
||||
@param selector The selector matching the general sibling element.
|
||||
@returns A general sibling selector.
|
||||
@return A general sibling selector.
|
||||
*/
|
||||
extern CSSSelector * generalSiblingSelector(CSSSelector *selector);
|
||||
|
||||
@@ -218,7 +218,7 @@ extern CSSSelector * generalSiblingSelector(CSSSelector *selector);
|
||||
CSS nagation selector: ':not(div)'
|
||||
|
||||
@param selector The selector which should be negated.
|
||||
@returns A negation selector.
|
||||
@return A negation selector.
|
||||
*/
|
||||
extern CSSSelector * not(CSSSelector *selector);
|
||||
|
||||
@@ -228,7 +228,7 @@ extern CSSSelector * not(CSSSelector *selector);
|
||||
@discussion 'div:has(p)' matches all <div> elements which have a descendant <p> element.
|
||||
|
||||
@param selector The selector matching a descendant element.
|
||||
@returns A has-descendant selector.
|
||||
@return A has-descendant selector.
|
||||
*/
|
||||
extern CSSSelector * has(CSSSelector *selector);
|
||||
|
||||
@@ -238,7 +238,7 @@ extern CSSSelector * has(CSSSelector *selector);
|
||||
A compound selector matching only elements that match all of the specified selectors.
|
||||
|
||||
@param selectors The selectors list.
|
||||
@returns All-Of selector.
|
||||
@return All-Of selector.
|
||||
*/
|
||||
extern CSSSelector * allOf(NSArray<CSSSelector *> *selectors);
|
||||
|
||||
@@ -246,7 +246,7 @@ extern CSSSelector * allOf(NSArray<CSSSelector *> *selectors);
|
||||
A compound selector matching all elements that match at least one of the specified selectors.
|
||||
|
||||
@param selectors The selectors list.
|
||||
@returns Any-Of selector.
|
||||
@return Any-Of selector.
|
||||
*/
|
||||
extern CSSSelector * anyOf(NSArray<CSSSelector *> *selectors);
|
||||
|
||||
@@ -259,7 +259,7 @@ extern CSSSelector * anyOf(NSArray<CSSSelector *> *selectors);
|
||||
|
||||
@param name The name of the selector.
|
||||
@param selector The underlying selector.
|
||||
@returns A named-pseudo selector.
|
||||
@return A named-pseudo selector.
|
||||
*/
|
||||
extern CSSSelector * namedPseudoSelector(NSString *name, CSSSelector *selector);
|
||||
|
||||
@@ -270,7 +270,7 @@ extern CSSSelector * namedPseudoSelector(NSString *name, CSSSelector *selector);
|
||||
|
||||
@param name The name of the selector.
|
||||
@param acceptBlock The block which provides the implementation for the accept-element logic.
|
||||
@returns A named-block selector.
|
||||
@return A named-block selector.
|
||||
*/
|
||||
extern CSSSelector * namedBlockSelector(NSString *name, BOOL (^ acceptBlock)(HTMLElement *element));
|
||||
|
||||
|
||||
@@ -11,102 +11,102 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
@returns Root element selector: ':root'
|
||||
@return Root element selector: ':root'
|
||||
*/
|
||||
extern CSSSelector * rootSelector();
|
||||
|
||||
/**
|
||||
@returns Empy element selector: ':empty'
|
||||
@return Empy element selector: ':empty'
|
||||
*/
|
||||
extern CSSSelector * emptySelector();
|
||||
|
||||
/**
|
||||
@returns A parent element selector: ':parent'
|
||||
@return A parent element selector: ':parent'
|
||||
*/
|
||||
extern CSSSelector * parentSelector();
|
||||
|
||||
/**
|
||||
@returns A button element selector: ':button'
|
||||
@return A button element selector: ':button'
|
||||
*/
|
||||
extern CSSSelector * buttonSelector();
|
||||
|
||||
/**
|
||||
@returns A checkbox element selector: ':checkbox'
|
||||
@return A checkbox element selector: ':checkbox'
|
||||
*/
|
||||
extern CSSSelector * checkboxSelector();
|
||||
|
||||
/**
|
||||
@returns A file element selector: ':file'
|
||||
@return A file element selector: ':file'
|
||||
*/
|
||||
extern CSSSelector * fileSelector();
|
||||
|
||||
/**
|
||||
@returns A header element selector: ':header'
|
||||
@return A header element selector: ':header'
|
||||
*/
|
||||
extern CSSSelector * headerSelector();
|
||||
|
||||
/**
|
||||
@returns An image element selector: ':image'
|
||||
@return An image element selector: ':image'
|
||||
*/
|
||||
extern CSSSelector * imageSelector();
|
||||
|
||||
/**
|
||||
@returns A parent element selector: ':parent'
|
||||
@return A parent element selector: ':parent'
|
||||
*/
|
||||
extern CSSSelector * inputSelector();
|
||||
|
||||
/**
|
||||
@returns A link element selector: ':link'
|
||||
@return A link element selector: ':link'
|
||||
*/
|
||||
extern CSSSelector * linkSelector();
|
||||
|
||||
/**
|
||||
@returns A password element selector: ':password'
|
||||
@return A password element selector: ':password'
|
||||
*/
|
||||
extern CSSSelector * passwordSelector();
|
||||
|
||||
/**
|
||||
@returns A radio element selector: ':radio'
|
||||
@return A radio element selector: ':radio'
|
||||
*/
|
||||
extern CSSSelector * radioSelector();
|
||||
|
||||
/**
|
||||
@returns A reset element selector: ':reset'
|
||||
@return A reset element selector: ':reset'
|
||||
*/
|
||||
extern CSSSelector * resetSelector();
|
||||
|
||||
/**
|
||||
@returns A submit element selector: ':submit'
|
||||
@return A submit element selector: ':submit'
|
||||
*/
|
||||
extern CSSSelector * submitSelector();
|
||||
|
||||
/**
|
||||
@returns A text element selector: ':text'
|
||||
@return A text element selector: ':text'
|
||||
*/
|
||||
extern CSSSelector * textSelector();
|
||||
|
||||
/**
|
||||
@returns An enabled element selector: ':enabled'
|
||||
@return An enabled element selector: ':enabled'
|
||||
*/
|
||||
extern CSSSelector * enabledSelector();
|
||||
|
||||
/**
|
||||
@returns A disabled element selector: ':disabled'
|
||||
@return A disabled element selector: ':disabled'
|
||||
*/
|
||||
extern CSSSelector * disabledSelector();
|
||||
|
||||
/**
|
||||
@returns A checked element selector: ':checked'
|
||||
@return A checked element selector: ':checked'
|
||||
*/
|
||||
extern CSSSelector * checkedSelector();
|
||||
|
||||
/**
|
||||
@returns An optional element selector: ':optional'
|
||||
@return An optional element selector: ':optional'
|
||||
*/
|
||||
extern CSSSelector * optionalSelector();
|
||||
|
||||
/**
|
||||
@returns A required element selector: ':required'
|
||||
@return A required element selector: ':required'
|
||||
*/
|
||||
extern CSSSelector * requiredSelector();
|
||||
|
||||
@@ -116,7 +116,7 @@ extern CSSSelector * requiredSelector();
|
||||
Selects all elements at an index less than the specified index. A negative index counts backwards from the last element.
|
||||
|
||||
@param index The zero-based index of the element to match.
|
||||
@returns A Less-Than selector.
|
||||
@return A Less-Than selector.
|
||||
*/
|
||||
extern CSSSelector * ltSelector(NSInteger index);
|
||||
|
||||
@@ -127,7 +127,7 @@ extern CSSSelector * ltSelector(NSInteger index);
|
||||
last element.
|
||||
|
||||
@param index The zero-based index of the element to match.
|
||||
@returns A Greater-Than selector.
|
||||
@return A Greater-Than selector.
|
||||
*/
|
||||
extern CSSSelector * gtSelector(NSInteger index);
|
||||
|
||||
@@ -137,7 +137,7 @@ extern CSSSelector * gtSelector(NSInteger index);
|
||||
Selects the element at the specified index. A negative index counts backwards from the last element.
|
||||
|
||||
@param index The zero-based index of the element to match.
|
||||
@returns An Equal selector.
|
||||
@return An Equal selector.
|
||||
*/
|
||||
extern CSSSelector * eqSelector(NSInteger index);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/**
|
||||
Returns the universal selector.
|
||||
|
||||
@returns A new instance of a universal selector that matches all elements.
|
||||
@return A new instance of a universal selector that matches all elements.
|
||||
*/
|
||||
+ (instancetype)universalSelector;
|
||||
|
||||
@@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes a new selector for the specified type.
|
||||
|
||||
@param type The type of elements that should be matched.
|
||||
@returns A new instance of a type selector.
|
||||
@return A new instance of a type selector.
|
||||
*/
|
||||
- (instancetype)initWithType:(NSString *)type;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
Initializes a new character token.
|
||||
|
||||
@param string The string with which to initialize the token.
|
||||
@returns A new instance of a character token.
|
||||
@return A new instance of a character token.
|
||||
*/
|
||||
- (instancetype)initWithString:(NSString *)string;
|
||||
|
||||
@@ -42,14 +42,14 @@
|
||||
@discussion HTML whitespace characters are: CHARACTER TABULATION U+0009, LINE FEED U+000A, FORM FEED U+000C,
|
||||
CARRIAGE RETURN U+000D, and SPACE U+0020
|
||||
|
||||
@returns `YES` if this token contains only whitespace characters, `NO` otherwise.
|
||||
@return `YES` if this token contains only whitespace characters, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)isWhitespaceToken;
|
||||
|
||||
/**
|
||||
Checks whether this token is empty.
|
||||
|
||||
@returns `YES` if this token is empty, `NO` otherwise.
|
||||
@return `YES` if this token is empty, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)isEmpty;
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
Splits this token retaining only characters after the leading whitespace. The leading whitespace characters are then
|
||||
returned a new characters token.
|
||||
|
||||
@returns A characters token with leading whitespace characters. Returns 'nil` if no leading whitespace exists.
|
||||
@return A characters token with leading whitespace characters. Returns 'nil` if no leading whitespace exists.
|
||||
*/
|
||||
- (HTMLCharacterToken *)tokenBySplitingLeadingWhiteSpace;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes a new HTML comment node.
|
||||
|
||||
@param data The comment string.
|
||||
@returns A new isntance of a HTML comment node.
|
||||
@return A new isntance of a HTML comment node.
|
||||
*/
|
||||
- (instancetype)initWithData:(NSString *)data;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
Initializes a new comment token.
|
||||
|
||||
@param string The string with which to initialize the token.
|
||||
@returns A new instance of a comment token.
|
||||
@return A new instance of a comment token.
|
||||
*/
|
||||
- (instancetype)initWithData:(NSString *)data;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
Initializes a new DOCTYPE token.
|
||||
|
||||
@param name The name with which to initialize the token.
|
||||
@returns A new instance of a DOCTYPE token.
|
||||
@return A new instance of a DOCTYPE token.
|
||||
*/
|
||||
- (instancetype)initWithName:(NSString *)name;
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@param element The associated context element.
|
||||
@param attribute The associated attribute.
|
||||
@param value The initial attribute's value.
|
||||
@returns A new instance of the DOM token list.
|
||||
@return A new instance of the DOM token list.
|
||||
*/
|
||||
- (instancetype)initWithElement:(HTMLElement *)element attribute:(NSString *)attribute value:(NSString *)value;
|
||||
|
||||
/**
|
||||
@returns The length of this token list
|
||||
@return The length of this token list
|
||||
*/
|
||||
- (NSUInteger)length;
|
||||
|
||||
@@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Checks whether this list contains the given token.
|
||||
|
||||
@param token The token.
|
||||
@returns `YES` if the given token is in this list, `NO` otherwise.
|
||||
@return `YES` if the given token is in this list, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)contains:(NSString *)token;
|
||||
|
||||
@@ -68,7 +68,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Toggles the given token.
|
||||
|
||||
@param token The token to toggle.
|
||||
@returns `YES` if the token was added to the list, `NO` if it was removed from it.
|
||||
@return `YES` if the token was added to the list, `NO` if it was removed from it.
|
||||
*/
|
||||
- (BOOL)toggle:(NSString *)token;
|
||||
|
||||
@@ -84,7 +84,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Returns the value of the token at the given index.
|
||||
|
||||
@param index The index at which to return the token.
|
||||
@returns The token at the given index. If index is greater than or equal to the value returned by count, an
|
||||
@return The token at the given index. If index is greater than or equal to the value returned by count, an
|
||||
NSRangeException is raised.
|
||||
*/
|
||||
- (NSString *)objectAtIndexedSubscript:(NSUInteger)index;
|
||||
@@ -99,7 +99,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)setObject:(NSString *)obj atIndexedSubscript:(NSUInteger)index;
|
||||
|
||||
/**
|
||||
@returns The string representation of this token list, which can be used as the attribute's value.
|
||||
@return The string representation of this token list, which can be used as the attribute's value.
|
||||
*/
|
||||
- (NSString *)stringify;
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ typedef NS_ENUM(short, HTMLDocumentReadyState)
|
||||
exception if node is an instance of HTMLDocument.
|
||||
|
||||
@param node The node to adopt.
|
||||
@returns The adopted node
|
||||
@return The adopted node
|
||||
*/
|
||||
- (HTMLNode *)adoptNode:(HTMLNode *)node;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes a new document fragment with the given document as owner.
|
||||
|
||||
@param document The owner document.
|
||||
@returns A new instance of a document fragment.
|
||||
@return A new instance of a document fragment.
|
||||
*/
|
||||
- (instancetype)initWithDocument:(nullable HTMLDocument *)document;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@param name The name.
|
||||
@param publicIdentifier The public identifier.
|
||||
@param systemIdentifier The system identigier
|
||||
@returns A new document type instance.
|
||||
@return A new document type instance.
|
||||
*/
|
||||
- (instancetype)initWithName:(NSString *)name
|
||||
publicIdentifier:(nullable NSString *)publicIdentifier
|
||||
@@ -46,14 +46,14 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/**
|
||||
Checks whether this DOCTYPE is valid.
|
||||
|
||||
@returns `YES` if this is a valid DOCTYPE, `NO` otherwise.
|
||||
@return `YES` if this is a valid DOCTYPE, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)isValid;
|
||||
|
||||
/**
|
||||
Return the quirks mode of this DOCTYPE.
|
||||
|
||||
@returns The quirks mode.
|
||||
@return The quirks mode.
|
||||
|
||||
@see HTMLQuirksMode
|
||||
*/
|
||||
|
||||
@@ -64,7 +64,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes a new HTML element with the given tag name.
|
||||
|
||||
@param tagname The tag name.
|
||||
@returns A new HTML element.
|
||||
@return A new HTML element.
|
||||
*/
|
||||
- (instancetype)initWithTagName:(NSString *)tagName;
|
||||
|
||||
@@ -73,7 +73,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@param tagname The tag name.
|
||||
@param attributes The attributes.
|
||||
@returns A new HTML element.
|
||||
@return A new HTML element.
|
||||
*/
|
||||
- (instancetype)initWithTagName:(NSString *)tagName attributes:(NSDictionary *)attributes;
|
||||
|
||||
@@ -83,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@param tagname The tag name.
|
||||
@param namespace The namespace.
|
||||
@param attributes The attributes.
|
||||
@returns A new HTML element.
|
||||
@return A new HTML element.
|
||||
*/
|
||||
- (instancetype)initWithTagName:(NSString *)tagName namespace:(HTMLNamespace)htmlNamespace attributes:(NSDictionary *)attributes;
|
||||
|
||||
@@ -91,7 +91,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Checks whether this element has an attribute with the given name.
|
||||
|
||||
@param name The attribute name.
|
||||
@returns `YES` if the element has such an attributes, `NO` otherwise.
|
||||
@return `YES` if the element has such an attributes, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)hasAttribute:(NSString *)name;
|
||||
|
||||
@@ -99,7 +99,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Returns the value of the attribute with the given name.
|
||||
|
||||
@param name The attribute's name.
|
||||
@returns The attribute's value, `nil` if the element doesn't have such attribute.
|
||||
@return The attribute's value, `nil` if the element doesn't have such attribute.
|
||||
*/
|
||||
- (nullable NSString *)objectForKeyedSubscript:(NSString *)name;
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ NS_INLINE BOOL IsSpecialElement(HTMLElement *element)
|
||||
@"dir", @"div", @"dl", @"dt", @"embed", @"fieldset", @"figcaption",
|
||||
@"figure", @"footer", @"form", @"frame", @"frameset", @"h1", @"h2", @"h3",
|
||||
@"h4", @"h5", @"h6", @"head", @"header", @"hgroup", @"hr", @"html", @"iframe",
|
||||
@"img", @"input", @"isindex", @"li", @"link", @"listing", @"main", @"marquee",
|
||||
@"menu", @"menuitem", @"meta", @"nav", @"noembed", @"noframes", @"noscript",
|
||||
@"img", @"input", @"li", @"link", @"listing", @"main", @"marquee",
|
||||
@"menu", @"meta", @"nav", @"noembed", @"noframes", @"noscript",
|
||||
@"object", @"ol", @"p", @"param", @"plaintext", @"pre", @"script", @"section",
|
||||
@"select", @"source", @"style", @"summary", @"table", @"tbody", @"td",
|
||||
@"template", @"textarea", @"tfoot", @"th", @"thead", @"title", @"tr",
|
||||
|
||||
@@ -38,21 +38,21 @@ typedef void (^ HTMLStreamReaderErrorCallback)(NSString *reason);
|
||||
Initializes a new Input Stream Reader with the given string.
|
||||
|
||||
@param string The HTML string
|
||||
@returns A new instance of the Input Stream Reader.
|
||||
@return A new instance of the Input Stream Reader.
|
||||
*/
|
||||
- (id)initWithString:(NSString *)string;
|
||||
|
||||
/**
|
||||
Returns the current input character.
|
||||
|
||||
@returns The current code point in the input stream as a `UTF32Char`.
|
||||
@return The current code point in the input stream as a `UTF32Char`.
|
||||
*/
|
||||
- (UTF32Char)currentInputCharacter;
|
||||
|
||||
/**
|
||||
Returns the next input character without consuming it.
|
||||
|
||||
@returns The next code point in the input stream as a `UTF32Char`. Returns `EOF` if the stream is fully consumed.
|
||||
@return The next code point in the input stream as a `UTF32Char`. Returns `EOF` if the stream is fully consumed.
|
||||
*/
|
||||
- (UTF32Char)nextInputCharacter;
|
||||
|
||||
@@ -60,7 +60,7 @@ typedef void (^ HTMLStreamReaderErrorCallback)(NSString *reason);
|
||||
Returns the input character at a given offset without consuming it.
|
||||
|
||||
@param offset The offset of the character.
|
||||
@returns The code point in the input stream as a `UTF32Char` at the given offset.
|
||||
@return The code point in the input stream as a `UTF32Char` at the given offset.
|
||||
*/
|
||||
- (UTF32Char)inputCharacterPointAtOffset:(NSUInteger)offset;
|
||||
|
||||
@@ -68,7 +68,7 @@ typedef void (^ HTMLStreamReaderErrorCallback)(NSString *reason);
|
||||
Consumes and returns the next input character. Consuming a characters advances the current scan location of the
|
||||
input stream.
|
||||
|
||||
@returns The next code point in the input stream as a `UTF32Char`. Returns `EOF` if the stream is fully consumed.
|
||||
@return The next code point in the input stream as a `UTF32Char`. Returns `EOF` if the stream is fully consumed.
|
||||
*/
|
||||
- (UTF32Char)consumeNextInputCharacter;
|
||||
|
||||
@@ -84,7 +84,7 @@ typedef void (^ HTMLStreamReaderErrorCallback)(NSString *reason);
|
||||
Consumes the given character at the current location.
|
||||
|
||||
@param character The character to consume.
|
||||
@returns YES if the given character was consumed at the current location, NO otherwise.
|
||||
@return YES if the given character was consumed at the current location, NO otherwise.
|
||||
*/
|
||||
- (BOOL)consumeCharacter:(UTF32Char)character;
|
||||
|
||||
@@ -93,7 +93,7 @@ typedef void (^ HTMLStreamReaderErrorCallback)(NSString *reason);
|
||||
|
||||
@param result Upon return, contains the consumed unsigned number. Pass `NULL` to skip over an unsigned number at the
|
||||
current location.
|
||||
@returns YES if an unsigned number could be consumed at the current location, NO otherwise.
|
||||
@return YES if an unsigned number could be consumed at the current location, NO otherwise.
|
||||
*/
|
||||
- (BOOL)consumeNumber:(unsigned long long *)result;
|
||||
|
||||
@@ -102,7 +102,7 @@ typedef void (^ HTMLStreamReaderErrorCallback)(NSString *reason);
|
||||
|
||||
@param result Upon return, contains the consumed decimal number. Pass `NULL` to skip over a decimal number at the
|
||||
current location.
|
||||
@returns YES if a decimal number could be consumed at the current location, NO otherwise.
|
||||
@return YES if a decimal number could be consumed at the current location, NO otherwise.
|
||||
*/
|
||||
- (BOOL)consumeDecimalNumber:(NSDecimal *)result;
|
||||
|
||||
@@ -111,7 +111,7 @@ typedef void (^ HTMLStreamReaderErrorCallback)(NSString *reason);
|
||||
|
||||
@param result Upon return, contains the consumed hexadecimal number. Pass `NULL` to skip over a hexadecimal number at
|
||||
the current location.
|
||||
@returns YES if a hexadecimal number could be consumed at the current location, NO otherwise.
|
||||
@return YES if a hexadecimal number could be consumed at the current location, NO otherwise.
|
||||
*/
|
||||
- (BOOL)consumeHexNumber:(unsigned long long *)result;
|
||||
|
||||
@@ -120,7 +120,7 @@ typedef void (^ HTMLStreamReaderErrorCallback)(NSString *reason);
|
||||
|
||||
@param string The string to consume.
|
||||
@param caseSensitive YES if the string's case should be ignored, NO otherwise
|
||||
@returns YES if the given string was consumed at the current location, NO otherwise.
|
||||
@return YES if the given string was consumed at the current location, NO otherwise.
|
||||
*/
|
||||
- (BOOL)consumeString:(NSString *)string caseSensitive:(BOOL)caseSensitive;
|
||||
|
||||
@@ -128,7 +128,7 @@ typedef void (^ HTMLStreamReaderErrorCallback)(NSString *reason);
|
||||
Consumes characters starting at the current location until any character in a given string is encountered.
|
||||
|
||||
@param characters The string containing the characters to consume up to.
|
||||
@returns A string containing the consumed characters. Returns `nil` if none were consumed.
|
||||
@return A string containing the consumed characters. Returns `nil` if none were consumed.
|
||||
*/
|
||||
- (NSString *)consumeCharactersUpToCharactersInString:(NSString *)characters;
|
||||
|
||||
@@ -136,7 +136,7 @@ typedef void (^ HTMLStreamReaderErrorCallback)(NSString *reason);
|
||||
Consumes characters starting at the current location until a given string is encountered.
|
||||
|
||||
@param string The string to consume up to.
|
||||
@returns A string containing the consumed characters. Returns `nil` if none were consumed.
|
||||
@return A string containing the consumed characters. Returns `nil` if none were consumed.
|
||||
*/
|
||||
- (NSString *)consumeCharactersUpToString:(NSString *)string;
|
||||
|
||||
@@ -144,14 +144,14 @@ typedef void (^ HTMLStreamReaderErrorCallback)(NSString *reason);
|
||||
Consumes characters as long as the match the characters in the given string starting at the current location.
|
||||
|
||||
@param characters A string with the characters to consume.
|
||||
@returns A string containing the consumed characters. Returns `nil` if none were found.
|
||||
@return A string containing the consumed characters. Returns `nil` if none were found.
|
||||
*/
|
||||
- (NSString *)consumeCharactersInString:(NSString *)characters;
|
||||
|
||||
/**
|
||||
Consumes alphanumeric characters starting at the current location.
|
||||
|
||||
@returns A string containing the consumed alphanumeric characters. Returns `nil` if none were found.
|
||||
@return A string containing the consumed alphanumeric characters. Returns `nil` if none were found.
|
||||
*/
|
||||
- (NSString *)consumeAlphanumericCharacters;
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
return LINE_FEED;
|
||||
}
|
||||
if (CFStringIsSurrogateLowCharacter(nextInputCharacter)) {
|
||||
NSString *reason = [NSString stringWithFormat:@"Non-Unicode character found (an isolated low surrogate: 0x%X)", nextInputCharacter];
|
||||
NSString *reason = [NSString stringWithFormat:@"Non-Unicode character found (an isolated low surrogate: 0x%X)", (unsigned int)nextInputCharacter];
|
||||
[self emitParseError:reason];
|
||||
return nextInputCharacter;
|
||||
}
|
||||
@@ -90,7 +90,7 @@
|
||||
if (CFStringIsSurrogateHighCharacter(nextInputCharacter)) {
|
||||
UniChar surrogateLow = CFStringGetCharacterFromInlineBuffer(&_buffer, _location + 1);
|
||||
if (CFStringIsSurrogateLowCharacter(surrogateLow) == NO) {
|
||||
NSString *reason = [NSString stringWithFormat:@"Non-Unicode character found (an isolated high surrogate: 0x%X)", nextInputCharacter];
|
||||
NSString *reason = [NSString stringWithFormat:@"Non-Unicode character found (an isolated high surrogate: 0x%X)", (unsigned int)nextInputCharacter];
|
||||
[self emitParseError:reason];
|
||||
return nextInputCharacter;
|
||||
}
|
||||
@@ -100,7 +100,7 @@
|
||||
}
|
||||
|
||||
if (isControlOrUndefinedCharacter(nextInputCharacter)) {
|
||||
NSString *reason = [NSString stringWithFormat:@"A control/undefined character found: (0x%X)", nextInputCharacter];
|
||||
NSString *reason = [NSString stringWithFormat:@"A control/undefined character found: (0x%X)", (unsigned int)nextInputCharacter];
|
||||
[self emitParseError:reason];
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.braincookie.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
@@ -17,7 +17,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<string>0.9.3</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -22,3 +22,6 @@ extern const unsigned char HTMLKitVersionString[];
|
||||
#import "CSSSelectors.h"
|
||||
#import "CSSSelectorParser.h"
|
||||
#import "CSSNthExpressionParser.h"
|
||||
|
||||
#import "NSString+HTMLKit.h"
|
||||
#import "NSCharacterSet+HTMLKit.h"
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
Returns the index of the given node in the list.
|
||||
|
||||
@param node The node.
|
||||
@returns The index of the given node in the list.
|
||||
@return The index of the given node in the list.
|
||||
*/
|
||||
- (NSUInteger)indexOfElement:(id)node;
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
Checks whether the given element is in the list.
|
||||
|
||||
@param element The element to check.
|
||||
@returns `YES` if element is in the list, `NO` otherwise.
|
||||
@return `YES` if element is in the list, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)containsElement:(id)element;
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
/**
|
||||
Returns the last element in this list.
|
||||
|
||||
@returns The last entry.
|
||||
@return The last entry.
|
||||
*/
|
||||
- (id)lastEntry;
|
||||
|
||||
@@ -104,35 +104,35 @@
|
||||
in the list, if any, or the start of the list otherwise.
|
||||
|
||||
@param tagName The tag name.
|
||||
@returns The formatting element.
|
||||
@return The formatting element.
|
||||
*/
|
||||
- (HTMLElement *)formattingElementWithTagName:(NSString *)tagName;
|
||||
|
||||
/**
|
||||
Returns the count of elements in this list.
|
||||
|
||||
@returns The elements count.
|
||||
@return The elements count.
|
||||
*/
|
||||
- (NSUInteger)count;
|
||||
|
||||
/**
|
||||
Checks whether this list is empty.
|
||||
|
||||
@returns `YES` if the stack is empty, `NO` otherwise.
|
||||
@return `YES` if the stack is empty, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)isEmpty;
|
||||
|
||||
/**
|
||||
Return an object enumerator over this list.
|
||||
|
||||
@returns An enumerator
|
||||
@return An enumerator
|
||||
*/
|
||||
- (NSEnumerator *)enumerator;
|
||||
|
||||
/**
|
||||
Return an object enumerator over this list.
|
||||
|
||||
@returns An enumerator
|
||||
@return An enumerator
|
||||
*/
|
||||
- (NSEnumerator *)reverseObjectEnumerator;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
@param name The node's name.
|
||||
@param type The node's type.
|
||||
@returns A new instance of a HTML Node.
|
||||
@return A new instance of a HTML Node.
|
||||
*/
|
||||
- (instancetype)initWithName:(NSString *)name type:(HTMLNodeType)type NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
|
||||
+22
-22
@@ -145,7 +145,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
/**
|
||||
Checks whether this node has child nodes.
|
||||
|
||||
@returns `YES` if this node has any children, `NO` otherwise.
|
||||
@return `YES` if this node has any children, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)hasChildNodes;
|
||||
|
||||
@@ -153,14 +153,14 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
Checks whether this node has child nodes of the given type.
|
||||
|
||||
@param type The type to check.
|
||||
@returns `YES` if this node has any children of the given type, `NO` otherwise.
|
||||
@return `YES` if this node has any children of the given type, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)hasChildNodeOfType:(HTMLNodeType)type;
|
||||
|
||||
/**
|
||||
Returns the cound of child nodes.
|
||||
|
||||
@returns The child nodes count.
|
||||
@return The child nodes count.
|
||||
*/
|
||||
- (NSUInteger)childNodesCount;
|
||||
|
||||
@@ -168,7 +168,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
Returns the child node at a given index.
|
||||
|
||||
@param index The index at which to return the child node.
|
||||
@returns The child node at a index. If index is greater than or equal to the value returned by count, an
|
||||
@return The child node at a index. If index is greater than or equal to the value returned by count, an
|
||||
NSRangeException is raised.
|
||||
*/
|
||||
- (HTMLNode *)childNodeAtIndex:(NSUInteger)index;
|
||||
@@ -177,7 +177,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
Returns the index of the given child node in the set of child nodes.
|
||||
|
||||
@param node The node.
|
||||
@returns The index of the given node in the children set.
|
||||
@return The index of the given node in the children set.
|
||||
*/
|
||||
- (NSUInteger)indexOfChildNode:(HTMLNode *)node;
|
||||
|
||||
@@ -186,7 +186,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
|
||||
@discussion This method count only nodes of type HTMLNodeElement.
|
||||
|
||||
@returns The child elements count.
|
||||
@return The child elements count.
|
||||
*/
|
||||
- (NSUInteger)childElementsCount;
|
||||
|
||||
@@ -194,7 +194,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
Returns the child element at a given index.
|
||||
|
||||
@param index The index at which to return the child element.
|
||||
@returns The child element at a index. If index is greater than or equal to the value returned by count, an
|
||||
@return The child element at a index. If index is greater than or equal to the value returned by count, an
|
||||
NSRangeException is raised.
|
||||
*/
|
||||
- (HTMLElement *)childElementAtIndex:(NSUInteger)index;
|
||||
@@ -203,7 +203,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
Returns the index of the given child element in the set of child nodes.
|
||||
|
||||
@param node The element.
|
||||
@returns The index of the given element in the children set.
|
||||
@return The index of the given element in the children set.
|
||||
*/
|
||||
- (NSUInteger)indexOfChildElement:(HTMLElement *)element;
|
||||
|
||||
@@ -211,7 +211,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
Prepends the given node to the set of child nodes.
|
||||
|
||||
@param node The node to prepend.
|
||||
@returns The node being prepended.
|
||||
@return The node being prepended.
|
||||
*/
|
||||
- (HTMLNode *)prependNode:(HTMLNode *)node;
|
||||
|
||||
@@ -226,7 +226,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
Appends the given node to the set of child nodes.
|
||||
|
||||
@param node The node to append.
|
||||
@returns The node being appended.
|
||||
@return The node being appended.
|
||||
*/
|
||||
- (HTMLNode *)appendNode:(HTMLNode *)node;
|
||||
|
||||
@@ -243,7 +243,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
@param node The node to insert.
|
||||
@param child A reference child node before which the new node should be inserted. If child is `nil` then the new node
|
||||
will be inserted as the last child node.
|
||||
@returns The node being inserted.
|
||||
@return The node being inserted.
|
||||
*/
|
||||
- (HTMLNode *)insertNode:(HTMLNode *)node beforeChildNode:(nullable HTMLNode *)child;
|
||||
|
||||
@@ -252,7 +252,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
|
||||
@param child The child node to replace.
|
||||
@param replacement The replacement node.
|
||||
@returns The replacement node.
|
||||
@return The replacement node.
|
||||
*/
|
||||
- (HTMLNode *)replaceChildNode:(HTMLNode *)child withNode:(HTMLNode *)replacement;
|
||||
|
||||
@@ -303,7 +303,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
Compares the position of this node with the given node in the document.
|
||||
|
||||
@param node The node with which to comapre the position.
|
||||
@returns The HTMLDocumentPosition of this node in relation to the given node.
|
||||
@return The HTMLDocumentPosition of this node in relation to the given node.
|
||||
|
||||
@see HTMLDocumentPosition
|
||||
*/
|
||||
@@ -313,7 +313,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
Checks whether this node is descendant of the given node.
|
||||
|
||||
@param node The node to check.
|
||||
@returns `YES` if this node is descendant of the gicen node, `NO` otherwsie.
|
||||
@return `YES` if this node is descendant of the gicen node, `NO` otherwsie.
|
||||
*/
|
||||
- (BOOL)isDescendantOfNode:(HTMLNode *)node;
|
||||
|
||||
@@ -321,7 +321,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
Checks whether this node contains the given node.
|
||||
|
||||
@param node The node to check.
|
||||
@returns `YES` if this node contains the given node, `NO` otherwsie.
|
||||
@return `YES` if this node contains the given node, `NO` otherwsie.
|
||||
*/
|
||||
- (BOOL)containsNode:(HTMLNode *)node;
|
||||
|
||||
@@ -344,7 +344,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
/**
|
||||
Returns a node iterator rooted at this node whith no filter and HTMLNodeFilterShowAll.
|
||||
|
||||
@returns A new node iterator whose root is this node.
|
||||
@return A new node iterator whose root is this node.
|
||||
|
||||
@see HTMLNodeIterator
|
||||
@see HTMLNodeFilterShowOptions
|
||||
@@ -356,7 +356,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
|
||||
@param showOptions The iterator's show options.
|
||||
@param filter The iterator's filter.
|
||||
@returns A new node iterator whose root is this node.
|
||||
@return A new node iterator whose root is this node.
|
||||
|
||||
@see HTMLNodeIterator
|
||||
@see HTMLNodeFilterShowOptions
|
||||
@@ -369,7 +369,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
|
||||
@param showOptions The iterator's show options.
|
||||
@param filter The iterator's filter block.
|
||||
@returns A new node iterator whose root is this node.
|
||||
@return A new node iterator whose root is this node.
|
||||
|
||||
@see HTMLNodeIterator
|
||||
@see HTMLNodeFilterShowOptions
|
||||
@@ -381,7 +381,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
Returns the first element in the DOM tree rooted at this node, that is matched by the given selector string.
|
||||
|
||||
@param selector The CSS seletor string.
|
||||
@returns The first element that is matched by the parsed selector. Rerturns `nil` if the selector could not be parsed
|
||||
@return The first element that is matched by the parsed selector. Rerturns `nil` if the selector could not be parsed
|
||||
or no element was matched.
|
||||
|
||||
@see firstElementMatchingSelector:
|
||||
@@ -393,7 +393,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
Returns all elements in the DOM tree rooted at this node, that are matched by the given selector string.
|
||||
|
||||
@param selector The CSS seletor string.
|
||||
@returns The elements that are matched by the parsed selector. Rerturns an empty array if the selector could not be parsed
|
||||
@return The elements that are matched by the parsed selector. Rerturns an empty array if the selector could not be parsed
|
||||
or no elements were matched.
|
||||
|
||||
@see elementsMatchingSelector:
|
||||
@@ -405,7 +405,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
Returns the first element in the DOM tree rooted at this node, that is matched by the given selector.
|
||||
|
||||
@param selector The CSS seletor.
|
||||
@returns The first element that is matched by the parsed selector. Rerturns `nil` if no element was matched.
|
||||
@return The first element that is matched by the parsed selector. Rerturns `nil` if no element was matched.
|
||||
|
||||
@see CSSSelector
|
||||
*/
|
||||
@@ -415,7 +415,7 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
|
||||
Returns all elements in the DOM tree rooted at this node, that are matched by the given selector.
|
||||
|
||||
@param selector The CSS seletor.
|
||||
@returns The elements that are matched by the parsed selector. Rerturns an empty array if no elements were matched.
|
||||
@return The elements that are matched by the parsed selector. Rerturns an empty array if no elements were matched.
|
||||
|
||||
@see CSSSelector
|
||||
*/
|
||||
|
||||
@@ -55,7 +55,7 @@ typedef NS_OPTIONS(unsigned long, HTMLNodeFilterShowOptions)
|
||||
The implementation should return a HTMLNodeFilterValue to indicate accepting, skipping or rejecting a node.
|
||||
|
||||
@param node The node to be filtered.
|
||||
@returns `HTMLNodeFilterAccept` if accepted, `HTMLNodeFilterSkip` if skipped, or `HTMLNodeFilterReject` if rejected.
|
||||
@return `HTMLNodeFilterAccept` if accepted, `HTMLNodeFilterSkip` if skipped, or `HTMLNodeFilterReject` if rejected.
|
||||
*/
|
||||
- (HTMLNodeFilterValue)acceptNode:(HTMLNode *)node;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes a new node iterator with no filter and HTMLNodeFilterShowAll show options.
|
||||
|
||||
@param node The root node.
|
||||
@returns A new instance of a node iterator.
|
||||
@return A new instance of a node iterator.
|
||||
*/
|
||||
- (instancetype)initWithNode:(HTMLNode *)node;
|
||||
|
||||
@@ -63,7 +63,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@param node The root node.
|
||||
@param filter The node filter to use.
|
||||
@returns A new instance of a node iterator.
|
||||
@return A new instance of a node iterator.
|
||||
*/
|
||||
- (instancetype)initWithNode:(HTMLNode *)node
|
||||
filter:(nullable id<HTMLNodeFilter>)filter;
|
||||
@@ -74,19 +74,19 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@param node The root node.
|
||||
@param showOptions The show options for the iterator.
|
||||
@param filter The node filter to use.
|
||||
@returns A new instance of a node iterator.
|
||||
@return A new instance of a node iterator.
|
||||
*/
|
||||
- (instancetype)initWithNode:(HTMLNode *)node
|
||||
showOptions:(HTMLNodeFilterShowOptions)showOptions
|
||||
filter:(nullable id<HTMLNodeFilter>)filter;
|
||||
|
||||
/**
|
||||
@returns The next iterated node in tree order, `nil` if there are no more nodes to iterate.
|
||||
@return The next iterated node in tree order, `nil` if there are no more nodes to iterate.
|
||||
*/
|
||||
- (nullable HTMLNode *)nextNode;
|
||||
|
||||
/**
|
||||
@returns The previous iterated node in tree order, `nil` if there are no more nodes to iterate.
|
||||
@return The previous iterated node in tree order, `nil` if there are no more nodes to iterate.
|
||||
*/
|
||||
- (nullable HTMLNode *)previousNode;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Returns the object at the specified index.
|
||||
|
||||
@param index An index within the bounds of the dictionary.
|
||||
@returns The object located at index.
|
||||
@return The object located at index.
|
||||
*/
|
||||
- (ObjectType)objectAtIndex:(NSUInteger)index;
|
||||
|
||||
@@ -60,7 +60,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Returns the index of the given key in the dictionary.
|
||||
|
||||
@param aKey The key.
|
||||
@returns The index of the given key in the dictionary.
|
||||
@return The index of the given key in the dictionary.
|
||||
*/
|
||||
- (NSUInteger)indexOfKey:(KeyType<NSCopying>)aKey;
|
||||
|
||||
@@ -81,7 +81,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)setObject:(ObjectType)obj atIndexedSubscript:(NSUInteger)index;
|
||||
|
||||
/**
|
||||
@returns A reverse key enumerator.
|
||||
@return A reverse key enumerator.
|
||||
*/
|
||||
- (NSEnumerator<KeyType> *)reverseKeyEnumerator;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
@param reason The error's reason message.
|
||||
@param location The error's location in the stream.
|
||||
@returns A new instance of a parse error token.
|
||||
@return A new instance of a parse error token.
|
||||
*/
|
||||
- (instancetype)initWithReasonMessage:(NSString *)reason andStreamLocation:(NSUInteger)location;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%@: %p Reason='%@' Location='%lu'>", self.class, self, _reason, _location];
|
||||
return [NSString stringWithFormat:@"<%@: %p Reason='%@' Location='%lu'>", self.class, self, _reason, (unsigned long)_location];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -41,14 +41,14 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
https://html.spec.whatwg.org/multipage/syntax.html#determining-the-character-encoding
|
||||
|
||||
@param string The HTML string to parse
|
||||
@returns A new instance of the HTML parser.
|
||||
@return A new instance of the HTML parser.
|
||||
*/
|
||||
- (instancetype)initWithString:(NSString *)string;
|
||||
|
||||
/**
|
||||
Runs the parsing algorithm and generates a valid HTML document object.
|
||||
|
||||
@returns A HTML document object that is the result of parsing the HTML string, with which this parser instance was
|
||||
@return A HTML document object that is the result of parsing the HTML string, with which this parser instance was
|
||||
initialized
|
||||
|
||||
@see HTMLDocument
|
||||
@@ -63,7 +63,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
instance. In this case the parser will reset its internal state and re-run the parsing algorithm.
|
||||
|
||||
@param contextElement A context element used for parsing a HTML fragment
|
||||
@returns An array of HTML elements, that are the result of parsing the given HTML string with the given context element.
|
||||
@return An array of HTML elements, that are the result of parsing the given HTML string with the given context element.
|
||||
|
||||
@see HTMLElement
|
||||
*/
|
||||
|
||||
+39
-59
@@ -519,7 +519,7 @@
|
||||
|
||||
- (void)generateImpliedEndTagsExceptForElement:(NSString *)tagName
|
||||
{
|
||||
while ([self.currentNode.tagName isEqualToAny:@"dd", @"dt", @"li", @"option", @"optgroup", @"p", @"rb", @"rp", @"rt", @"rtc", nil] &&
|
||||
while ([self.currentNode.tagName isEqualToAny:@"dd", @"dt", @"li", @"menuitem", @"option", @"optgroup", @"p", @"rb", @"rp", @"rt", @"rtc", nil] &&
|
||||
![self.currentNode.tagName isEqualToString:tagName]) {
|
||||
[_stackOfOpenElements popCurrentNode];
|
||||
}
|
||||
@@ -588,20 +588,29 @@
|
||||
HTMLElement *lastNode = furthestBlock;
|
||||
|
||||
NSUInteger index = [_stackOfOpenElements indexOfElement:node];
|
||||
for (int innerLoopCounter = 0; innerLoopCounter < 3; innerLoopCounter ++) {
|
||||
|
||||
index--;
|
||||
int innerLoopCounter = 0;
|
||||
while (YES) {
|
||||
|
||||
innerLoopCounter += 1;
|
||||
index -= 1;
|
||||
|
||||
node = _stackOfOpenElements[index];
|
||||
|
||||
if ([node isEqual:formattingElement]) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (innerLoopCounter > 3 && [_listOfActiveFormattingElements containsElement:node]) {
|
||||
[_listOfActiveFormattingElements removeElement:node];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (![_listOfActiveFormattingElements containsElement:node]) {
|
||||
[_stackOfOpenElements removeElement:node];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ([node isEqual:formattingElement]) {
|
||||
break;
|
||||
}
|
||||
|
||||
HTMLElement *newElement = [node copy];
|
||||
[_listOfActiveFormattingElements replaceElementAtIndex:[_listOfActiveFormattingElements indexOfElement:node]
|
||||
withElement:newElement];
|
||||
@@ -1158,8 +1167,8 @@
|
||||
[self HTMLInsertionModeInTemplate:token];
|
||||
} else {
|
||||
for (HTMLElement *node in _stackOfOpenElements) {
|
||||
if ([node.tagName isEqualToAny:@"dd", @"dt", @"li", @"optgroup", @"option", @"p", @"rb", @"rp",
|
||||
@"rt", @"rtc", @"tbody", @"td", @"tfoot", @"th", @"thead", @"tr", @"body", @"html", nil]) {
|
||||
if ([node.tagName isEqualToAny:@"dd", @"dt", @"li", @"menuitem", @"optgroup", @"option", @"p", @"rb",
|
||||
@"rp", @"rt", @"rtc", @"tbody", @"td", @"tfoot", @"th", @"thead", @"tr", @"body", @"html", nil]) {
|
||||
[self emitParseError:@"EOF reached with unclosed element <%@> in <body>", node.tagName];
|
||||
break;
|
||||
}
|
||||
@@ -1222,12 +1231,20 @@
|
||||
[self switchInsertionMode:HTMLInsertionModeInFrameset];
|
||||
} else if ([tagName isEqualToAny:@"address", @"article", @"aside", @"blockquote", @"center",
|
||||
@"details", @"dialog", @"dir", @"div", @"dl", @"fieldset", @"figcaption", @"figure",
|
||||
@"footer", @"header", @"hgroup", @"main", @"menu", @"nav", @"ol", @"p", @"section",
|
||||
@"footer", @"header", @"hgroup", @"main", @"nav", @"ol", @"p", @"section",
|
||||
@"summary", @"ul", nil]) {
|
||||
if ([_stackOfOpenElements hasElementInButtonScopeWithTagName:@"p"]) {
|
||||
[self closePElement];
|
||||
}
|
||||
[self insertElementForToken:token];
|
||||
} else if ([tagName isEqualToString:@"menu"]) {
|
||||
if ([_stackOfOpenElements hasElementInButtonScopeWithTagName:@"p"]) {
|
||||
[self closePElement];
|
||||
}
|
||||
if ([self.currentNode.tagName isEqualToString:@"menuitem"]) {
|
||||
[_stackOfOpenElements popCurrentNode];
|
||||
}
|
||||
[self insertElementForToken:token];
|
||||
} else if ([tagName isEqualToAny:@"h1", @"h2", @"h3", @"h4", @"h5", @"h6", nil]) {
|
||||
if ([_stackOfOpenElements hasElementInButtonScopeWithTagName:@"p"]) {
|
||||
[self closePElement];
|
||||
@@ -1364,13 +1381,16 @@
|
||||
if (type == nil || ![type isEqualToStringIgnoringCase:@"hidden"]) {
|
||||
_framesetOkFlag = NO;
|
||||
}
|
||||
} else if ([tagName isEqualToAny:@"menuitem", @"param", @"source", @"track", nil]) {
|
||||
} else if ([tagName isEqualToAny:@"param", @"source", @"track", nil]) {
|
||||
[self insertElementForToken:token];
|
||||
[_stackOfOpenElements popCurrentNode];
|
||||
} else if ([tagName isEqualToString:@"hr"]) {
|
||||
if ([_stackOfOpenElements hasElementInButtonScopeWithTagName:@"p"]) {
|
||||
[self closePElement];
|
||||
}
|
||||
if ([self.currentNode.tagName isEqualToString:@"menuitem"]) {
|
||||
[_stackOfOpenElements popCurrentNode];
|
||||
}
|
||||
[self insertElementForToken:token];
|
||||
[_stackOfOpenElements popCurrentNode];
|
||||
_framesetOkFlag = NO;
|
||||
@@ -1378,52 +1398,6 @@
|
||||
[self emitParseError:@"Image Start Tag Token with tagname <image> should be <img>. Don't ask."];
|
||||
token.tagName = @"img";
|
||||
[self reprocessToken:token];
|
||||
} else if ([tagName isEqualToString:@"isindex"]) {
|
||||
[self emitParseError:@"Unexpected start tag <isindex> in <body>"];
|
||||
if (_formElementPointer != nil && ![_stackOfOpenElements containsElementWithTagName:@"template"]) {
|
||||
return;
|
||||
}
|
||||
_framesetOkFlag = NO;
|
||||
if ([_stackOfOpenElements hasElementInButtonScopeWithTagName:@"p"]) {
|
||||
[self closePElement];
|
||||
}
|
||||
|
||||
HTMLStartTagToken *formToken = [[HTMLStartTagToken alloc] initWithTagName:@"form"];
|
||||
HTMLElement *form = [self insertElementForToken:formToken];
|
||||
if (![_stackOfOpenElements containsElementWithTagName:@"template"]) {
|
||||
_formElementPointer = form;
|
||||
}
|
||||
NSString *action = token.attributes[@"action"];
|
||||
if (action != nil) {
|
||||
form.attributes[@"action"] = action;
|
||||
}
|
||||
|
||||
HTMLStartTagToken *hrToken = [[HTMLStartTagToken alloc] initWithTagName:@"hr"];
|
||||
[self insertElementForToken:hrToken];
|
||||
|
||||
[_stackOfOpenElements popCurrentNode];
|
||||
[self reconstructActiveFormattingElements];
|
||||
|
||||
HTMLStartTagToken *labelToken = [[HTMLStartTagToken alloc] initWithTagName:@"label"];
|
||||
[self insertElementForToken:labelToken];
|
||||
|
||||
NSString *prompt = token.attributes[@"prompt"] ?: @"This is a searchable index. Enter search keywords: ";
|
||||
[self insertCharacters:prompt];
|
||||
|
||||
NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithDictionary:token.attributes];
|
||||
attributes[@"name"] = @"isindex";
|
||||
[attributes removeObjectForKey:@"action"];
|
||||
[attributes removeObjectForKey:@"prompt"];
|
||||
|
||||
HTMLStartTagToken *inputToken = [[HTMLStartTagToken alloc] initWithTagName:@"input" attributes:attributes];
|
||||
[self insertElementForToken:inputToken];
|
||||
[_stackOfOpenElements popCurrentNode];
|
||||
|
||||
[_stackOfOpenElements popCurrentNode];
|
||||
[self insertElementForToken:hrToken];
|
||||
[_stackOfOpenElements popCurrentNode];
|
||||
[_stackOfOpenElements popCurrentNode];
|
||||
_formElementPointer = nil;
|
||||
} else if ([tagName isEqualToString:@"textarea"]) {
|
||||
[self insertElementForToken:token];
|
||||
_ignoreNextLineFeedCharacterToken = YES;
|
||||
@@ -1462,6 +1436,12 @@
|
||||
}
|
||||
[self reconstructActiveFormattingElements];
|
||||
[self insertElementForToken:token];
|
||||
} else if ([tagName isEqualToString:@"menuitem"]) {
|
||||
if ([self.currentNode.tagName isEqualToString:@"menuitem"]) {
|
||||
[_stackOfOpenElements popCurrentNode];
|
||||
}
|
||||
[self reconstructActiveFormattingElements];
|
||||
[self insertElementForToken:token];
|
||||
} else if ([tagName isEqualToAny:@"rb", @"rtc", nil]) {
|
||||
if ([_stackOfOpenElements hasElementInScopeWithTagName:@"ruby"]) {
|
||||
[self generateImpliedEndTagsExceptForElement:nil];
|
||||
@@ -1516,8 +1496,8 @@
|
||||
[self emitParseError:@"Unexpected end tag </body> without body element in scope in <body>"];
|
||||
}
|
||||
for (HTMLElement *node in _stackOfOpenElements) {
|
||||
if ([node.tagName isEqualToAny:@"dd", @"dt", @"li", @"optgroup", @"option", @"p", @"rb", @"rp", @"rt",
|
||||
@"rtc", @"tbody", @"td", @"tfoot", @"th", @"thead", @"tr", @"body", @"html", nil]) {
|
||||
if ([node.tagName isEqualToAny:@"dd", @"dt", @"li", @"menuitem", @"optgroup", @"option", @"p", @"rb", @"rp",
|
||||
@"rt", @"rtc", @"tbody", @"td", @"tfoot", @"th", @"thead", @"tr", @"body", @"html", nil]) {
|
||||
[self emitParseError:@"Misnested end tag </%@> with open element <%@> in <body>", tagName, node.tagName];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
Returns the index of the given node in the stack.
|
||||
|
||||
@param node The node.
|
||||
@returns The index of the given node in the stack.
|
||||
@return The index of the given node in the stack.
|
||||
*/
|
||||
- (NSUInteger)indexOfElement:(id)node;
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
Checks whether the given element is in the stack.
|
||||
|
||||
@param element The element.
|
||||
@returns `YES` if the element is in the stack, `NO` otherwise.
|
||||
@return `YES` if the element is in the stack, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)containsElement:(id)element;
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
Checks whether an element with the given tag name is in the stack.
|
||||
|
||||
@param tagname The element's tag name.
|
||||
@returns `YES` if such an element is in the stack, `NO` otherwise.
|
||||
@return `YES` if such an element is in the stack, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)containsElementWithTagName:(NSString *)tagName;
|
||||
|
||||
@@ -178,35 +178,35 @@
|
||||
https://html.spec.whatwg.org/multipage/syntax.html#adoption-agency-algorithm
|
||||
|
||||
@param index The index.
|
||||
@returns The furthest block after index.
|
||||
@return The furthest block after index.
|
||||
*/
|
||||
- (HTMLElement *)furthestBlockAfterIndex:(NSUInteger)index;
|
||||
|
||||
/**
|
||||
Returns the count of elements in this stack.
|
||||
|
||||
@returns The elements count.
|
||||
@return The elements count.
|
||||
*/
|
||||
- (NSUInteger)count;
|
||||
|
||||
/**
|
||||
Checks whether this stack is empty.
|
||||
|
||||
@returns `YES` if the stack is empty, `NO` otherwise.
|
||||
@return `YES` if the stack is empty, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)isEmpy;
|
||||
|
||||
/**
|
||||
Return an object enumerator over this stack.
|
||||
|
||||
@returns An enumerator
|
||||
@return An enumerator
|
||||
*/
|
||||
- (NSEnumerator *)enumerator;
|
||||
|
||||
/**
|
||||
Return a reverse object enumerator over this stack.
|
||||
|
||||
@returns A reverse enumerator
|
||||
@return A reverse enumerator
|
||||
*/
|
||||
- (NSEnumerator *)reverseObjectEnumerator;
|
||||
|
||||
|
||||
@@ -129,7 +129,11 @@
|
||||
|
||||
- (void)popElementsUntilElementPoppedWithTagName:(NSString *)tagName
|
||||
{
|
||||
while (self.currentNode && ![self.currentNode.tagName isEqualToString:tagName]) {
|
||||
while (self.currentNode) {
|
||||
if (self.currentNode.htmlNamespace == HTMLNamespaceHTML &&
|
||||
[self.currentNode.tagName isEqualToString:tagName]) {
|
||||
break;
|
||||
}
|
||||
[_stack removeLastObject];
|
||||
}
|
||||
[_stack removeLastObject];
|
||||
@@ -137,7 +141,11 @@
|
||||
|
||||
- (void)popElementsUntilAnElementPoppedWithAnyOfTagNames:(NSArray *)tagNames
|
||||
{
|
||||
while (self.currentNode && ![tagNames containsObject:self.currentNode.tagName]) {
|
||||
while (self.currentNode) {
|
||||
if (self.currentNode.htmlNamespace == HTMLNamespaceHTML &&
|
||||
[tagNames containsObject:self.currentNode.tagName]) {
|
||||
break;
|
||||
}
|
||||
[_stack removeLastObject];
|
||||
}
|
||||
[_stack removeLastObject];
|
||||
@@ -257,7 +265,10 @@
|
||||
{
|
||||
for (HTMLElement *node in _stack.reverseObjectEnumerator) {
|
||||
if ([tagNames containsObject:node.tagName]) {
|
||||
return node;
|
||||
NSNumber *namespace = elementTypes[node.tagName] ?: @(HTMLNamespaceHTML);
|
||||
if ([namespace isEqual:@(node.htmlNamespace)]) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
if ([elementTypes[node.tagName] isEqual:@(node.htmlNamespace)]) {
|
||||
return nil;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
Initializes a new tag token.
|
||||
|
||||
@param tagName The tag's name.
|
||||
@returns A new instance of a tag token.
|
||||
@return A new instance of a tag token.
|
||||
*/
|
||||
- (instancetype)initWithTagName:(NSString *)tagName;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
@param tagName The tag's name.
|
||||
@param attributes The tag's attributes.
|
||||
@returns A new instance of a tag token.
|
||||
@return A new instance of a tag token.
|
||||
*/
|
||||
- (instancetype)initWithTagName:(NSString *)tagName attributes:(NSMutableDictionary *)attributes;
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
Initializes a new HTML text node.
|
||||
|
||||
@param data The text string.
|
||||
@returns A new isntance of a HTML text node.
|
||||
@return A new isntance of a HTML text node.
|
||||
*/
|
||||
- (instancetype)initWithData:(NSString *)data;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
Initializes a new Tokenizer with the given string.
|
||||
|
||||
@param string The HTML string
|
||||
@returns A new instance of the Tokenizer.
|
||||
@return A new instance of the Tokenizer.
|
||||
*/
|
||||
- (instancetype)initWithString:(NSString *)string;
|
||||
|
||||
|
||||
@@ -452,7 +452,6 @@
|
||||
NSString *entityName = nil;
|
||||
NSString *entityReplacement = nil;
|
||||
|
||||
#warning Improve Named Entity Search
|
||||
UTF32Char inputCharacter = [_inputStreamReader consumeNextInputCharacter];
|
||||
NSArray *names = [HTMLTokenizerEntities entities];
|
||||
NSMutableString *name = [NSMutableString stringWithString:StringFromUTF32Char(inputCharacter)];
|
||||
@@ -671,7 +670,7 @@
|
||||
[_inputStreamReader reconsumeCurrentInputCharacter];
|
||||
break;
|
||||
default:
|
||||
[self emitParseError:@"Unexpected character (0x%X) in Tag Open state", character];
|
||||
[self emitParseError:@"Unexpected character (0x%X) in Tag Open state", (unsigned int)character];
|
||||
[self switchToState:HTMLTokenizerStateData];
|
||||
[self emitCharacterToken:LESS_THAN_SIGN];
|
||||
[_inputStreamReader reconsumeCurrentInputCharacter];
|
||||
@@ -702,7 +701,7 @@
|
||||
[_inputStreamReader reconsumeCurrentInputCharacter];
|
||||
break;
|
||||
default:
|
||||
[self emitParseError:@"Unexpected character (0x%X) in End Tag Open state", character];
|
||||
[self emitParseError:@"Unexpected character (0x%X) in End Tag Open state", (unsigned int)character];
|
||||
[self switchToState:HTMLTokenizerStateBogusComment];
|
||||
[_inputStreamReader reconsumeCurrentInputCharacter];
|
||||
break;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
Returns the replacement entity at the given index.
|
||||
|
||||
@param index The index of the character reference.
|
||||
@returns The replacement character reference entitiy.
|
||||
@return The replacement character reference entitiy.
|
||||
*/
|
||||
+ (NSString *)replacementAtIndex:(NSUInteger)index;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@param node The root node.
|
||||
@param filter The node filter to use.
|
||||
@returns A new instance of a tree walker.
|
||||
@return A new instance of a tree walker.
|
||||
*/
|
||||
- (instancetype)initWithNode:(HTMLNode *)node;
|
||||
|
||||
@@ -59,7 +59,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@param node The root node.
|
||||
@param filter The node filter to use.
|
||||
@returns A new instance of a tree walker.
|
||||
@return A new instance of a tree walker.
|
||||
*/
|
||||
- (instancetype)initWithNode:(HTMLNode *)node
|
||||
filter:(nullable id<HTMLNodeFilter>)filter;
|
||||
@@ -70,7 +70,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@param node The root node.
|
||||
@param showOptions The show options for the walker.
|
||||
@param filter The node filter to use.
|
||||
@returns A new instance of a tree walker.
|
||||
@return A new instance of a tree walker.
|
||||
*/
|
||||
- (instancetype)initWithNode:(HTMLNode *)node
|
||||
showOptions:(HTMLNodeFilterShowOptions)showOptions
|
||||
|
||||
@@ -18,33 +18,33 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/**
|
||||
Checks whether this string is equal to another ignoring the case.
|
||||
|
||||
@returns `YES` if the two string are equal ignroing the case, `NO` otherwise.
|
||||
@return `YES` if the two string are equal ignroing the case, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)isEqualToStringIgnoringCase:(NSString *)aString;
|
||||
|
||||
/**
|
||||
Checks whether this string is equal to any of the given strings.
|
||||
|
||||
@returns `YES` if there is an equal string, `NO` otherwise.
|
||||
@return `YES` if there is an equal string, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)isEqualToAny:(NSString *)first, ... NS_REQUIRES_NIL_TERMINATION;
|
||||
|
||||
/**
|
||||
Checks whether this string has a prefix ignoring the case.
|
||||
|
||||
@returns `YES` if this string has a given prefix ignroing the case, `NO` otherwise.
|
||||
@return `YES` if this string has a given prefix ignroing the case, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)hasPrefixIgnoringCase:(NSString *)aString;
|
||||
|
||||
/**
|
||||
Checks whether this string is a HTML whitespace string.
|
||||
|
||||
@returns `YES` if this string is a HTML whitespace string, `NO` otherwise.
|
||||
@return `YES` if this string is a HTML whitespace string, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)isHTMLWhitespaceString;
|
||||
|
||||
/**
|
||||
@returns The length of the leading HTML whitespace characters in this string.
|
||||
@return The length of the leading HTML whitespace characters in this string.
|
||||
*/
|
||||
- (NSUInteger)leadingHTMLWhitespaceLength;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
@interface HTML5LibTokenizerTest : NSObject
|
||||
|
||||
@property (nonatomic, copy) NSString *testName;
|
||||
@property (nonatomic, copy) NSString *testFile;
|
||||
@property (nonatomic, copy) NSString *title;
|
||||
@property (nonatomic, copy) NSString *input;
|
||||
@property (nonatomic, strong) NSArray *output;
|
||||
|
||||
@@ -39,7 +39,7 @@ static NSString * const TOKENIZER = @"tokenizer";
|
||||
|
||||
+ (NSArray *)loadTestsWithFileAtPath:(NSString *)filePath
|
||||
{
|
||||
NSString *testName = filePath.lastPathComponent.stringByDeletingLastPathComponent;
|
||||
NSString *testFile = filePath.lastPathComponent;
|
||||
|
||||
NSString *json = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
|
||||
NSData *data = [json dataUsingEncoding:NSUTF8StringEncoding];
|
||||
@@ -52,7 +52,7 @@ static NSString * const TOKENIZER = @"tokenizer";
|
||||
|
||||
for (NSDictionary *test in jsonTests) {
|
||||
HTML5LibTokenizerTest *html5libTest = [[HTML5LibTokenizerTest alloc] initWithTestDictionary:test];
|
||||
html5libTest.testName = testName;
|
||||
html5libTest.testFile = testFile;
|
||||
[tests addObject:html5libTest];
|
||||
}
|
||||
return tests;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// HTMLKitTestObserver.h
|
||||
// HTMLKit
|
||||
//
|
||||
// Created by Iska on 10/04/16.
|
||||
// Copyright © 2016 BrainCookie. All rights reserved.
|
||||
//
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
@interface HTMLKitTestReport : NSObject
|
||||
@property (assign, readonly) NSUInteger totalCount;
|
||||
@property (assign, readonly) NSUInteger failureCount;
|
||||
@property (copy, readonly) NSString *failureReport;
|
||||
@end
|
||||
|
||||
@interface HTMLKitTestObserver<TestCase: XCTestCase *> : NSObject <XCTestObservation>
|
||||
|
||||
- (instancetype)initWithName:(NSString *)name;
|
||||
|
||||
- (void)addCaseForHTML5LibTestWithInput:(NSString *)input;
|
||||
- (HTMLKitTestReport *)generateReport;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// HTMLKitTestObserver.m
|
||||
// HTMLKit
|
||||
//
|
||||
// Created by Iska on 10/04/16.
|
||||
// Copyright © 2016 BrainCookie. All rights reserved.
|
||||
//
|
||||
|
||||
#import "HTMLKitTestObserver.h"
|
||||
|
||||
#pragma mark - HTMLKitTestReport
|
||||
|
||||
@interface HTMLKitTestReport ()
|
||||
@property (assign) NSUInteger totalCount;
|
||||
@property (assign) NSUInteger failureCount;
|
||||
@property (copy) NSString *failureReport;
|
||||
@end
|
||||
|
||||
@implementation HTMLKitTestReport
|
||||
@synthesize totalCount, failureCount, failureReport;
|
||||
@end
|
||||
|
||||
#pragma mark - HTMLKitTestObserver
|
||||
|
||||
@interface HTMLKitTestObserver ()
|
||||
{
|
||||
NSString *_name;
|
||||
NSMutableArray *_cases;
|
||||
NSMutableDictionary *_currentCase;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation HTMLKitTestObserver
|
||||
|
||||
- (instancetype)initWithName:(NSString *)name
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_name = [name copy];
|
||||
_cases = [NSMutableArray new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)addCaseForHTML5LibTestWithInput:(NSString *)input
|
||||
{
|
||||
_currentCase = [NSMutableDictionary new];
|
||||
_currentCase[@"input"] = input;
|
||||
_currentCase[@"status"] = @"Passed";
|
||||
[_cases addObject:_currentCase];
|
||||
}
|
||||
|
||||
- (void)testCase:(XCTestCase *)testCase didFailWithDescription:(NSString *)description inFile:(NSString *)filePath atLine:(NSUInteger)lineNumber
|
||||
{
|
||||
_currentCase[@"status"] = @"Failed";
|
||||
}
|
||||
|
||||
- (HTMLKitTestReport *)generateReport
|
||||
{
|
||||
NSMutableString *reportDescription = [NSMutableString string];
|
||||
|
||||
NSIndexSet *failedIndexes = [_cases indexesOfObjectsPassingTest:^BOOL(NSDictionary *testCase, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
return [testCase[@"status"] isEqualToString:@"Failed"];
|
||||
}];
|
||||
|
||||
NSArray *failedTests = [_cases objectsAtIndexes:failedIndexes];
|
||||
|
||||
NSUInteger totalCount = _cases.count;
|
||||
NSUInteger failureCount = failedTests.count;
|
||||
|
||||
[reportDescription appendFormat:@"HTML5Lib test %@ failed [%lu] out of [%lu] total tests\n", _name, (unsigned long)failureCount, (unsigned long)_cases.count];
|
||||
|
||||
for (NSDictionary *testCase in failedTests) {
|
||||
[reportDescription appendFormat:@"Failed test for input: %@\n", testCase[@"input"]];
|
||||
}
|
||||
|
||||
HTMLKitTestReport *report = [HTMLKitTestReport new];
|
||||
report.totalCount = totalCount;
|
||||
report.failureCount = failureCount;
|
||||
report.failureReport = reportDescription;
|
||||
|
||||
return report;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// HTMLKitTestUtil.h
|
||||
// HTMLKit
|
||||
//
|
||||
// Created by Iska on 11/04/16.
|
||||
// Copyright © 2016 BrainCookie. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface HTMLKitTestUtil : NSObject
|
||||
|
||||
+ (NSInvocation *)addTestToClass:(Class)cls withName:(NSString *)name block:(id)block;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// HTMLKitTestUtil.m
|
||||
// HTMLKit
|
||||
//
|
||||
// Created by Iska on 11/04/16.
|
||||
// Copyright © 2016 BrainCookie. All rights reserved.
|
||||
//
|
||||
|
||||
#import "HTMLKitTestUtil.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@implementation HTMLKitTestUtil
|
||||
|
||||
+ (NSInvocation *)addTestToClass:(Class)cls withName:(NSString *)name block:(id)block
|
||||
{
|
||||
IMP implementation = imp_implementationWithBlock(block);
|
||||
const char *types = [[NSString stringWithFormat:@"%s%s%s", @encode(id), @encode(id), @encode(SEL)] UTF8String];
|
||||
|
||||
SEL selector = NSSelectorFromString(name);
|
||||
class_addMethod(cls, selector, implementation, types);
|
||||
|
||||
NSMethodSignature *signature = [cls instanceMethodSignatureForSelector:selector];
|
||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
|
||||
invocation.selector = selector;
|
||||
|
||||
return invocation;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -7,8 +7,10 @@
|
||||
//
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
#import "HTML5LibTokenizerTest.h"
|
||||
|
||||
#import "HTMLKitTestUtil.h"
|
||||
|
||||
#import "HTML5LibTokenizerTest.h"
|
||||
#import "HTMLTokenizer.h"
|
||||
#import "HTMLTokenizerStates.h"
|
||||
#import "HTMLTokens.h"
|
||||
@@ -30,7 +32,6 @@
|
||||
#pragma mark - HTML5Lib Test Suite
|
||||
|
||||
@interface HTMLKitTokenizerTests : XCTestCase
|
||||
@property (nonatomic, strong) NSString *testName;
|
||||
@property (nonatomic, strong) NSArray *testsList;
|
||||
@end
|
||||
|
||||
@@ -50,44 +51,31 @@
|
||||
|
||||
+ (void)addTestCaseForTestFile:(NSString *)testFile withTests:(NSArray *)tests toTestSuite:(XCTestSuite *)suite
|
||||
{
|
||||
NSArray *allInvocations = [self testInvocations];
|
||||
for (NSInvocation *invocation in allInvocations) {
|
||||
XCTestCase *testCase = [[self alloc] initWithInvocation:invocation
|
||||
testName:testFile
|
||||
tests:tests];
|
||||
[suite addTest:testCase];
|
||||
}
|
||||
NSString *testName = [testFile.stringByDeletingPathExtension stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
|
||||
testName = [NSString stringWithFormat:@"testTokenizer__%@", testName];
|
||||
|
||||
NSInvocation *invocation = [HTMLKitTestUtil addTestToClass:self withName:testName block:^ (HTMLKitTokenizerTests *instance){
|
||||
[instance runTests];
|
||||
}];
|
||||
|
||||
XCTestCase *testCase = [[self alloc] initWithInvocation:invocation tests:tests];
|
||||
[suite addTest:testCase];
|
||||
}
|
||||
|
||||
#pragma mark - Instance
|
||||
|
||||
- (instancetype)initWithInvocation:(NSInvocation *)invocation
|
||||
testName:(NSString *)testName
|
||||
tests:(NSArray *)tests
|
||||
- (instancetype)initWithInvocation:(NSInvocation *)invocation tests:(NSArray *)tests
|
||||
{
|
||||
self = [super initWithInvocation:invocation];
|
||||
if (self) {
|
||||
_testName = testName;
|
||||
_testsList = tests;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)name
|
||||
{
|
||||
NSInvocation *invocation = [self invocation];
|
||||
NSString *title = self.testName.stringByDeletingPathExtension;
|
||||
return [NSString stringWithFormat:@"-[%@ %@_%@]", self.class, NSStringFromSelector(invocation.selector), title];
|
||||
}
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
return self.name;
|
||||
}
|
||||
|
||||
#pragma mark - Tests
|
||||
|
||||
- (void)testTokenizer
|
||||
- (void)runTests
|
||||
{
|
||||
for (HTML5LibTokenizerTest *test in self.testsList) {
|
||||
|
||||
@@ -101,7 +89,7 @@
|
||||
NSArray *tokens = tokenizer.allObjects;
|
||||
|
||||
NSString *message = [NSString stringWithFormat:@"HTML5Lib test in file: \'%@\' Title: '%@'\nInput: '%@'\nExpected:\n%@\nActual:\n%@\n",
|
||||
self.testName,
|
||||
test.testFile,
|
||||
test.title,
|
||||
test.input,
|
||||
expectedTokens,
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "HTMLKitTestUtil.h"
|
||||
|
||||
#import "HTMLKitTestObserver.h"
|
||||
#import "HTML5LibTreeConstructionTest.h"
|
||||
#import "HTMLDOM.h"
|
||||
#import "HTMLParser.h"
|
||||
@@ -26,7 +29,9 @@
|
||||
#pragma mark - HTML5Lib Test Suite
|
||||
|
||||
@interface HTMLKitTreeConstructionTests : XCTestCase
|
||||
@property (nonatomic, strong) NSString *testName;
|
||||
{
|
||||
HTMLKitTestObserver<HTMLKitTreeConstructionTests *> *_observer;
|
||||
}
|
||||
@property (nonatomic, strong) NSArray *testsList;
|
||||
@end
|
||||
|
||||
@@ -45,50 +50,58 @@
|
||||
|
||||
+ (void)addTestCaseForTestFile:(NSString *)testFile withTests:(NSArray *)tests toTestSuite:(XCTestSuite *)suite
|
||||
{
|
||||
NSArray *allInvocations = [self testInvocations];
|
||||
for (NSInvocation *invocation in allInvocations) {
|
||||
XCTestCase *testCase = [[self alloc] initWithInvocation:invocation
|
||||
testName:testFile
|
||||
tests:tests];
|
||||
[suite addTest:testCase];
|
||||
}
|
||||
NSString *testName = [testFile.stringByDeletingPathExtension stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
|
||||
testName = [NSString stringWithFormat:@"testPareser__%@", testName];
|
||||
|
||||
NSInvocation *invocation = [HTMLKitTestUtil addTestToClass:self withName:testName block:^ (HTMLKitTreeConstructionTests *instance){
|
||||
[instance runTests];
|
||||
}];
|
||||
|
||||
XCTestCase *testCase = [[self alloc] initWithInvocation:invocation tests:tests];
|
||||
[suite addTest:testCase];
|
||||
}
|
||||
|
||||
#pragma mark - Instance
|
||||
|
||||
- (instancetype)initWithInvocation:(NSInvocation *)invocation
|
||||
testName:(NSString *)testName
|
||||
tests:(NSArray *)tests
|
||||
- (instancetype)initWithInvocation:(NSInvocation *)invocation tests:(NSArray *)tests
|
||||
{
|
||||
self = [super initWithInvocation:invocation];
|
||||
if (self) {
|
||||
_testName = testName;
|
||||
_testsList = tests;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)name
|
||||
#pragma mark - Setup
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
NSInvocation *invocation = [self invocation];
|
||||
NSString *title = self.testName.stringByDeletingPathExtension;
|
||||
return [NSString stringWithFormat:@"-[%@ %@_%@]", self.class, NSStringFromSelector(invocation.selector), title];
|
||||
_observer = [[HTMLKitTestObserver alloc] initWithName:self.name];
|
||||
[[XCTestObservationCenter sharedTestObservationCenter] addTestObserver:_observer];
|
||||
|
||||
[super setUp];
|
||||
}
|
||||
|
||||
- (NSString *)description
|
||||
- (void)tearDown
|
||||
{
|
||||
return self.name;
|
||||
HTMLKitTestReport *testReport = [_observer generateReport];
|
||||
XCTAssertTrue(testReport.failureCount == 0, @"%@", testReport.failureReport);
|
||||
|
||||
[[XCTestObservationCenter sharedTestObservationCenter] removeTestObserver:_observer];
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
#pragma mark - Tests
|
||||
|
||||
- (void)testParser
|
||||
- (void)runTests
|
||||
{
|
||||
for (HTML5LibTreeConstructionTest *test in self.testsList) {
|
||||
NSString *testInput = test.data;
|
||||
|
||||
[_observer addCaseForHTML5LibTestWithInput:testInput];
|
||||
|
||||
HTMLParser *parser = [[HTMLParser alloc] initWithString:testInput];
|
||||
HTMLElement *contextElement = test.documentFragment;
|
||||
|
||||
HTMLParser *parser = [[HTMLParser alloc] initWithString:test.data];
|
||||
|
||||
NSArray *actual = nil;
|
||||
if (contextElement == nil) {
|
||||
actual = [parser parseDocument].childNodes.array;
|
||||
|
||||
Submodule HTMLKitTests/html5lib-tests updated: 56c435f033...c305da74fa
@@ -1,8 +1,16 @@
|
||||
# HTMLKit
|
||||
|
||||

|
||||

|
||||
|
||||
An Objective-C framework for your everyday HTML needs.
|
||||
|
||||
[](https://travis-ci.org/iabudiab/HTMLKit)
|
||||
[](https://github.com/Carthage/Carthage)
|
||||
[](https://cocoapods.org/pods/HTMLKit)
|
||||
[](http://cocoadocs.org/docsets/HTMLKit)
|
||||
[](http://cocoadocs.org/docsets/HTMLKit)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
|
||||
# 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.
|
||||
@@ -15,14 +23,77 @@ DOM mutations are validated as described in the [WHATWG DOM Standard](https://do
|
||||
|
||||
## Tests
|
||||
|
||||
HTMLKit passes all of the [HTML5Lib](https://github.com/html5lib/html5lib-tests) Tokenizer and Tree Construction tests except the Blink changes introduced on 16.09.2015. The `html5lib-tests` is configured as a git-submodule. If you plan to run the tests, do not forget to pull it too.
|
||||
HTMLKit passes all of the [HTML5Lib](https://github.com/html5lib/html5lib-tests) Tokenizer and Tree Construction tests. The `html5lib-tests` is configured as a git-submodule. If you plan to run the tests, do not forget to pull it too.
|
||||
|
||||
The CSS3 Selector implementation is tested with the an adapted version of the [CSS3 Selectors Test Suite](http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/html/full/flat/index.html), ignoring the tests that require user interaction, session history, and scripting.
|
||||
The CSS3 Selector implementation is tested with an adapted version of the [CSS3 Selectors Test Suite](http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/html/full/flat/index.html), ignoring the tests that require user interaction, session history, and scripting.
|
||||
|
||||
## Does it Swift?
|
||||
|
||||
Check out the playground!
|
||||
|
||||
# Installation
|
||||
|
||||
### Carthage
|
||||
[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
|
||||
|
||||
If you don't have Carthage yet, you can install it with Homebrew using the following command:
|
||||
|
||||
```bash
|
||||
$ brew update
|
||||
$ brew install carthage
|
||||
```
|
||||
|
||||
To add `HTMLKit` as a dependency into your project using Carthage just add the following line in your `Cartfile`:
|
||||
|
||||
```
|
||||
github "iabudiab/HTMLKit"
|
||||
```
|
||||
|
||||
Then run the following command to build the framework and drag the built `HTMLKit.framework` into your Xcode project.
|
||||
|
||||
```bash
|
||||
$ carthage update
|
||||
```
|
||||
|
||||
### CocoaPods
|
||||
[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects.
|
||||
|
||||
If you don't have CocoaPods yet, you can install it with the following command:
|
||||
|
||||
```bash
|
||||
$ gem install cocoapods
|
||||
```
|
||||
|
||||
To add `HTMLKit` as a dependency into your project using CocoaPods just add the following in your `Podfile`:
|
||||
|
||||
```ruby
|
||||
use_frameworks!
|
||||
|
||||
target 'MyTarget' do
|
||||
pod 'HTMLKit', '~> 0.9'
|
||||
end
|
||||
```
|
||||
|
||||
Then, run the following command:
|
||||
|
||||
```bash
|
||||
$ pod install
|
||||
```
|
||||
|
||||
### Manually
|
||||
|
||||
1- Add `HTMLKit` as git submodule
|
||||
|
||||
```bash
|
||||
$ git submodule add https://github.com/iabudiab/HTMLKit.git
|
||||
```
|
||||
|
||||
2- Open the `HTMLKit` folder and drag'n'drop the `HTMLKit.xcodeproj` into the Project Navigator in Xcode to add it as a sub-project.
|
||||
|
||||
3- In the General panel of your target add `HTMLKit.framework` under the `Embedded Binaries`
|
||||
|
||||
# Features
|
||||
|
||||
# Parsing Documents
|
||||
|
||||
Given some HTML content, you can parse it either via the `HTMLParser` or instatiate a `HTMLDocument` directly:
|
||||
@@ -66,7 +137,7 @@ Here are some of the things you can do:
|
||||
* Create new elements and assign attributes
|
||||
|
||||
```objective-c
|
||||
HTMLElement *description = [[HTMLElement alloc] initWithTagName:@"body" attributes: @{@"name": @"description"}];
|
||||
HTMLElement *description = [[HTMLElement alloc] initWithTagName:@"meta" attributes: @{@"name": @"description"}];
|
||||
description[@"content"] = @"HTMLKit for iOS & OSX";
|
||||
```
|
||||
|
||||
@@ -177,7 +248,7 @@ NSArray *hasSiblingParagraph = [document elementsMatchingSelector:generalSibling
|
||||
NSArray *nonParagraphChildOfDiv = [document elementsMatchingSelector:
|
||||
allOf(@[
|
||||
childOfElementSelector(typeSelector(@"div")),
|
||||
nay(typeSelector(@"p"))
|
||||
not(typeSelector(@"p"))
|
||||
])
|
||||
];
|
||||
```
|
||||
@@ -187,17 +258,17 @@ Here are more examples:
|
||||
```objective-c
|
||||
HTMLNode *firstDivElement = [document firstElementMatchingSelector:typeSelector(@"div")];
|
||||
|
||||
var secondChildOfDiv = [firstDivElement querySelectorAll:@":nth-child(2)"];
|
||||
var secondOfType = [firstDivElement querySelectorAll:@":nth-of-type(2n)"];
|
||||
NSArray *secondChildOfDiv = [firstDivElement querySelectorAll:@":nth-child(2)"];
|
||||
NSArray *secondOfType = [firstDivElement querySelectorAll:@":nth-of-type(2n)"];
|
||||
|
||||
secondChildOfDiv = [firstDivElement elementsMatchingSelector:nthChildSelector(CSSNthExpressionMake(0, 2))];
|
||||
secondOfType = [firstDivElement elementsMatchingSelector:nthOfTypeSelector(CSSNthExpressionMake(2, 0))];
|
||||
|
||||
var notParagraphAndNotDiv = [firstDivElement querySelectorAll:@":not(p):not(div)"];
|
||||
NSArray *notParagraphAndNotDiv = [firstDivElement querySelectorAll:@":not(p):not(div)"];
|
||||
notParagraphAndNotDiv = [firstDivElement elementsMatchingSelector:
|
||||
allOf([
|
||||
nay(typeSelector(@"p")),
|
||||
nay(typeSelector(@"div"))
|
||||
not(typeSelector(@"p")),
|
||||
not(typeSelector(@"div"))
|
||||
])
|
||||
];
|
||||
```
|
||||
@@ -211,6 +282,10 @@ CSSSelector *myAwesomeSelector = namedBlockSelector(@"myAwesomeSelector", ^BOOL
|
||||
notParagraphAndNotDiv = [firstDivElement elementsMatchingSelector:myAwesomeSelector];
|
||||
```
|
||||
|
||||
# Change Log
|
||||
|
||||
See the [CHANGELOG.md](CHANGELOG.md) for more info.
|
||||
|
||||
# License
|
||||
|
||||
HTMLKit is available under the MIT license. See the LICENSE file for more info.
|
||||
HTMLKit is available under the MIT license. See the [LICENSE](LICENSE) file for more info.
|
||||
|
||||
Reference in New Issue
Block a user