├── .github ├── CONTRIBUTING.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .jazzy.yaml ├── .travis.yml ├── HTMLEntities-Carthage.xcodeproj ├── HTMLEntitiesTests_Info.plist ├── HTMLEntities_Info.plist ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ ├── HTMLEntities.xcscheme │ └── xcschememanagement.plist ├── HTMLEntities.podspec ├── Info.plist ├── LICENSE ├── Package.swift ├── README.md ├── Sources └── HTMLEntities │ ├── Constants.swift │ ├── ParseError.swift │ ├── String+HTMLEntities.swift │ └── Utilities.swift ├── Tests ├── HTMLEntitiesTests │ ├── HTMLEntitiesTests.swift │ └── LinuxSafeguardTest.swift └── LinuxMain.swift └── docs ├── Enums.html ├── Enums └── ParseError.html ├── Extensions.html ├── Extensions ├── String.html └── String │ └── HTMLEscapeOptions.html ├── css ├── highlight.css └── jazzy.css ├── docsets ├── HTMLEntities.docset │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ ├── Documents │ │ ├── Enums.html │ │ ├── Enums │ │ │ └── ParseError.html │ │ ├── Extensions.html │ │ ├── Extensions │ │ │ ├── String.html │ │ │ └── String │ │ │ │ └── HTMLEscapeOptions.html │ │ ├── css │ │ │ ├── highlight.css │ │ │ └── jazzy.css │ │ ├── img │ │ │ ├── carat.png │ │ │ ├── dash.png │ │ │ ├── gh.png │ │ │ └── spinner.gif │ │ ├── index.html │ │ ├── js │ │ │ ├── jazzy.js │ │ │ ├── jazzy.search.js │ │ │ ├── jquery.min.js │ │ │ ├── lunr.min.js │ │ │ └── typeahead.jquery.js │ │ └── search.json │ │ └── docSet.dsidx └── HTMLEntities.tgz ├── img ├── carat.png ├── dash.png ├── gh.png └── spinner.gif ├── index.html ├── js ├── jazzy.js ├── jazzy.search.js ├── jquery.min.js ├── lunr.min.js └── typeahead.jquery.js └── search.json /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to IBM-Swift 2 | 3 | We welcome contributions, and request you follow these guidelines. 4 | 5 | - [Raising issues](#raising-issues) 6 | - [Contributor License Agreement](#contributor-license-agreement) 7 | - [Coding Standards](#coding-standards) 8 | 9 | 10 | ## Raising issues 11 | 12 | Please raise any bug reports on the issue tracker. Be sure to 13 | search the list to see if your issue has already been raised. 14 | 15 | A good bug report is one that make it easy for us to understand what you were 16 | trying to do and what went wrong. Provide as much context as possible so we can try to recreate the issue. 17 | 18 | ### Contributor License Agreement 19 | 20 | In order for us to accept pull-requests, the contributor must first complete 21 | a Contributor License Agreement (CLA). Please see our [CLA repo](http://github.com/IBM-Swift/CLA) for more information. 22 | 23 | This clarifies the intellectual property license granted with any contribution. It is for your protection as a 24 | Contributor as well as the protection of IBM and its customers; it does not 25 | change your rights to use your own Contributions for any other purpose. 26 | 27 | ### Coding standards 28 | 29 | Please ensure you follow [the Kitura coding standards](https://github.com/IBM-Swift/Kitura/blob/master/Documentation/CodeConventions.md) 30 | 31 | Please note: 32 | 33 | - all files must have the Apache license in the header. 34 | - all PRs must have passing builds for all operating systems. 35 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Description 4 | 5 | 6 | ## Motivation and Context 7 | 8 | 9 | 10 | ## How Has This Been Tested? 11 | 12 | 13 | 14 | 15 | ## Checklist: 16 | 17 | 18 | - [ ] I have submitted a [CLA form](https://github.com/IBM-Swift/CLA) 19 | - [ ] If applicable, I have updated the documentation accordingly. 20 | - [ ] If applicable, I have added tests to cover my changes. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | *.xcodeproj/ 5 | !HTMLEntities-Carthage.xcodeproj/ 6 | 7 | ## Build generated 8 | build/ 9 | DerivedData/ 10 | 11 | ## Various settings 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata/ 21 | 22 | ## Other 23 | *.moved-aside 24 | *.xcuserstate 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | *.dSYM.zip 30 | *.dSYM 31 | 32 | ## Playgrounds 33 | timeline.xctimeline 34 | playground.xcworkspace 35 | 36 | # Swift Package Manager 37 | # 38 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 39 | # Packages/ 40 | .build/ 41 | 42 | # CocoaPods 43 | # 44 | # We recommend against adding the Pods directory to your .gitignore. However 45 | # you should judge for yourself, the pros and cons are mentioned at: 46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 47 | # 48 | # Pods/ 49 | 50 | # Carthage 51 | # 52 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 53 | # Carthage/Checkouts 54 | 55 | Carthage/Build 56 | 57 | # fastlane 58 | # 59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 60 | # screenshots whenever they are needed. 61 | # For more information about the recommended setup visit: 62 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 63 | 64 | fastlane/report.xml 65 | fastlane/Preview.html 66 | fastlane/screenshots 67 | fastlane/test_output 68 | -------------------------------------------------------------------------------- /.jazzy.yaml: -------------------------------------------------------------------------------- 1 | module: HTMLEntities 2 | author: IBM and the Kitura project authors 3 | github_url: https://github.com/Kitura/swift-html-entities 4 | 5 | theme: fullwidth 6 | clean: true 7 | exclude: [Packages] 8 | 9 | readme: README.md 10 | 11 | skip_undocumented: false 12 | hide_documentation_coverage: false 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Travis CI build file. 2 | 3 | # whitelist (branches that should be built) 4 | branches: 5 | only: 6 | - master 7 | - /^issue.*$/ 8 | 9 | # the matrix of builds should cover each combination of Swift version 10 | # and platform that is supported. The version of Swift used is specified 11 | # by .swift-version, unless SWIFT_SNAPSHOT is specified. 12 | matrix: 13 | include: 14 | - os: linux 15 | dist: xenial 16 | sudo: required 17 | services: docker 18 | env: DOCKER_IMAGE=docker.kitura.net/kitura/swift-ci-ubuntu18.04:5.2.5 19 | - os: linux 20 | dist: bionic 21 | sudo: required 22 | services: docker 23 | env: DOCKER_IMAGE=docker.kitura.net/kitura/swift-ci-ubuntu18.04:5.4 24 | - os: linux 25 | dist: xenial 26 | sudo: required 27 | services: docker 28 | env: DOCKER_IMAGE=docker.kitura.net/kitura/swift-ci-ubuntu18.04:latest USE_SWIFT_DEVELOPMENT_SNAPSHOT=1 29 | - os: osx 30 | osx_image: xcode12.2 31 | sudo: required 32 | env: JAZZY_ELIGIBLE=true 33 | - os: osx 34 | osx_image: xcode13.2 35 | sudo: required 36 | env: USE_SWIFT_DEVELOPMENT_SNAPSHOT=1 37 | 38 | 39 | before_install: 40 | - git clone https://github.com/Kitura/Package-Builder.git 41 | 42 | script: 43 | - ./Package-Builder/build-package.sh -projectDir $TRAVIS_BUILD_DIR 44 | -------------------------------------------------------------------------------- /HTMLEntities-Carthage.xcodeproj/HTMLEntitiesTests_Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CFBundleDevelopmentRegion 5 | en 6 | CFBundleExecutable 7 | $(EXECUTABLE_NAME) 8 | CFBundleIdentifier 9 | $(PRODUCT_BUNDLE_IDENTIFIER) 10 | CFBundleInfoDictionaryVersion 11 | 6.0 12 | CFBundleName 13 | $(PRODUCT_NAME) 14 | CFBundlePackageType 15 | BNDL 16 | CFBundleShortVersionString 17 | 1.0 18 | CFBundleSignature 19 | ???? 20 | CFBundleVersion 21 | $(CURRENT_PROJECT_VERSION) 22 | NSPrincipalClass 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /HTMLEntities-Carthage.xcodeproj/HTMLEntities_Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CFBundleDevelopmentRegion 5 | en 6 | CFBundleExecutable 7 | $(EXECUTABLE_NAME) 8 | CFBundleIdentifier 9 | $(PRODUCT_BUNDLE_IDENTIFIER) 10 | CFBundleInfoDictionaryVersion 11 | 6.0 12 | CFBundleName 13 | $(PRODUCT_NAME) 14 | CFBundlePackageType 15 | FMWK 16 | CFBundleShortVersionString 17 | 1.0 18 | CFBundleSignature 19 | ???? 20 | CFBundleVersion 21 | $(CURRENT_PROJECT_VERSION) 22 | NSPrincipalClass 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /HTMLEntities-Carthage.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | OBJ_26 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_9 /* Constants.swift */; }; 11 | OBJ_27 /* ParseError.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_10 /* ParseError.swift */; }; 12 | OBJ_28 /* String+HTMLEntities.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_11 /* String+HTMLEntities.swift */; }; 13 | OBJ_29 /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_12 /* Utilities.swift */; }; 14 | OBJ_36 /* HTMLEntitiesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_15 /* HTMLEntitiesTests.swift */; }; 15 | OBJ_37 /* LinuxSafeguardTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_16 /* LinuxSafeguardTest.swift */; }; 16 | OBJ_39 /* HTMLEntities.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = OBJ_19 /* HTMLEntities.framework */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | DFDE62571F59F33A00735E5F /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = OBJ_1 /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = OBJ_21; 25 | remoteInfo = HTMLEntities; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | D8835F911F69ABA100694AD9 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | OBJ_10 /* ParseError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParseError.swift; sourceTree = ""; }; 32 | OBJ_11 /* String+HTMLEntities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+HTMLEntities.swift"; sourceTree = ""; }; 33 | OBJ_12 /* Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utilities.swift; sourceTree = ""; }; 34 | OBJ_15 /* HTMLEntitiesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTMLEntitiesTests.swift; sourceTree = ""; }; 35 | OBJ_16 /* LinuxSafeguardTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinuxSafeguardTest.swift; sourceTree = ""; }; 36 | OBJ_17 /* docs */ = {isa = PBXFileReference; lastKnownFileType = folder; path = docs; sourceTree = SOURCE_ROOT; }; 37 | OBJ_19 /* HTMLEntities.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = HTMLEntities.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | OBJ_20 /* HTMLEntitiesTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; path = HTMLEntitiesTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | OBJ_6 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; 40 | OBJ_9 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | OBJ_30 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 0; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | OBJ_38 /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 0; 54 | files = ( 55 | OBJ_39 /* HTMLEntities.framework in Frameworks */, 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | /* End PBXFrameworksBuildPhase section */ 60 | 61 | /* Begin PBXGroup section */ 62 | D8835F921F69ABD800694AD9 /* Supporting Files */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | D8835F911F69ABA100694AD9 /* Info.plist */, 66 | ); 67 | name = "Supporting Files"; 68 | sourceTree = ""; 69 | }; 70 | OBJ_13 /* Tests */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | OBJ_14 /* HTMLEntitiesTests */, 74 | ); 75 | name = Tests; 76 | sourceTree = SOURCE_ROOT; 77 | }; 78 | OBJ_14 /* HTMLEntitiesTests */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | OBJ_15 /* HTMLEntitiesTests.swift */, 82 | OBJ_16 /* LinuxSafeguardTest.swift */, 83 | ); 84 | name = HTMLEntitiesTests; 85 | path = Tests/HTMLEntitiesTests; 86 | sourceTree = SOURCE_ROOT; 87 | }; 88 | OBJ_18 /* Products */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | OBJ_19 /* HTMLEntities.framework */, 92 | OBJ_20 /* HTMLEntitiesTests.xctest */, 93 | ); 94 | name = Products; 95 | sourceTree = BUILT_PRODUCTS_DIR; 96 | }; 97 | OBJ_5 = { 98 | isa = PBXGroup; 99 | children = ( 100 | OBJ_6 /* Package.swift */, 101 | OBJ_7 /* Sources */, 102 | OBJ_13 /* Tests */, 103 | D8835F921F69ABD800694AD9 /* Supporting Files */, 104 | OBJ_17 /* docs */, 105 | OBJ_18 /* Products */, 106 | ); 107 | sourceTree = ""; 108 | }; 109 | OBJ_7 /* Sources */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | OBJ_8 /* HTMLEntities */, 113 | ); 114 | name = Sources; 115 | sourceTree = SOURCE_ROOT; 116 | }; 117 | OBJ_8 /* HTMLEntities */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | OBJ_9 /* Constants.swift */, 121 | OBJ_10 /* ParseError.swift */, 122 | OBJ_11 /* String+HTMLEntities.swift */, 123 | OBJ_12 /* Utilities.swift */, 124 | ); 125 | name = HTMLEntities; 126 | path = Sources/HTMLEntities; 127 | sourceTree = SOURCE_ROOT; 128 | }; 129 | /* End PBXGroup section */ 130 | 131 | /* Begin PBXNativeTarget section */ 132 | OBJ_21 /* HTMLEntities */ = { 133 | isa = PBXNativeTarget; 134 | buildConfigurationList = OBJ_22 /* Build configuration list for PBXNativeTarget "HTMLEntities" */; 135 | buildPhases = ( 136 | OBJ_25 /* Sources */, 137 | OBJ_30 /* Frameworks */, 138 | ); 139 | buildRules = ( 140 | ); 141 | dependencies = ( 142 | ); 143 | name = HTMLEntities; 144 | productName = HTMLEntities; 145 | productReference = OBJ_19 /* HTMLEntities.framework */; 146 | productType = "com.apple.product-type.framework"; 147 | }; 148 | OBJ_31 /* HTMLEntitiesTests */ = { 149 | isa = PBXNativeTarget; 150 | buildConfigurationList = OBJ_32 /* Build configuration list for PBXNativeTarget "HTMLEntitiesTests" */; 151 | buildPhases = ( 152 | OBJ_35 /* Sources */, 153 | OBJ_38 /* Frameworks */, 154 | ); 155 | buildRules = ( 156 | ); 157 | dependencies = ( 158 | OBJ_40 /* PBXTargetDependency */, 159 | ); 160 | name = HTMLEntitiesTests; 161 | productName = HTMLEntitiesTests; 162 | productReference = OBJ_20 /* HTMLEntitiesTests.xctest */; 163 | productType = "com.apple.product-type.bundle.unit-test"; 164 | }; 165 | /* End PBXNativeTarget section */ 166 | 167 | /* Begin PBXProject section */ 168 | OBJ_1 /* Project object */ = { 169 | isa = PBXProject; 170 | attributes = { 171 | LastUpgradeCheck = 9999; 172 | }; 173 | buildConfigurationList = OBJ_2 /* Build configuration list for PBXProject "HTMLEntities-Carthage" */; 174 | compatibilityVersion = "Xcode 3.2"; 175 | developmentRegion = English; 176 | hasScannedForEncodings = 0; 177 | knownRegions = ( 178 | en, 179 | ); 180 | mainGroup = OBJ_5; 181 | productRefGroup = OBJ_18 /* Products */; 182 | projectDirPath = ""; 183 | projectRoot = ""; 184 | targets = ( 185 | OBJ_21 /* HTMLEntities */, 186 | OBJ_31 /* HTMLEntitiesTests */, 187 | ); 188 | }; 189 | /* End PBXProject section */ 190 | 191 | /* Begin PBXSourcesBuildPhase section */ 192 | OBJ_25 /* Sources */ = { 193 | isa = PBXSourcesBuildPhase; 194 | buildActionMask = 0; 195 | files = ( 196 | OBJ_26 /* Constants.swift in Sources */, 197 | OBJ_27 /* ParseError.swift in Sources */, 198 | OBJ_28 /* String+HTMLEntities.swift in Sources */, 199 | OBJ_29 /* Utilities.swift in Sources */, 200 | ); 201 | runOnlyForDeploymentPostprocessing = 0; 202 | }; 203 | OBJ_35 /* Sources */ = { 204 | isa = PBXSourcesBuildPhase; 205 | buildActionMask = 0; 206 | files = ( 207 | OBJ_36 /* HTMLEntitiesTests.swift in Sources */, 208 | OBJ_37 /* LinuxSafeguardTest.swift in Sources */, 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | /* End PBXSourcesBuildPhase section */ 213 | 214 | /* Begin PBXTargetDependency section */ 215 | OBJ_40 /* PBXTargetDependency */ = { 216 | isa = PBXTargetDependency; 217 | target = OBJ_21 /* HTMLEntities */; 218 | targetProxy = DFDE62571F59F33A00735E5F /* PBXContainerItemProxy */; 219 | }; 220 | /* End PBXTargetDependency section */ 221 | 222 | /* Begin XCBuildConfiguration section */ 223 | OBJ_23 /* Debug */ = { 224 | isa = XCBuildConfiguration; 225 | buildSettings = { 226 | APPLICATION_EXTENSION_API_ONLY = YES; 227 | CURRENT_PROJECT_VERSION = 1; 228 | ENABLE_TESTABILITY = YES; 229 | FRAMEWORK_SEARCH_PATHS = ( 230 | "$(inherited)", 231 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 232 | ); 233 | HEADER_SEARCH_PATHS = "$(inherited)"; 234 | INFOPLIST_FILE = "${PROJECT_FILE_PATH}/HTMLEntities_Info.plist"; 235 | LD_RUNPATH_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; 236 | OTHER_LDFLAGS = "$(inherited)"; 237 | OTHER_SWIFT_FLAGS = "$(inherited)"; 238 | PRODUCT_BUNDLE_IDENTIFIER = HTMLEntities; 239 | PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; 240 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 241 | SKIP_INSTALL = YES; 242 | TARGET_NAME = HTMLEntities; 243 | }; 244 | name = Debug; 245 | }; 246 | OBJ_24 /* Release */ = { 247 | isa = XCBuildConfiguration; 248 | buildSettings = { 249 | APPLICATION_EXTENSION_API_ONLY = YES; 250 | CURRENT_PROJECT_VERSION = 1; 251 | ENABLE_TESTABILITY = YES; 252 | FRAMEWORK_SEARCH_PATHS = ( 253 | "$(inherited)", 254 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 255 | ); 256 | HEADER_SEARCH_PATHS = "$(inherited)"; 257 | INFOPLIST_FILE = "${PROJECT_FILE_PATH}/HTMLEntities_Info.plist"; 258 | LD_RUNPATH_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; 259 | OTHER_LDFLAGS = "$(inherited)"; 260 | OTHER_SWIFT_FLAGS = "$(inherited)"; 261 | PRODUCT_BUNDLE_IDENTIFIER = HTMLEntities; 262 | PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; 263 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 264 | SKIP_INSTALL = YES; 265 | TARGET_NAME = HTMLEntities; 266 | }; 267 | name = Release; 268 | }; 269 | OBJ_3 /* Debug */ = { 270 | isa = XCBuildConfiguration; 271 | buildSettings = { 272 | CLANG_ENABLE_OBJC_ARC = YES; 273 | COMBINE_HIDPI_IMAGES = YES; 274 | COPY_PHASE_STRIP = NO; 275 | CURRENT_PROJECT_VERSION = 1; 276 | DEBUG_INFORMATION_FORMAT = dwarf; 277 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 278 | ENABLE_NS_ASSERTIONS = YES; 279 | GCC_OPTIMIZATION_LEVEL = 0; 280 | INFOPLIST_FILE = Info.plist; 281 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 282 | MACOSX_DEPLOYMENT_TARGET = 10.9; 283 | ONLY_ACTIVE_ARCH = YES; 284 | OTHER_SWIFT_FLAGS = "-DXcode"; 285 | PRODUCT_NAME = "$(TARGET_NAME)"; 286 | SDKROOT = macosx; 287 | SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; 288 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = SWIFT_PACKAGE; 289 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 290 | SWIFT_VERSION = 4.2; 291 | TVOS_DEPLOYMENT_TARGET = 9.0; 292 | USE_HEADERMAP = NO; 293 | WATCHOS_DEPLOYMENT_TARGET = 2.0; 294 | }; 295 | name = Debug; 296 | }; 297 | OBJ_33 /* Debug */ = { 298 | isa = XCBuildConfiguration; 299 | buildSettings = { 300 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; 301 | FRAMEWORK_SEARCH_PATHS = ( 302 | "$(inherited)", 303 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 304 | ); 305 | HEADER_SEARCH_PATHS = "$(inherited)"; 306 | INFOPLIST_FILE = "${PROJECT_FILE_PATH}/HTMLEntitiesTests_Info.plist"; 307 | LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @loader_path/Frameworks"; 308 | OTHER_LDFLAGS = "$(inherited)"; 309 | OTHER_SWIFT_FLAGS = "$(inherited)"; 310 | TARGET_NAME = HTMLEntitiesTests; 311 | }; 312 | name = Debug; 313 | }; 314 | OBJ_34 /* Release */ = { 315 | isa = XCBuildConfiguration; 316 | buildSettings = { 317 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; 318 | FRAMEWORK_SEARCH_PATHS = ( 319 | "$(inherited)", 320 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 321 | ); 322 | HEADER_SEARCH_PATHS = "$(inherited)"; 323 | INFOPLIST_FILE = "${PROJECT_FILE_PATH}/HTMLEntitiesTests_Info.plist"; 324 | LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @loader_path/Frameworks"; 325 | OTHER_LDFLAGS = "$(inherited)"; 326 | OTHER_SWIFT_FLAGS = "$(inherited)"; 327 | TARGET_NAME = HTMLEntitiesTests; 328 | }; 329 | name = Release; 330 | }; 331 | OBJ_4 /* Release */ = { 332 | isa = XCBuildConfiguration; 333 | buildSettings = { 334 | CLANG_ENABLE_OBJC_ARC = YES; 335 | COMBINE_HIDPI_IMAGES = YES; 336 | COPY_PHASE_STRIP = YES; 337 | CURRENT_PROJECT_VERSION = 1; 338 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 339 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 340 | GCC_OPTIMIZATION_LEVEL = s; 341 | INFOPLIST_FILE = Info.plist; 342 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 343 | MACOSX_DEPLOYMENT_TARGET = 10.9; 344 | OTHER_SWIFT_FLAGS = "-DXcode"; 345 | PRODUCT_NAME = "$(TARGET_NAME)"; 346 | SDKROOT = macosx; 347 | SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; 348 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = SWIFT_PACKAGE; 349 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 350 | SWIFT_VERSION = 4.2; 351 | TVOS_DEPLOYMENT_TARGET = 9.0; 352 | USE_HEADERMAP = NO; 353 | WATCHOS_DEPLOYMENT_TARGET = 2.0; 354 | }; 355 | name = Release; 356 | }; 357 | /* End XCBuildConfiguration section */ 358 | 359 | /* Begin XCConfigurationList section */ 360 | OBJ_2 /* Build configuration list for PBXProject "HTMLEntities-Carthage" */ = { 361 | isa = XCConfigurationList; 362 | buildConfigurations = ( 363 | OBJ_3 /* Debug */, 364 | OBJ_4 /* Release */, 365 | ); 366 | defaultConfigurationIsVisible = 0; 367 | defaultConfigurationName = Debug; 368 | }; 369 | OBJ_22 /* Build configuration list for PBXNativeTarget "HTMLEntities" */ = { 370 | isa = XCConfigurationList; 371 | buildConfigurations = ( 372 | OBJ_23 /* Debug */, 373 | OBJ_24 /* Release */, 374 | ); 375 | defaultConfigurationIsVisible = 0; 376 | defaultConfigurationName = Debug; 377 | }; 378 | OBJ_32 /* Build configuration list for PBXNativeTarget "HTMLEntitiesTests" */ = { 379 | isa = XCConfigurationList; 380 | buildConfigurations = ( 381 | OBJ_33 /* Debug */, 382 | OBJ_34 /* Release */, 383 | ); 384 | defaultConfigurationIsVisible = 0; 385 | defaultConfigurationName = Debug; 386 | }; 387 | /* End XCConfigurationList section */ 388 | }; 389 | rootObject = OBJ_1 /* Project object */; 390 | } 391 | -------------------------------------------------------------------------------- /HTMLEntities-Carthage.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HTMLEntities-Carthage.xcodeproj/xcshareddata/xcschemes/HTMLEntities.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 55 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 74 | 76 | 77 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /HTMLEntities-Carthage.xcodeproj/xcshareddata/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SchemeUserState 5 | 6 | HTMLEntities.xcscheme 7 | 8 | 9 | SuppressBuildableAutocreation 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /HTMLEntities.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint HTMLEntities.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "HTMLEntities" 19 | s.version = "4.0.1" 20 | s.summary = "HTML5 spec-compliant character encoder/decoder for Swift" 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | s.description = <<-DESC 28 | Pure Swift HTML encode/decode utility tool for Swift 4 and Swift 5. 29 | 30 | Includes support for HTML5 named character references. You can find the list of all 2231 HTML5 named character references [here](https://www.w3.org/TR/html5/syntax.html#named-character-references). 31 | 32 | `HTMLEntities` can escape ALL non-ASCII characters as well as the characters `<`, `>`, `&`, `"`, `’`, as these five characters are part of the HTML tag and HTML attribute syntaxes. 33 | 34 | In addition, `HTMLEntities` can unescape encoded HTML text that contains decimal, hexadecimal, or HTML5 named character references. 35 | DESC 36 | 37 | s.homepage = "https://github.com/Kitura/swift-html-entities" 38 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 39 | 40 | 41 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 42 | # 43 | # Licensing your code is important. See http://choosealicense.com for more info. 44 | # CocoaPods will detect a license file if there is a named LICENSE* 45 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 46 | # 47 | 48 | s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" } 49 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } 50 | 51 | 52 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 53 | # 54 | # Specify the authors of the library, with email addresses. Email addresses 55 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 56 | # accepts just a name if you'd rather not provide an email address. 57 | # 58 | # Specify a social_media_url where others can refer to, for example a twitter 59 | # profile URL. 60 | # 61 | 62 | s.author = "Youming Lin" 63 | 64 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 65 | # 66 | # If this Pod runs only on iOS or OS X, then specify the platform and 67 | # the deployment target. You can optionally include the target after the platform. 68 | # 69 | 70 | # s.platform = :ios 71 | # s.platform = :ios, "5.0" 72 | 73 | # When using multiple platforms 74 | s.ios.deployment_target = "9.0" 75 | s.osx.deployment_target = "10.10" 76 | # s.watchos.deployment_target = "2.0" 77 | # s.tvos.deployment_target = "9.0" 78 | s.swift_version = "5.2" 79 | 80 | 81 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 82 | # 83 | # Specify the location from where the source should be retrieved. 84 | # Supports git, hg, bzr, svn and HTTP. 85 | # 86 | 87 | s.source = { :git => "https://github.com/Kitura/swift-html-entities.git", :tag => "#{s.version}" } 88 | 89 | 90 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 91 | # 92 | # CocoaPods is smart about how it includes source code. For source files 93 | # giving a folder will include any swift, h, m, mm, c & cpp files. 94 | # For header files it will include any header in the folder. 95 | # Not including the public_header_files will make all headers public. 96 | # 97 | 98 | s.source_files = "Sources/**/*.swift" 99 | # s.exclude_files = "Classes/Exclude" 100 | 101 | # s.public_header_files = "Classes/**/*.h" 102 | 103 | 104 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 105 | # 106 | # A list of resources included with the Pod. These are copied into the 107 | # target bundle with a build phase script. Anything else will be cleaned. 108 | # You can preserve files from being cleaned, please don't preserve 109 | # non-essential files like tests, examples and documentation. 110 | # 111 | 112 | # s.resource = "icon.png" 113 | # s.resources = "Resources/*.png" 114 | 115 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 116 | 117 | 118 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 119 | # 120 | # Link your library with frameworks, or libraries. Libraries do not include 121 | # the lib prefix of their name. 122 | # 123 | 124 | # s.framework = "SomeFramework" 125 | # s.frameworks = "SomeFramework", "AnotherFramework" 126 | 127 | # s.library = "iconv" 128 | # s.libraries = "iconv", "xml2" 129 | 130 | 131 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 132 | # 133 | # If your library depends on compiler flags you can set them in the xcconfig hash 134 | # where they will only apply to your library. If you depend on other Podspecs 135 | # you can include multiple dependencies to ensure it works. 136 | 137 | # s.requires_arc = true 138 | 139 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 140 | # s.dependency "JSONKit", "~> 1.4" 141 | 142 | end 143 | -------------------------------------------------------------------------------- /Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleVersion 6 | $(CURRENT_PROJECT_VERSION) 7 | 8 | 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.2 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | /** 5 | * Copyright IBM Corporation and the Kitura project authors 2016-2020 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | **/ 19 | 20 | import PackageDescription 21 | 22 | let package = Package( 23 | name: "HTMLEntities", 24 | products: [ 25 | // Products define the executables and libraries produced by a package, and make them visible to other packages. 26 | .library( 27 | name: "HTMLEntities", 28 | targets: ["HTMLEntities"] 29 | ) 30 | ], 31 | targets: [ 32 | // Targets are the basic building blocks of a package. A target can define a module or a test suite. 33 | // Targets can depend on other targets in this package, and on products in packages which this package depends on. 34 | .target( 35 | name: "HTMLEntities" 36 | ), 37 | .testTarget( 38 | name: "HTMLEntitiesTests", 39 | dependencies: ["HTMLEntities"] 40 | ) 41 | ] 42 | ) 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HTMLEntities 2 | 3 | [![Build Status - Master](https://api.travis-ci.org/Kitura/swift-html-entities.svg?branch=master)](https://travis-ci.org/Kitura/swift-html-entities) 4 | ![macOS](https://img.shields.io/badge/os-macOS-green.svg?style=flat) 5 | ![Linux](https://img.shields.io/badge/os-linux-green.svg?style=flat) 6 | ![Apache 2](https://img.shields.io/badge/license-Apache2-blue.svg?style=flat) 7 | [![codecov](https://codecov.io/gh/Kitura/swift-html-entities/branch/master/graph/badge.svg)](https://codecov.io/gh/Kitura/swift-html-entities) 8 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 9 | 10 | ## Summary 11 | Pure Swift HTML encode/decode utility tool for Swift. 12 | 13 | Includes support for HTML5 named character references. You can find the list of all 2231 HTML5 named character references [here](https://www.w3.org/TR/html5/syntax.html#named-character-references). 14 | 15 | `HTMLEntities` can escape ALL non-ASCII characters as well as the characters `<`, `>`, `&`, `"`, `’`, as these five characters are part of the HTML tag and HTML attribute syntaxes. 16 | 17 | In addition, `HTMLEntities` can unescape encoded HTML text that contains decimal, hexadecimal, or HTML5 named character references. 18 | 19 | ## API Documentation 20 | 21 | API documentation for `HTMLEntities` is located [here](https://kitura.github.io/swift-html-entities/). 22 | 23 | ## Features 24 | 25 | * Supports HTML5 named character references (`NegativeMediumSpace;` etc.) 26 | * HTML5 spec-compliant; strict parse mode recognizes [parse errors](https://www.w3.org/TR/html5/syntax.html#tokenizing-character-references) 27 | * Supports decimal and hexadecimal escapes for all characters 28 | * Simple to use as functions are added by way of extending the default `String` class 29 | * Minimal dependencies; implementation is completely self-contained 30 | 31 | ## Version Info 32 | 33 | Latest release of `HTMLEntities` requires Swift 4.0 and higher. 34 | 35 | ## Installation 36 | 37 | ### Via Swift Package Manager 38 | 39 | Add `HTMLEntities` to your `Package.swift`: 40 | 41 | ```swift 42 | import PackageDescription 43 | 44 | let package = Package( 45 | name: "", 46 | ... 47 | dependencies: [ 48 | .package(url: "https://github.com/Kitura/swift-html-entities.git", from: "3.0.0") 49 | ] 50 | // Also, make sure to add HTMLEntities to your package target's dependencies 51 | ) 52 | ``` 53 | 54 | ### Via CocoaPods 55 | 56 | Add `HTMLEntities` to your `Podfile`: 57 | 58 | ``` 59 | target '' do 60 | pod 'HTMLEntities', :git => 'https://github.com/Kitura/swift-html-entities.git' 61 | end 62 | ``` 63 | 64 | ### Via Carthage 65 | 66 | Add `HTMLEntities` to your `Cartfile`: 67 | 68 | ``` 69 | github "Kitura/swift-html-entities" 70 | ``` 71 | 72 | ## Usage 73 | 74 | ```swift 75 | import HTMLEntities 76 | 77 | // encode example 78 | let html = "" 79 | 80 | print(html.htmlEscape()) 81 | // Prints "<script>alert("abc")</script>" 82 | 83 | // decode example 84 | let htmlencoded = "<script>alert("abc")</script>" 85 | 86 | print(htmlencoded.htmlUnescape()) 87 | // Prints "" 88 | ``` 89 | 90 | ## Advanced Options 91 | 92 | `HTMLEntities` supports various options when escaping and unescaping HTML characters. 93 | 94 | ### Escape Options 95 | 96 | #### `allowUnsafeSymbols` 97 | 98 | Defaults to `false`. Specifies if unsafe ASCII characters should be skipped or not. 99 | 100 | ```swift 101 | import HTMLEntities 102 | 103 | let html = "

\"café\"

" 104 | 105 | print(html.htmlEscape()) 106 | // Prints "<p>"café"</p>" 107 | 108 | print(html.htmlEscape(allowUnsafeSymbols: true)) 109 | // Prints "

\"café\"

" 110 | 111 | ``` 112 | 113 | #### `decimal` 114 | 115 | Defaults to `false`. Specifies if decimal character escapes should be used instead of hexadecimal character escapes whenever numeric character escape is used (i.e., does not affect named character references escapes). The use of hexadecimal character escapes is recommended. 116 | 117 | ```swift 118 | import HTMLEntities 119 | 120 | let text = "한, 한, ế, ế, 🇺🇸" 121 | 122 | print(text.htmlEscape()) 123 | // Prints "한, 한, ế, ế, 🇺🇸" 124 | 125 | print(text.htmlEscape(decimal: true)) 126 | // Prints "한, 한, ế, ế, 🇺🇸" 127 | ``` 128 | 129 | #### `encodeEverything` 130 | 131 | Defaults to `false`. Specifies if all characters should be escaped, even if some characters are safe. If `true`, overrides the setting for `allowUnsafeSymbols`. 132 | 133 | ```swift 134 | import HTMLEntities 135 | 136 | let text = "A quick brown fox jumps over the lazy dog" 137 | 138 | print(text.htmlEscape()) 139 | // Prints "A quick brown fox jumps over the lazy dog" 140 | 141 | print(text.htmlEscape(encodeEverything: true)) 142 | // Prints "A quick brown fox jumps over the lazy dog" 143 | 144 | // `encodeEverything` overrides `allowUnsafeSymbols` 145 | print(text.htmlEscape(allowUnsafeSymbols: true, encodeEverything: true)) 146 | // Prints "A quick brown fox jumps over the lazy dog" 147 | ``` 148 | 149 | #### `useNamedReferences` 150 | 151 | Defaults to `false`. Specifies if named character references should be used whenever possible. Set to `false` to always use numeric character references, i.e., for compatibility with older browsers that do not recognize named character references. 152 | 153 | ```swift 154 | import HTMLEntities 155 | 156 | let html = "" 157 | 158 | print(html.htmlEscape()) 159 | // Prints “<script>alert("abc")</script>” 160 | 161 | print(html.htmlEscape(useNamedReferences: true)) 162 | // Prints “<script>alert("abc")</script>” 163 | ``` 164 | 165 | #### Set Escape Options Globally 166 | 167 | HTML escape options can be set globally so that you don't have to set them everytime you want to escape a string. The options are managed in the `String.HTMLEscapeOptions` struct. 168 | 169 | ```swift 170 | import HTMLEntities 171 | 172 | // set `useNamedReferences` to `true` globally 173 | String.HTMLEscapeOptions.useNamedReferences = true 174 | 175 | let html = "" 176 | 177 | // Now, the default behavior of `htmlEscape()` is to use named character references 178 | print(html.htmlEscape()) 179 | // Prints “<script>alert("abc")</script>” 180 | 181 | // And you can still go back to using numeric character references only 182 | print(html.htmlEscape(useNamedReferences: false)) 183 | // Prints "<script>alert("abc")</script>" 184 | ``` 185 | 186 | ### Unescape Options 187 | 188 | #### `strict` 189 | 190 | Defaults to `false`. Specifies if HTML5 parse errors should be thrown or simply passed over. 191 | 192 | **Note**: `htmlUnescape()` is a throwing function if `strict` is used in call argument (no matter if it is set to `true` or `false`); `htmlUnescape()` is NOT a throwing function if no argument is provided. 193 | 194 | ```swift 195 | import HTMLEntities 196 | 197 | let text = "한" 198 | 199 | print(text.htmlUnescape()) 200 | // Prints "한" 201 | 202 | print(try text.htmlUnescape(strict: true)) 203 | // Throws a `ParseError.MissingSemicolon` instance 204 | 205 | // a throwing function because `strict` is passed in argument 206 | // but no error is thrown because `strict: false` 207 | print(try text.htmlUnescape(strict: false)) 208 | // Prints "한" 209 | ``` 210 | 211 | ## Acknowledgments 212 | 213 | `HTMLEntities` was designed to support some of the same options as [`he`](https://github.com/mathiasbynens/he), a popular Javascript HTML encoder/decoder. 214 | 215 | ## License 216 | 217 | Apache 2.0 218 | -------------------------------------------------------------------------------- /Sources/HTMLEntities/ParseError.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright IBM Corporation 2016, 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// Enums used to delineate the different kinds of parse errors 18 | /// that may be encountered during HTML unescaping. See 19 | /// https://www.w3.org/TR/html5/syntax.html#tokenizing-character-references 20 | /// for an explanation of the different parse errors. 21 | public enum ParseError: Error { 22 | /// "If that number is one of the numbers in the first column of the following 23 | /// table, then this is a parse error." 24 | case DeprecatedNumericReference(String) 25 | 26 | /// "[I]f the number is in the range 0x0001 to 0x0008, 0x000D to 0x001F, 0x007F 27 | /// to 0x009F, 0xFDD0 to 0xFDEF, or is one of 0x000B, 0xFFFE, 0xFFFF, 0x1FFFE, 28 | /// 0x1FFFF, 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE, 29 | /// 0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF, 0x9FFFE, 30 | /// 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 0xCFFFE, 0xCFFFF, 0xDFFFE, 31 | /// 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF, 0x10FFFE, or 0x10FFFF, then 32 | /// this is a parse error." 33 | case DisallowedNumericReference(String) 34 | 35 | /// This should NEVER be hit in code execution. If this error is thrown, then 36 | /// decoder has faulty logic 37 | case IllegalArgument(String) 38 | 39 | /// "[I]f the characters after the U+0026 AMPERSAND character (&) consist of 40 | /// a sequence of one or more alphanumeric ASCII characters followed by a 41 | /// U+003B SEMICOLON character (;), then this is a parse error." 42 | case InvalidNamedReference(String) 43 | 44 | /// "If no characters match the range, then don't consume any characters 45 | /// (and unconsume the U+0023 NUMBER SIGN character and, if appropriate, 46 | /// the X character). This is a parse error; nothing is returned." 47 | case MalformedNumericReference(String) 48 | 49 | /// "[I]f the next character is a U+003B SEMICOLON, consume that too. 50 | /// If it isn't, there is a parse error." 51 | case MissingSemicolon(String) 52 | 53 | /// "[I]f the number is in the range 0xD800 to 0xDFFF or is greater 54 | /// than 0x10FFFF, then this is a parse error." 55 | case OutsideValidUnicodeRange(String) 56 | } 57 | -------------------------------------------------------------------------------- /Sources/HTMLEntities/Utilities.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright IBM Corporation 2016, 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | extension Dictionary { 18 | /// Union of two dictionaries 19 | /// Note: The in the argument will override 20 | /// the current dictionary's if the keys match 21 | func updating(_ dict: [Key: Value]) -> [Key: Value] { 22 | var newDict = self 23 | 24 | for (key, value) in dict { 25 | newDict[key] = value 26 | } 27 | 28 | return newDict 29 | } 30 | } 31 | 32 | extension Dictionary where Value: Hashable { 33 | /// Invert a dictionary: -> 34 | /// Note: Does not check for uniqueness among values 35 | func inverting(_ pick: (Key, Key) -> Key = { existingValue, newValue in 36 | return newValue 37 | }) -> [Value: Key] { 38 | var inverseDict: [Value: Key] = [:] 39 | 40 | for (key, value) in self { 41 | if let existing = inverseDict[value] { 42 | inverseDict[value] = pick(existing, key) 43 | } 44 | else { 45 | inverseDict[value] = key 46 | } 47 | } 48 | 49 | return inverseDict 50 | } 51 | } 52 | 53 | extension UInt32 { 54 | var isAlphaNumeric: Bool { 55 | // unicode values of [0-9], [A-Z], and [a-z] 56 | return self.isNumeral || 0x41...0x5A ~= self || 0x61...0x7A ~= self 57 | } 58 | 59 | var isAmpersand: Bool { 60 | // unicode value of & 61 | return self == 0x26 62 | } 63 | 64 | var isASCII: Bool { 65 | // Less than 0x80 66 | return self < 0x80 67 | } 68 | 69 | /// https://www.w3.org/International/questions/qa-escapes#use 70 | var isAttributeSyntax: Bool { 71 | // unicode values of [", '] 72 | return self == 0x22 || self == 0x27 73 | } 74 | 75 | var isDisallowedReference: Bool { 76 | // unicode values of [0x1-0x8], [0xD-0x1F], [0x7F-0x9F], [0xFDD0-0xFDEF], 77 | // 0xB, 0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF, 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 78 | // 0x4FFFE, 0x4FFFF, 0x5FFFE, 0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 79 | // 0x8FFFE, 0x8FFFF, 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 80 | // 0xCFFFE, 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF, 81 | // 0x10FFFE, and 0x10FFFF 82 | return disallowedNumericReferences.contains(self) 83 | } 84 | 85 | var isHash: Bool { 86 | // unicode value of # 87 | return self == 0x23 88 | } 89 | 90 | var isHexNumeral: Bool { 91 | // unicode values of [0-9], [A-F], and [a-f] 92 | return isNumeral || 0x41...0x46 ~= self || 0x61...0x66 ~= self 93 | } 94 | 95 | var isNumeral: Bool { 96 | // unicode values of [0-9] 97 | return 0x30...0x39 ~= self 98 | } 99 | 100 | /// https://www.w3.org/TR/html5/syntax.html#tokenizing-character-references 101 | var isReplacementCharacterEquivalent: Bool { 102 | // UInt32 values of [0xD800-0xDFFF], (0x10FFFF-∞] 103 | return 0xD800...0xDFFF ~= self || 0x10FFFF < self 104 | } 105 | 106 | var isSafeASCII: Bool { 107 | return self.isASCII && !self.isAttributeSyntax && !self.isTagSyntax 108 | } 109 | 110 | var isSemicolon: Bool { 111 | // unicode value of ; 112 | return self == 0x3B 113 | } 114 | 115 | /// https://www.w3.org/International/questions/qa-escapes#use 116 | var isTagSyntax: Bool { 117 | // unicode values of [&, < , >] 118 | return self.isAmpersand || self == 0x3C || self == 0x3E 119 | } 120 | 121 | var isX: Bool { 122 | // unicode values of X and x 123 | return self == 0x58 || self == 0x78 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /Tests/HTMLEntitiesTests/LinuxSafeguardTest.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright IBM Corporation 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // An extra test case to ensure that all other test cases include all of their 18 | // tests in their respective `allTests` variable. This is to ensure that the 19 | // same number of unit tests are executed on Linux as there are on OSX. 20 | // 21 | // Code adapted from https://oleb.net/blog/2017/03/keeping-xctest-in-sync/ 22 | 23 | // Test disabled on Swift 4 for now due to 24 | // https://bugs.swift.org/browse/SR-5684 25 | #if os(OSX) && !swift(>=3.2) 26 | import XCTest 27 | 28 | class LinuxSafeguardTest: XCTestCase { 29 | func testLinuxTestSuiteIncludesAllTests() { 30 | var linuxCount: Int 31 | var darwinCount: Int 32 | 33 | // HTMLEntitiesTests 34 | linuxCount = HTMLEntitiesTests.allTests.count 35 | darwinCount = Int(HTMLEntitiesTests.defaultTestSuite().testCaseCount) 36 | XCTAssertEqual(linuxCount, darwinCount, "\(darwinCount - linuxCount) tests are missing from HTMLEntitiesTests.allTests") 37 | } 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /Tests/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright IBM Corporation 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | import Glibc 18 | import XCTest 19 | @testable import HTMLEntitiesTests 20 | 21 | // Implementation taken from http://stackoverflow.com/a/24029847 22 | #if swift(>=3.2) 23 | extension MutableCollection { 24 | mutating func shuffle() { 25 | let c = count 26 | guard c > 1 else { return } 27 | 28 | srand(UInt32(time(nil))) 29 | for (firstUnshuffled , unshuffledCount) in zip(indices, stride(from: c, to: 1, by: -1)) { 30 | let d: IndexDistance = numericCast(random() % numericCast(unshuffledCount)) 31 | guard d != 0 else { continue } 32 | let i = index(firstUnshuffled, offsetBy: d) 33 | swapAt(firstUnshuffled, i) 34 | } 35 | } 36 | } 37 | #else 38 | extension MutableCollection where Indices.Iterator.Element == Index { 39 | mutating func shuffle() { 40 | let c = count 41 | guard c > 1 else { return } 42 | 43 | srand(UInt32(time(nil))) 44 | for (firstUnshuffled , unshuffledCount) in zip(indices, stride(from: c, to: 1, by: -1)) { 45 | let d: IndexDistance = numericCast(random() % numericCast(unshuffledCount)) 46 | guard d != 0 else { continue } 47 | let i = index(firstUnshuffled, offsetBy: d) 48 | swap(&self[firstUnshuffled], &self[i]) 49 | } 50 | } 51 | } 52 | #endif 53 | 54 | extension Sequence { 55 | func shuffled() -> [Iterator.Element] { 56 | var result = Array(self) 57 | result.shuffle() 58 | return result 59 | } 60 | } 61 | 62 | XCTMain([ 63 | testCase(HTMLEntitiesTests.allTests.shuffled()), 64 | ].shuffled()) 65 | -------------------------------------------------------------------------------- /docs/Enums.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Enumerations Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | HTMLEntities 4.0.0 Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 74 |
75 | 76 |
77 |
78 |

Enumerations

79 |

The following enumerations are available globally.

80 | 81 |
82 |
83 | 84 |
85 |
86 |
87 |
    88 |
  • 89 |
    90 | 91 | 92 | 93 | ParseError 94 | 95 |
    96 |
    97 |
    98 |
    99 |
    100 |
    101 |

    Enums used to delineate the different kinds of parse errors 102 | that may be encountered during HTML unescaping. See 103 | https://www.w3.org/TR/html5/syntax.html#tokenizing-character-references 104 | for an explanation of the different parse errors.

    105 | 106 | See more 107 |
    108 |
    109 |

    Declaration

    110 |
    111 |

    Swift

    112 |
    public enum ParseError : Error
    113 | 114 |
    115 |
    116 |
    117 |
    118 |
  • 119 |
120 |
121 |
122 |
123 | 124 |
125 |
126 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /docs/Enums/ParseError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ParseError Enumeration Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | HTMLEntities 4.0.0 Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 74 |
75 | 76 |
77 |
78 |

ParseError

79 |
80 |
81 | 82 |
public enum ParseError : Error
83 | 84 |
85 |
86 |

Enums used to delineate the different kinds of parse errors 87 | that may be encountered during HTML unescaping. See 88 | https://www.w3.org/TR/html5/syntax.html#tokenizing-character-references 89 | for an explanation of the different parse errors.

90 | 91 |
92 |
93 | 94 |
95 |
96 |
97 |
    98 |
  • 99 |
    100 | 101 | 102 | 103 | DeprecatedNumericReference(_:) 104 | 105 |
    106 |
    107 |
    108 |
    109 |
    110 |
    111 |

    “If that number is one of the numbers in the first column of the following 112 | table, then this is a parse error.”

    113 | 114 |
    115 |
    116 |

    Declaration

    117 |
    118 |

    Swift

    119 |
    case DeprecatedNumericReference(String)
    120 | 121 |
    122 |
    123 |
    124 |
    125 |
  • 126 |
  • 127 |
    128 | 129 | 130 | 131 | DisallowedNumericReference(_:) 132 | 133 |
    134 |
    135 |
    136 |
    137 |
    138 |
    139 |

    “[I]f the number is in the range 0x0001 to 0x0008, 0x000D to 0x001F, 0x007F 140 | to 0x009F, 0xFDD0 to 0xFDEF, or is one of 0x000B, 0xFFFE, 0xFFFF, 0x1FFFE, 141 | 0x1FFFF, 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE, 142 | 0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF, 0x9FFFE, 143 | 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 0xCFFFE, 0xCFFFF, 0xDFFFE, 144 | 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF, 0x10FFFE, or 0x10FFFF, then 145 | this is a parse error.”

    146 | 147 |
    148 |
    149 |

    Declaration

    150 |
    151 |

    Swift

    152 |
    case DisallowedNumericReference(String)
    153 | 154 |
    155 |
    156 |
    157 |
    158 |
  • 159 |
  • 160 |
    161 | 162 | 163 | 164 | IllegalArgument(_:) 165 | 166 |
    167 |
    168 |
    169 |
    170 |
    171 |
    172 |

    This should NEVER be hit in code execution. If this error is thrown, then 173 | decoder has faulty logic

    174 | 175 |
    176 |
    177 |

    Declaration

    178 |
    179 |

    Swift

    180 |
    case IllegalArgument(String)
    181 | 182 |
    183 |
    184 |
    185 |
    186 |
  • 187 |
  • 188 |
    189 | 190 | 191 | 192 | InvalidNamedReference(_:) 193 | 194 |
    195 |
    196 |
    197 |
    198 |
    199 |
    200 |

    “[I]f the characters after the U+0026 AMPERSAND character (&) consist of 201 | a sequence of one or more alphanumeric ASCII characters followed by a 202 | U+003B SEMICOLON character (;), then this is a parse error.”

    203 | 204 |
    205 |
    206 |

    Declaration

    207 |
    208 |

    Swift

    209 |
    case InvalidNamedReference(String)
    210 | 211 |
    212 |
    213 |
    214 |
    215 |
  • 216 |
  • 217 |
    218 | 219 | 220 | 221 | MalformedNumericReference(_:) 222 | 223 |
    224 |
    225 |
    226 |
    227 |
    228 |
    229 |

    “If no characters match the range, then don’t consume any characters 230 | (and unconsume the U+0023 NUMBER SIGN character and, if appropriate, 231 | the X character). This is a parse error; nothing is returned.”

    232 | 233 |
    234 |
    235 |

    Declaration

    236 |
    237 |

    Swift

    238 |
    case MalformedNumericReference(String)
    239 | 240 |
    241 |
    242 |
    243 |
    244 |
  • 245 |
  • 246 |
    247 | 248 | 249 | 250 | MissingSemicolon(_:) 251 | 252 |
    253 |
    254 |
    255 |
    256 |
    257 |
    258 |

    “[I]f the next character is a U+003B SEMICOLON, consume that too. 259 | If it isn’t, there is a parse error.”

    260 | 261 |
    262 |
    263 |

    Declaration

    264 |
    265 |

    Swift

    266 |
    case MissingSemicolon(String)
    267 | 268 |
    269 |
    270 |
    271 |
    272 |
  • 273 |
  • 274 |
    275 | 276 | 277 | 278 | OutsideValidUnicodeRange(_:) 279 | 280 |
    281 |
    282 |
    283 |
    284 |
    285 |
    286 |

    “[I]f the number is in the range 0xD800 to 0xDFFF or is greater 287 | than 0x10FFFF, then this is a parse error.”

    288 | 289 |
    290 |
    291 |

    Declaration

    292 |
    293 |

    Swift

    294 |
    case OutsideValidUnicodeRange(String)
    295 | 296 |
    297 |
    298 |
    299 |
    300 |
  • 301 |
302 |
303 |
304 |
305 | 306 |
307 |
308 | 312 | 313 | 314 | 315 | -------------------------------------------------------------------------------- /docs/Extensions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Extensions Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | HTMLEntities 4.0.0 Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 74 |
75 | 76 |
77 |
78 |

Extensions

79 |

The following extensions are available globally.

80 | 81 |
82 |
83 | 84 |
85 |
86 |
87 |
    88 |
  • 89 |
    90 | 91 | 92 | 93 | String 94 | 95 |
    96 |
    97 |
    98 |
    99 |
    100 |
    101 |

    This String extension provides utility functions to convert strings to their 102 | HTML escaped equivalents and vice versa.

    103 | 104 | See more 105 |
    106 |
    107 |

    Declaration

    108 |
    109 |

    Swift

    110 |
    public extension String
    111 | 112 |
    113 |
    114 |
    115 |
    116 |
  • 117 |
118 |
119 |
120 |
121 | 122 |
123 |
124 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /docs/Extensions/String.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | String Extension Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | HTMLEntities 4.0.0 Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 74 |
75 | 76 |
77 |
78 |

String

79 |
80 |
81 | 82 |
public extension String
83 | 84 |
85 |
86 |

This String extension provides utility functions to convert strings to their 87 | HTML escaped equivalents and vice versa.

88 | 89 |
90 |
91 | 92 |
93 |
94 |
95 |
    96 |
  • 97 |
    98 | 99 | 100 | 101 | HTMLEscapeOptions 102 | 103 |
    104 |
    105 |
    106 |
    107 |
    108 |
    109 |

    Global HTML escape options

    110 | 111 | See more 112 |
    113 |
    114 |

    Declaration

    115 |
    116 |

    Swift

    117 |
    struct HTMLEscapeOptions
    118 | 119 |
    120 |
    121 |
    122 |
    123 |
  • 124 |
  • 125 | 132 |
    133 |
    134 |
    135 |
    136 |
    137 |

    Return string as HTML escaped by replacing non-ASCII and unsafe characters 138 | with their numeric character escapes, or if such exists, their HTML named 139 | character reference equivalents. For example, this function turns

    140 | 141 |

    "<script>alert("abc")</script>"

    142 | 143 |

    into

    144 | 145 |

    "&lt;script&gt;alert(&quot;abc&quot;)&lt;/script&gt;"

    146 | 147 |

    You can view/change default option values globally via String.HTMLEscapeOptions.

    148 | 149 |
    150 |
    151 |

    Declaration

    152 |
    153 |

    Swift

    154 |
    func htmlEscape(allowUnsafeSymbols: Bool = HTMLEscapeOptions.allowUnsafeSymbols,
    155 |                        decimal: Bool = HTMLEscapeOptions.decimal,
    156 |                        encodeEverything: Bool = HTMLEscapeOptions.encodeEverything,
    157 |                        useNamedReferences: Bool = HTMLEscapeOptions.useNamedReferences)
    158 |     -> String
    159 | 160 |
    161 |
    162 |
    163 |

    Parameters

    164 | 165 | 166 | 167 | 172 | 178 | 179 | 180 | 185 | 191 | 192 | 193 | 198 | 204 | 205 | 206 | 211 | 217 | 218 | 219 |
    168 | 169 | allowUnsafeSymbols 170 | 171 | 173 |
    174 |

    Specifies if all ASCII characters should be skipped 175 | when escaping text. Optional

    176 |
    177 |
    181 | 182 | decimal 183 | 184 | 186 |
    187 |

    Specifies if decimal escapes should be used instead of 188 | hexadecimal escapes. Optional

    189 |
    190 |
    194 | 195 | encodeEverything 196 | 197 | 199 |
    200 |

    Specifies if all characters should be escaped, even if 201 | some are safe characters. Optional

    202 |
    203 |
    207 | 208 | useNamedReferences 209 | 210 | 212 |
    213 |

    Specifies if named character references 214 | should be used whenever possible. Optional

    215 |
    216 |
    220 |
    221 |
    222 |
    223 |
  • 224 |
  • 225 |
    226 | 227 | 228 | 229 | htmlUnescape(strict:) 230 | 231 |
    232 |
    233 |
    234 |
    235 |
    236 |
    237 |

    Return string as HTML unescaped by replacing HTML character references with their 238 | unicode character equivalents. For example, this function turns

    239 | 240 |

    "&lt;script&gt;alert(&quot;abc&quot;)&lt;/script&gt;"

    241 | 242 |

    into

    243 | 244 |

    "<script>alert(\"abc\")</script>"

    245 |
    246 |

    Throws

    247 | (Only if strict == true) The first ParseError encountered during parsing. 248 | 249 |
    250 | 251 |
    252 |
    253 |

    Declaration

    254 |
    255 |

    Swift

    256 |
    func htmlUnescape(strict: Bool) throws -> String
    257 | 258 |
    259 |
    260 |
    261 |

    Parameters

    262 | 263 | 264 | 265 | 270 | 275 | 276 | 277 |
    266 | 267 | strict 268 | 269 | 271 |
    272 |

    Specifies if escapes MUST always end with ;.

    273 |
    274 |
    278 |
    279 |
    280 |
    281 |
  • 282 |
  • 283 |
    284 | 285 | 286 | 287 | htmlUnescape() 288 | 289 |
    290 |
    291 |
    292 |
    293 |
    294 |
    295 |

    Return string as HTML unescaped by replacing HTML character references with their 296 | unicode character equivalents. For example, this function turns

    297 | 298 |

    "&lt;script&gt;alert(&quot;abc&quot;)&lt;/script&gt;"

    299 | 300 |

    into

    301 | 302 |

    "<script>alert(\"abc\")</script>"

    303 | 304 |

    Equivalent to htmlUnescape(strict: false), but does NOT throw parse error.

    305 | 306 |
    307 |
    308 |

    Declaration

    309 |
    310 |

    Swift

    311 |
    func htmlUnescape() -> String
    312 | 313 |
    314 |
    315 |
    316 |
    317 |
  • 318 |
319 |
320 |
321 |
322 | 323 |
324 |
325 | 329 | 330 | 331 | 332 | -------------------------------------------------------------------------------- /docs/Extensions/String/HTMLEscapeOptions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | HTMLEscapeOptions Structure Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | HTMLEntities 4.0.0 Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 74 |
75 | 76 |
77 |
78 |

HTMLEscapeOptions

79 |
80 |
81 | 82 |
struct HTMLEscapeOptions
83 | 84 |
85 |
86 |

Global HTML escape options

87 | 88 |
89 |
90 | 91 |
92 |
93 |
94 |
    95 |
  • 96 |
    97 | 98 | 99 | 100 | allowUnsafeSymbols 101 | 102 |
    103 |
    104 |
    105 |
    106 |
    107 |
    108 |

    Specifies if all ASCII characters should be skipped when escaping text

    109 | 110 |
    111 |
    112 |

    Declaration

    113 |
    114 |

    Swift

    115 |
    public static var allowUnsafeSymbols: Bool
    116 | 117 |
    118 |
    119 |
    120 |
    121 |
  • 122 |
  • 123 |
    124 | 125 | 126 | 127 | decimal 128 | 129 |
    130 |
    131 |
    132 |
    133 |
    134 |
    135 |

    Specifies if decimal escapes should be used instead of hexadecimal escapes

    136 | 137 |
    138 |
    139 |

    Declaration

    140 |
    141 |

    Swift

    142 |
    public static var decimal: Bool
    143 | 144 |
    145 |
    146 |
    147 |
    148 |
  • 149 |
  • 150 |
    151 | 152 | 153 | 154 | encodeEverything 155 | 156 |
    157 |
    158 |
    159 |
    160 |
    161 |
    162 |

    Specifies if all characters should be escaped, even if some are safe characters

    163 | 164 |
    165 |
    166 |

    Declaration

    167 |
    168 |

    Swift

    169 |
    public static var encodeEverything: Bool
    170 | 171 |
    172 |
    173 |
    174 |
    175 |
  • 176 |
  • 177 |
    178 | 179 | 180 | 181 | useNamedReferences 182 | 183 |
    184 |
    185 |
    186 |
    187 |
    188 |
    189 |

    Specifies if named character references should be used whenever possible

    190 | 191 |
    192 |
    193 |

    Declaration

    194 |
    195 |

    Swift

    196 |
    public static var useNamedReferences: Bool
    197 | 198 |
    199 |
    200 |
    201 |
    202 |
  • 203 |
204 |
205 |
206 |
207 | 208 |
209 |
210 | 214 | 215 | 216 | 217 | -------------------------------------------------------------------------------- /docs/css/highlight.css: -------------------------------------------------------------------------------- 1 | /* Credit to https://gist.github.com/wataru420/2048287 */ 2 | .highlight { 3 | /* Comment */ 4 | /* Error */ 5 | /* Keyword */ 6 | /* Operator */ 7 | /* Comment.Multiline */ 8 | /* Comment.Preproc */ 9 | /* Comment.Single */ 10 | /* Comment.Special */ 11 | /* Generic.Deleted */ 12 | /* Generic.Deleted.Specific */ 13 | /* Generic.Emph */ 14 | /* Generic.Error */ 15 | /* Generic.Heading */ 16 | /* Generic.Inserted */ 17 | /* Generic.Inserted.Specific */ 18 | /* Generic.Output */ 19 | /* Generic.Prompt */ 20 | /* Generic.Strong */ 21 | /* Generic.Subheading */ 22 | /* Generic.Traceback */ 23 | /* Keyword.Constant */ 24 | /* Keyword.Declaration */ 25 | /* Keyword.Pseudo */ 26 | /* Keyword.Reserved */ 27 | /* Keyword.Type */ 28 | /* Literal.Number */ 29 | /* Literal.String */ 30 | /* Name.Attribute */ 31 | /* Name.Builtin */ 32 | /* Name.Class */ 33 | /* Name.Constant */ 34 | /* Name.Entity */ 35 | /* Name.Exception */ 36 | /* Name.Function */ 37 | /* Name.Namespace */ 38 | /* Name.Tag */ 39 | /* Name.Variable */ 40 | /* Operator.Word */ 41 | /* Text.Whitespace */ 42 | /* Literal.Number.Float */ 43 | /* Literal.Number.Hex */ 44 | /* Literal.Number.Integer */ 45 | /* Literal.Number.Oct */ 46 | /* Literal.String.Backtick */ 47 | /* Literal.String.Char */ 48 | /* Literal.String.Doc */ 49 | /* Literal.String.Double */ 50 | /* Literal.String.Escape */ 51 | /* Literal.String.Heredoc */ 52 | /* Literal.String.Interpol */ 53 | /* Literal.String.Other */ 54 | /* Literal.String.Regex */ 55 | /* Literal.String.Single */ 56 | /* Literal.String.Symbol */ 57 | /* Name.Builtin.Pseudo */ 58 | /* Name.Variable.Class */ 59 | /* Name.Variable.Global */ 60 | /* Name.Variable.Instance */ 61 | /* Literal.Number.Integer.Long */ } 62 | .highlight .c { 63 | color: #999988; 64 | font-style: italic; } 65 | .highlight .err { 66 | color: #a61717; 67 | background-color: #e3d2d2; } 68 | .highlight .k { 69 | color: #000000; 70 | font-weight: bold; } 71 | .highlight .o { 72 | color: #000000; 73 | font-weight: bold; } 74 | .highlight .cm { 75 | color: #999988; 76 | font-style: italic; } 77 | .highlight .cp { 78 | color: #999999; 79 | font-weight: bold; } 80 | .highlight .c1 { 81 | color: #999988; 82 | font-style: italic; } 83 | .highlight .cs { 84 | color: #999999; 85 | font-weight: bold; 86 | font-style: italic; } 87 | .highlight .gd { 88 | color: #000000; 89 | background-color: #ffdddd; } 90 | .highlight .gd .x { 91 | color: #000000; 92 | background-color: #ffaaaa; } 93 | .highlight .ge { 94 | color: #000000; 95 | font-style: italic; } 96 | .highlight .gr { 97 | color: #aa0000; } 98 | .highlight .gh { 99 | color: #999999; } 100 | .highlight .gi { 101 | color: #000000; 102 | background-color: #ddffdd; } 103 | .highlight .gi .x { 104 | color: #000000; 105 | background-color: #aaffaa; } 106 | .highlight .go { 107 | color: #888888; } 108 | .highlight .gp { 109 | color: #555555; } 110 | .highlight .gs { 111 | font-weight: bold; } 112 | .highlight .gu { 113 | color: #aaaaaa; } 114 | .highlight .gt { 115 | color: #aa0000; } 116 | .highlight .kc { 117 | color: #000000; 118 | font-weight: bold; } 119 | .highlight .kd { 120 | color: #000000; 121 | font-weight: bold; } 122 | .highlight .kp { 123 | color: #000000; 124 | font-weight: bold; } 125 | .highlight .kr { 126 | color: #000000; 127 | font-weight: bold; } 128 | .highlight .kt { 129 | color: #445588; } 130 | .highlight .m { 131 | color: #009999; } 132 | .highlight .s { 133 | color: #d14; } 134 | .highlight .na { 135 | color: #008080; } 136 | .highlight .nb { 137 | color: #0086B3; } 138 | .highlight .nc { 139 | color: #445588; 140 | font-weight: bold; } 141 | .highlight .no { 142 | color: #008080; } 143 | .highlight .ni { 144 | color: #800080; } 145 | .highlight .ne { 146 | color: #990000; 147 | font-weight: bold; } 148 | .highlight .nf { 149 | color: #990000; } 150 | .highlight .nn { 151 | color: #555555; } 152 | .highlight .nt { 153 | color: #000080; } 154 | .highlight .nv { 155 | color: #008080; } 156 | .highlight .ow { 157 | color: #000000; 158 | font-weight: bold; } 159 | .highlight .w { 160 | color: #bbbbbb; } 161 | .highlight .mf { 162 | color: #009999; } 163 | .highlight .mh { 164 | color: #009999; } 165 | .highlight .mi { 166 | color: #009999; } 167 | .highlight .mo { 168 | color: #009999; } 169 | .highlight .sb { 170 | color: #d14; } 171 | .highlight .sc { 172 | color: #d14; } 173 | .highlight .sd { 174 | color: #d14; } 175 | .highlight .s2 { 176 | color: #d14; } 177 | .highlight .se { 178 | color: #d14; } 179 | .highlight .sh { 180 | color: #d14; } 181 | .highlight .si { 182 | color: #d14; } 183 | .highlight .sx { 184 | color: #d14; } 185 | .highlight .sr { 186 | color: #009926; } 187 | .highlight .s1 { 188 | color: #d14; } 189 | .highlight .ss { 190 | color: #990073; } 191 | .highlight .bp { 192 | color: #999999; } 193 | .highlight .vc { 194 | color: #008080; } 195 | .highlight .vg { 196 | color: #008080; } 197 | .highlight .vi { 198 | color: #008080; } 199 | .highlight .il { 200 | color: #009999; } 201 | -------------------------------------------------------------------------------- /docs/css/jazzy.css: -------------------------------------------------------------------------------- 1 | *, *:before, *:after { 2 | box-sizing: inherit; } 3 | 4 | body { 5 | margin: 0; 6 | background: #fff; 7 | color: #333; 8 | font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; 9 | letter-spacing: .2px; 10 | -webkit-font-smoothing: antialiased; 11 | box-sizing: border-box; } 12 | 13 | h1 { 14 | font-size: 2rem; 15 | font-weight: 700; 16 | margin: 1.275em 0 0.6em; } 17 | 18 | h2 { 19 | font-size: 1.75rem; 20 | font-weight: 700; 21 | margin: 1.275em 0 0.3em; } 22 | 23 | h3 { 24 | font-size: 1.5rem; 25 | font-weight: 700; 26 | margin: 1em 0 0.3em; } 27 | 28 | h4 { 29 | font-size: 1.25rem; 30 | font-weight: 700; 31 | margin: 1.275em 0 0.85em; } 32 | 33 | h5 { 34 | font-size: 1rem; 35 | font-weight: 700; 36 | margin: 1.275em 0 0.85em; } 37 | 38 | h6 { 39 | font-size: 1rem; 40 | font-weight: 700; 41 | margin: 1.275em 0 0.85em; 42 | color: #777; } 43 | 44 | p { 45 | margin: 0 0 1em; } 46 | 47 | ul, ol { 48 | padding: 0 0 0 2em; 49 | margin: 0 0 0.85em; } 50 | 51 | blockquote { 52 | margin: 0 0 0.85em; 53 | padding: 0 15px; 54 | color: #858585; 55 | border-left: 4px solid #e5e5e5; } 56 | 57 | img { 58 | max-width: 100%; } 59 | 60 | a { 61 | color: #4183c4; 62 | text-decoration: none; } 63 | a:hover, a:focus { 64 | outline: 0; 65 | text-decoration: underline; } 66 | a.discouraged { 67 | text-decoration: line-through; } 68 | a.discouraged:hover, a.discouraged:focus { 69 | text-decoration: underline line-through; } 70 | 71 | table { 72 | background: #fff; 73 | width: 100%; 74 | border-collapse: collapse; 75 | border-spacing: 0; 76 | overflow: auto; 77 | margin: 0 0 0.85em; } 78 | 79 | tr:nth-child(2n) { 80 | background-color: #fbfbfb; } 81 | 82 | th, td { 83 | padding: 6px 13px; 84 | border: 1px solid #ddd; } 85 | 86 | hr { 87 | height: 1px; 88 | border: none; 89 | background-color: #ddd; } 90 | 91 | pre { 92 | margin: 0 0 1.275em; 93 | padding: .85em 1em; 94 | overflow: auto; 95 | background: #f7f7f7; 96 | font-size: .85em; 97 | font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; } 98 | 99 | code { 100 | font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; } 101 | 102 | .item-container p > code, .item-container li > code, .top-matter p > code, .top-matter li > code { 103 | background: #f7f7f7; 104 | padding: .2em; } 105 | .item-container p > code:before, .item-container p > code:after, .item-container li > code:before, .item-container li > code:after, .top-matter p > code:before, .top-matter p > code:after, .top-matter li > code:before, .top-matter li > code:after { 106 | letter-spacing: -.2em; 107 | content: "\00a0"; } 108 | 109 | pre code { 110 | padding: 0; 111 | white-space: pre; } 112 | 113 | .content-wrapper { 114 | display: flex; 115 | flex-direction: column; } 116 | @media (min-width: 768px) { 117 | .content-wrapper { 118 | flex-direction: row; } } 119 | .header { 120 | display: flex; 121 | padding: 8px; 122 | font-size: 0.875em; 123 | background: #444; 124 | color: #999; } 125 | 126 | .header-col { 127 | margin: 0; 128 | padding: 0 8px; } 129 | 130 | .header-col--primary { 131 | flex: 1; } 132 | 133 | .header-link { 134 | color: #fff; } 135 | 136 | .header-icon { 137 | padding-right: 6px; 138 | vertical-align: -4px; 139 | height: 16px; } 140 | 141 | .breadcrumbs { 142 | font-size: 0.875em; 143 | padding: 8px 16px; 144 | margin: 0; 145 | background: #fbfbfb; 146 | border-bottom: 1px solid #ddd; } 147 | 148 | .carat { 149 | height: 10px; 150 | margin: 0 5px; } 151 | 152 | .navigation { 153 | order: 2; } 154 | @media (min-width: 768px) { 155 | .navigation { 156 | order: 1; 157 | width: 25%; 158 | max-width: 300px; 159 | padding-bottom: 64px; 160 | overflow: hidden; 161 | word-wrap: normal; 162 | background: #fbfbfb; 163 | border-right: 1px solid #ddd; } } 164 | .nav-groups { 165 | list-style-type: none; 166 | padding-left: 0; } 167 | 168 | .nav-group-name { 169 | border-bottom: 1px solid #ddd; 170 | padding: 8px 0 8px 16px; } 171 | 172 | .nav-group-name-link { 173 | color: #333; } 174 | 175 | .nav-group-tasks { 176 | margin: 8px 0; 177 | padding: 0 0 0 8px; } 178 | 179 | .nav-group-task { 180 | font-size: 1em; 181 | list-style-type: none; 182 | white-space: nowrap; } 183 | 184 | .nav-group-task-link { 185 | color: #808080; } 186 | 187 | .main-content { 188 | order: 1; } 189 | @media (min-width: 768px) { 190 | .main-content { 191 | order: 2; 192 | flex: 1; 193 | padding-bottom: 60px; } } 194 | .section { 195 | padding: 0 32px; 196 | border-bottom: 1px solid #ddd; } 197 | 198 | .section-content { 199 | max-width: 834px; 200 | margin: 0 auto; 201 | padding: 16px 0; } 202 | 203 | .section-name { 204 | color: #666; 205 | display: block; } 206 | .section-name p { 207 | margin-bottom: inherit; } 208 | 209 | .declaration .highlight { 210 | overflow-x: initial; 211 | padding: 8px 0; 212 | margin: 0; 213 | background-color: transparent; 214 | border: none; } 215 | 216 | .task-group-section { 217 | border-top: 1px solid #ddd; } 218 | 219 | .task-group { 220 | padding-top: 0px; } 221 | 222 | .task-name-container a[name]:before { 223 | content: ""; 224 | display: block; } 225 | 226 | .section-name-container { 227 | position: relative; } 228 | .section-name-container .section-name-link { 229 | position: absolute; 230 | top: 0; 231 | left: 0; 232 | bottom: 0; 233 | right: 0; 234 | margin-bottom: 0; } 235 | .section-name-container .section-name { 236 | position: relative; 237 | pointer-events: none; 238 | z-index: 1; } 239 | .section-name-container .section-name a { 240 | pointer-events: auto; } 241 | 242 | .item-container { 243 | padding: 0; } 244 | 245 | .item { 246 | padding-top: 8px; 247 | width: 100%; 248 | list-style-type: none; } 249 | .item a[name]:before { 250 | content: ""; 251 | display: block; } 252 | .item .token, .item .direct-link { 253 | display: inline-block; 254 | text-indent: -20px; 255 | padding-left: 3px; 256 | margin-left: 20px; 257 | font-size: 1rem; } 258 | .item .declaration-note { 259 | font-size: .85em; 260 | color: #808080; 261 | font-style: italic; } 262 | 263 | .pointer-container { 264 | border-bottom: 1px solid #ddd; 265 | left: -23px; 266 | padding-bottom: 13px; 267 | position: relative; 268 | width: 110%; } 269 | 270 | .pointer { 271 | left: 21px; 272 | top: 7px; 273 | display: block; 274 | position: absolute; 275 | width: 12px; 276 | height: 12px; 277 | border-left: 1px solid #ddd; 278 | border-top: 1px solid #ddd; 279 | background: #fff; 280 | transform: rotate(45deg); } 281 | 282 | .height-container { 283 | display: none; 284 | position: relative; 285 | width: 100%; 286 | overflow: hidden; } 287 | .height-container .section { 288 | background: #fff; 289 | border: 1px solid #ddd; 290 | border-top-width: 0; 291 | padding-top: 10px; 292 | padding-bottom: 5px; 293 | padding: 8px 16px; } 294 | 295 | .aside, .language { 296 | padding: 6px 12px; 297 | margin: 12px 0; 298 | border-left: 5px solid #dddddd; 299 | overflow-y: hidden; } 300 | .aside .aside-title, .language .aside-title { 301 | font-size: 9px; 302 | letter-spacing: 2px; 303 | text-transform: uppercase; 304 | padding-bottom: 0; 305 | margin: 0; 306 | color: #aaa; 307 | -webkit-user-select: none; } 308 | .aside p:last-child, .language p:last-child { 309 | margin-bottom: 0; } 310 | 311 | .language { 312 | border-left: 5px solid #cde9f4; } 313 | .language .aside-title { 314 | color: #4183c4; } 315 | 316 | .aside-warning, .aside-deprecated, .aside-unavailable { 317 | border-left: 5px solid #ff6666; } 318 | .aside-warning .aside-title, .aside-deprecated .aside-title, .aside-unavailable .aside-title { 319 | color: #ff0000; } 320 | 321 | .graybox { 322 | border-collapse: collapse; 323 | width: 100%; } 324 | .graybox p { 325 | margin: 0; 326 | word-break: break-word; 327 | min-width: 50px; } 328 | .graybox td { 329 | border: 1px solid #ddd; 330 | padding: 5px 25px 5px 10px; 331 | vertical-align: middle; } 332 | .graybox tr td:first-of-type { 333 | text-align: right; 334 | padding: 7px; 335 | vertical-align: top; 336 | word-break: normal; 337 | width: 40px; } 338 | 339 | .slightly-smaller { 340 | font-size: 0.9em; } 341 | 342 | .footer { 343 | padding: 8px 16px; 344 | background: #444; 345 | color: #ddd; 346 | font-size: 0.8em; } 347 | .footer p { 348 | margin: 8px 0; } 349 | .footer a { 350 | color: #fff; } 351 | 352 | html.dash .header, html.dash .breadcrumbs, html.dash .navigation { 353 | display: none; } 354 | 355 | html.dash .height-container { 356 | display: block; } 357 | 358 | form[role=search] input { 359 | font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; 360 | font-size: 14px; 361 | line-height: 24px; 362 | padding: 0 10px; 363 | margin: 0; 364 | border: none; 365 | border-radius: 1em; } 366 | .loading form[role=search] input { 367 | background: white url(../img/spinner.gif) center right 4px no-repeat; } 368 | 369 | form[role=search] .tt-menu { 370 | margin: 0; 371 | min-width: 300px; 372 | background: #fbfbfb; 373 | color: #333; 374 | border: 1px solid #ddd; } 375 | 376 | form[role=search] .tt-highlight { 377 | font-weight: bold; } 378 | 379 | form[role=search] .tt-suggestion { 380 | font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; 381 | padding: 0 8px; } 382 | form[role=search] .tt-suggestion span { 383 | display: table-cell; 384 | white-space: nowrap; } 385 | form[role=search] .tt-suggestion .doc-parent-name { 386 | width: 100%; 387 | text-align: right; 388 | font-weight: normal; 389 | font-size: 0.9em; 390 | padding-left: 16px; } 391 | 392 | form[role=search] .tt-suggestion:hover, 393 | form[role=search] .tt-suggestion.tt-cursor { 394 | cursor: pointer; 395 | background-color: #4183c4; 396 | color: #fff; } 397 | 398 | form[role=search] .tt-suggestion:hover .doc-parent-name, 399 | form[role=search] .tt-suggestion.tt-cursor .doc-parent-name { 400 | color: #fff; } 401 | -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleIdentifier 6 | com.jazzy.htmlentities 7 | CFBundleName 8 | HTMLEntities 9 | DocSetPlatformFamily 10 | htmlentities 11 | isDashDocset 12 | 13 | dashIndexFilePath 14 | index.html 15 | isJavaScriptEnabled 16 | 17 | DashDocSetFamily 18 | dashtoc 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/Enums.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Enumerations Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | HTMLEntities 4.0.0 Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 74 |
75 | 76 |
77 |
78 |

Enumerations

79 |

The following enumerations are available globally.

80 | 81 |
82 |
83 | 84 |
85 |
86 |
87 |
    88 |
  • 89 |
    90 | 91 | 92 | 93 | ParseError 94 | 95 |
    96 |
    97 |
    98 |
    99 |
    100 |
    101 |

    Enums used to delineate the different kinds of parse errors 102 | that may be encountered during HTML unescaping. See 103 | https://www.w3.org/TR/html5/syntax.html#tokenizing-character-references 104 | for an explanation of the different parse errors.

    105 | 106 | See more 107 |
    108 |
    109 |

    Declaration

    110 |
    111 |

    Swift

    112 |
    public enum ParseError : Error
    113 | 114 |
    115 |
    116 |
    117 |
    118 |
  • 119 |
120 |
121 |
122 |
123 | 124 |
125 |
126 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/Enums/ParseError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ParseError Enumeration Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | HTMLEntities 4.0.0 Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 74 |
75 | 76 |
77 |
78 |

ParseError

79 |
80 |
81 | 82 |
public enum ParseError : Error
83 | 84 |
85 |
86 |

Enums used to delineate the different kinds of parse errors 87 | that may be encountered during HTML unescaping. See 88 | https://www.w3.org/TR/html5/syntax.html#tokenizing-character-references 89 | for an explanation of the different parse errors.

90 | 91 |
92 |
93 | 94 |
95 |
96 |
97 |
    98 |
  • 99 |
    100 | 101 | 102 | 103 | DeprecatedNumericReference(_:) 104 | 105 |
    106 |
    107 |
    108 |
    109 |
    110 |
    111 |

    “If that number is one of the numbers in the first column of the following 112 | table, then this is a parse error.”

    113 | 114 |
    115 |
    116 |

    Declaration

    117 |
    118 |

    Swift

    119 |
    case DeprecatedNumericReference(String)
    120 | 121 |
    122 |
    123 |
    124 |
    125 |
  • 126 |
  • 127 |
    128 | 129 | 130 | 131 | DisallowedNumericReference(_:) 132 | 133 |
    134 |
    135 |
    136 |
    137 |
    138 |
    139 |

    “[I]f the number is in the range 0x0001 to 0x0008, 0x000D to 0x001F, 0x007F 140 | to 0x009F, 0xFDD0 to 0xFDEF, or is one of 0x000B, 0xFFFE, 0xFFFF, 0x1FFFE, 141 | 0x1FFFF, 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE, 142 | 0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF, 0x9FFFE, 143 | 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 0xCFFFE, 0xCFFFF, 0xDFFFE, 144 | 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF, 0x10FFFE, or 0x10FFFF, then 145 | this is a parse error.”

    146 | 147 |
    148 |
    149 |

    Declaration

    150 |
    151 |

    Swift

    152 |
    case DisallowedNumericReference(String)
    153 | 154 |
    155 |
    156 |
    157 |
    158 |
  • 159 |
  • 160 |
    161 | 162 | 163 | 164 | IllegalArgument(_:) 165 | 166 |
    167 |
    168 |
    169 |
    170 |
    171 |
    172 |

    This should NEVER be hit in code execution. If this error is thrown, then 173 | decoder has faulty logic

    174 | 175 |
    176 |
    177 |

    Declaration

    178 |
    179 |

    Swift

    180 |
    case IllegalArgument(String)
    181 | 182 |
    183 |
    184 |
    185 |
    186 |
  • 187 |
  • 188 |
    189 | 190 | 191 | 192 | InvalidNamedReference(_:) 193 | 194 |
    195 |
    196 |
    197 |
    198 |
    199 |
    200 |

    “[I]f the characters after the U+0026 AMPERSAND character (&) consist of 201 | a sequence of one or more alphanumeric ASCII characters followed by a 202 | U+003B SEMICOLON character (;), then this is a parse error.”

    203 | 204 |
    205 |
    206 |

    Declaration

    207 |
    208 |

    Swift

    209 |
    case InvalidNamedReference(String)
    210 | 211 |
    212 |
    213 |
    214 |
    215 |
  • 216 |
  • 217 |
    218 | 219 | 220 | 221 | MalformedNumericReference(_:) 222 | 223 |
    224 |
    225 |
    226 |
    227 |
    228 |
    229 |

    “If no characters match the range, then don’t consume any characters 230 | (and unconsume the U+0023 NUMBER SIGN character and, if appropriate, 231 | the X character). This is a parse error; nothing is returned.”

    232 | 233 |
    234 |
    235 |

    Declaration

    236 |
    237 |

    Swift

    238 |
    case MalformedNumericReference(String)
    239 | 240 |
    241 |
    242 |
    243 |
    244 |
  • 245 |
  • 246 |
    247 | 248 | 249 | 250 | MissingSemicolon(_:) 251 | 252 |
    253 |
    254 |
    255 |
    256 |
    257 |
    258 |

    “[I]f the next character is a U+003B SEMICOLON, consume that too. 259 | If it isn’t, there is a parse error.”

    260 | 261 |
    262 |
    263 |

    Declaration

    264 |
    265 |

    Swift

    266 |
    case MissingSemicolon(String)
    267 | 268 |
    269 |
    270 |
    271 |
    272 |
  • 273 |
  • 274 |
    275 | 276 | 277 | 278 | OutsideValidUnicodeRange(_:) 279 | 280 |
    281 |
    282 |
    283 |
    284 |
    285 |
    286 |

    “[I]f the number is in the range 0xD800 to 0xDFFF or is greater 287 | than 0x10FFFF, then this is a parse error.”

    288 | 289 |
    290 |
    291 |

    Declaration

    292 |
    293 |

    Swift

    294 |
    case OutsideValidUnicodeRange(String)
    295 | 296 |
    297 |
    298 |
    299 |
    300 |
  • 301 |
302 |
303 |
304 |
305 | 306 |
307 |
308 | 312 | 313 | 314 | 315 | -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/Extensions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Extensions Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | HTMLEntities 4.0.0 Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 74 |
75 | 76 |
77 |
78 |

Extensions

79 |

The following extensions are available globally.

80 | 81 |
82 |
83 | 84 |
85 |
86 |
87 |
    88 |
  • 89 |
    90 | 91 | 92 | 93 | String 94 | 95 |
    96 |
    97 |
    98 |
    99 |
    100 |
    101 |

    This String extension provides utility functions to convert strings to their 102 | HTML escaped equivalents and vice versa.

    103 | 104 | See more 105 |
    106 |
    107 |

    Declaration

    108 |
    109 |

    Swift

    110 |
    public extension String
    111 | 112 |
    113 |
    114 |
    115 |
    116 |
  • 117 |
118 |
119 |
120 |
121 | 122 |
123 |
124 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/Extensions/String.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | String Extension Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | HTMLEntities 4.0.0 Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 74 |
75 | 76 |
77 |
78 |

String

79 |
80 |
81 | 82 |
public extension String
83 | 84 |
85 |
86 |

This String extension provides utility functions to convert strings to their 87 | HTML escaped equivalents and vice versa.

88 | 89 |
90 |
91 | 92 |
93 |
94 |
95 |
    96 |
  • 97 |
    98 | 99 | 100 | 101 | HTMLEscapeOptions 102 | 103 |
    104 |
    105 |
    106 |
    107 |
    108 |
    109 |

    Global HTML escape options

    110 | 111 | See more 112 |
    113 |
    114 |

    Declaration

    115 |
    116 |

    Swift

    117 |
    struct HTMLEscapeOptions
    118 | 119 |
    120 |
    121 |
    122 |
    123 |
  • 124 |
  • 125 | 132 |
    133 |
    134 |
    135 |
    136 |
    137 |

    Return string as HTML escaped by replacing non-ASCII and unsafe characters 138 | with their numeric character escapes, or if such exists, their HTML named 139 | character reference equivalents. For example, this function turns

    140 | 141 |

    "<script>alert("abc")</script>"

    142 | 143 |

    into

    144 | 145 |

    "&lt;script&gt;alert(&quot;abc&quot;)&lt;/script&gt;"

    146 | 147 |

    You can view/change default option values globally via String.HTMLEscapeOptions.

    148 | 149 |
    150 |
    151 |

    Declaration

    152 |
    153 |

    Swift

    154 |
    func htmlEscape(allowUnsafeSymbols: Bool = HTMLEscapeOptions.allowUnsafeSymbols,
    155 |                        decimal: Bool = HTMLEscapeOptions.decimal,
    156 |                        encodeEverything: Bool = HTMLEscapeOptions.encodeEverything,
    157 |                        useNamedReferences: Bool = HTMLEscapeOptions.useNamedReferences)
    158 |     -> String
    159 | 160 |
    161 |
    162 |
    163 |

    Parameters

    164 | 165 | 166 | 167 | 172 | 178 | 179 | 180 | 185 | 191 | 192 | 193 | 198 | 204 | 205 | 206 | 211 | 217 | 218 | 219 |
    168 | 169 | allowUnsafeSymbols 170 | 171 | 173 |
    174 |

    Specifies if all ASCII characters should be skipped 175 | when escaping text. Optional

    176 |
    177 |
    181 | 182 | decimal 183 | 184 | 186 |
    187 |

    Specifies if decimal escapes should be used instead of 188 | hexadecimal escapes. Optional

    189 |
    190 |
    194 | 195 | encodeEverything 196 | 197 | 199 |
    200 |

    Specifies if all characters should be escaped, even if 201 | some are safe characters. Optional

    202 |
    203 |
    207 | 208 | useNamedReferences 209 | 210 | 212 |
    213 |

    Specifies if named character references 214 | should be used whenever possible. Optional

    215 |
    216 |
    220 |
    221 |
    222 |
    223 |
  • 224 |
  • 225 |
    226 | 227 | 228 | 229 | htmlUnescape(strict:) 230 | 231 |
    232 |
    233 |
    234 |
    235 |
    236 |
    237 |

    Return string as HTML unescaped by replacing HTML character references with their 238 | unicode character equivalents. For example, this function turns

    239 | 240 |

    "&lt;script&gt;alert(&quot;abc&quot;)&lt;/script&gt;"

    241 | 242 |

    into

    243 | 244 |

    "<script>alert(\"abc\")</script>"

    245 |
    246 |

    Throws

    247 | (Only if strict == true) The first ParseError encountered during parsing. 248 | 249 |
    250 | 251 |
    252 |
    253 |

    Declaration

    254 |
    255 |

    Swift

    256 |
    func htmlUnescape(strict: Bool) throws -> String
    257 | 258 |
    259 |
    260 |
    261 |

    Parameters

    262 | 263 | 264 | 265 | 270 | 275 | 276 | 277 |
    266 | 267 | strict 268 | 269 | 271 |
    272 |

    Specifies if escapes MUST always end with ;.

    273 |
    274 |
    278 |
    279 |
    280 |
    281 |
  • 282 |
  • 283 |
    284 | 285 | 286 | 287 | htmlUnescape() 288 | 289 |
    290 |
    291 |
    292 |
    293 |
    294 |
    295 |

    Return string as HTML unescaped by replacing HTML character references with their 296 | unicode character equivalents. For example, this function turns

    297 | 298 |

    "&lt;script&gt;alert(&quot;abc&quot;)&lt;/script&gt;"

    299 | 300 |

    into

    301 | 302 |

    "<script>alert(\"abc\")</script>"

    303 | 304 |

    Equivalent to htmlUnescape(strict: false), but does NOT throw parse error.

    305 | 306 |
    307 |
    308 |

    Declaration

    309 |
    310 |

    Swift

    311 |
    func htmlUnescape() -> String
    312 | 313 |
    314 |
    315 |
    316 |
    317 |
  • 318 |
319 |
320 |
321 |
322 | 323 |
324 |
325 | 329 | 330 | 331 | 332 | -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/Extensions/String/HTMLEscapeOptions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | HTMLEscapeOptions Structure Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |

23 | 24 | HTMLEntities 4.0.0 Docs 25 | 26 | (100% documented) 27 |

28 | 29 |

30 |

31 | 32 |
33 |

34 | 35 |

36 | 37 | 38 | View on GitHub 39 | 40 |

41 | 42 |
43 | 44 | 49 | 50 |
51 | 74 |
75 | 76 |
77 |
78 |

HTMLEscapeOptions

79 |
80 |
81 | 82 |
struct HTMLEscapeOptions
83 | 84 |
85 |
86 |

Global HTML escape options

87 | 88 |
89 |
90 | 91 |
92 |
93 |
94 |
    95 |
  • 96 |
    97 | 98 | 99 | 100 | allowUnsafeSymbols 101 | 102 |
    103 |
    104 |
    105 |
    106 |
    107 |
    108 |

    Specifies if all ASCII characters should be skipped when escaping text

    109 | 110 |
    111 |
    112 |

    Declaration

    113 |
    114 |

    Swift

    115 |
    public static var allowUnsafeSymbols: Bool
    116 | 117 |
    118 |
    119 |
    120 |
    121 |
  • 122 |
  • 123 |
    124 | 125 | 126 | 127 | decimal 128 | 129 |
    130 |
    131 |
    132 |
    133 |
    134 |
    135 |

    Specifies if decimal escapes should be used instead of hexadecimal escapes

    136 | 137 |
    138 |
    139 |

    Declaration

    140 |
    141 |

    Swift

    142 |
    public static var decimal: Bool
    143 | 144 |
    145 |
    146 |
    147 |
    148 |
  • 149 |
  • 150 |
    151 | 152 | 153 | 154 | encodeEverything 155 | 156 |
    157 |
    158 |
    159 |
    160 |
    161 |
    162 |

    Specifies if all characters should be escaped, even if some are safe characters

    163 | 164 |
    165 |
    166 |

    Declaration

    167 |
    168 |

    Swift

    169 |
    public static var encodeEverything: Bool
    170 | 171 |
    172 |
    173 |
    174 |
    175 |
  • 176 |
  • 177 |
    178 | 179 | 180 | 181 | useNamedReferences 182 | 183 |
    184 |
    185 |
    186 |
    187 |
    188 |
    189 |

    Specifies if named character references should be used whenever possible

    190 | 191 |
    192 |
    193 |

    Declaration

    194 |
    195 |

    Swift

    196 |
    public static var useNamedReferences: Bool
    197 | 198 |
    199 |
    200 |
    201 |
    202 |
  • 203 |
204 |
205 |
206 |
207 | 208 |
209 |
210 | 214 | 215 | 216 | 217 | -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/css/highlight.css: -------------------------------------------------------------------------------- 1 | /* Credit to https://gist.github.com/wataru420/2048287 */ 2 | .highlight { 3 | /* Comment */ 4 | /* Error */ 5 | /* Keyword */ 6 | /* Operator */ 7 | /* Comment.Multiline */ 8 | /* Comment.Preproc */ 9 | /* Comment.Single */ 10 | /* Comment.Special */ 11 | /* Generic.Deleted */ 12 | /* Generic.Deleted.Specific */ 13 | /* Generic.Emph */ 14 | /* Generic.Error */ 15 | /* Generic.Heading */ 16 | /* Generic.Inserted */ 17 | /* Generic.Inserted.Specific */ 18 | /* Generic.Output */ 19 | /* Generic.Prompt */ 20 | /* Generic.Strong */ 21 | /* Generic.Subheading */ 22 | /* Generic.Traceback */ 23 | /* Keyword.Constant */ 24 | /* Keyword.Declaration */ 25 | /* Keyword.Pseudo */ 26 | /* Keyword.Reserved */ 27 | /* Keyword.Type */ 28 | /* Literal.Number */ 29 | /* Literal.String */ 30 | /* Name.Attribute */ 31 | /* Name.Builtin */ 32 | /* Name.Class */ 33 | /* Name.Constant */ 34 | /* Name.Entity */ 35 | /* Name.Exception */ 36 | /* Name.Function */ 37 | /* Name.Namespace */ 38 | /* Name.Tag */ 39 | /* Name.Variable */ 40 | /* Operator.Word */ 41 | /* Text.Whitespace */ 42 | /* Literal.Number.Float */ 43 | /* Literal.Number.Hex */ 44 | /* Literal.Number.Integer */ 45 | /* Literal.Number.Oct */ 46 | /* Literal.String.Backtick */ 47 | /* Literal.String.Char */ 48 | /* Literal.String.Doc */ 49 | /* Literal.String.Double */ 50 | /* Literal.String.Escape */ 51 | /* Literal.String.Heredoc */ 52 | /* Literal.String.Interpol */ 53 | /* Literal.String.Other */ 54 | /* Literal.String.Regex */ 55 | /* Literal.String.Single */ 56 | /* Literal.String.Symbol */ 57 | /* Name.Builtin.Pseudo */ 58 | /* Name.Variable.Class */ 59 | /* Name.Variable.Global */ 60 | /* Name.Variable.Instance */ 61 | /* Literal.Number.Integer.Long */ } 62 | .highlight .c { 63 | color: #999988; 64 | font-style: italic; } 65 | .highlight .err { 66 | color: #a61717; 67 | background-color: #e3d2d2; } 68 | .highlight .k { 69 | color: #000000; 70 | font-weight: bold; } 71 | .highlight .o { 72 | color: #000000; 73 | font-weight: bold; } 74 | .highlight .cm { 75 | color: #999988; 76 | font-style: italic; } 77 | .highlight .cp { 78 | color: #999999; 79 | font-weight: bold; } 80 | .highlight .c1 { 81 | color: #999988; 82 | font-style: italic; } 83 | .highlight .cs { 84 | color: #999999; 85 | font-weight: bold; 86 | font-style: italic; } 87 | .highlight .gd { 88 | color: #000000; 89 | background-color: #ffdddd; } 90 | .highlight .gd .x { 91 | color: #000000; 92 | background-color: #ffaaaa; } 93 | .highlight .ge { 94 | color: #000000; 95 | font-style: italic; } 96 | .highlight .gr { 97 | color: #aa0000; } 98 | .highlight .gh { 99 | color: #999999; } 100 | .highlight .gi { 101 | color: #000000; 102 | background-color: #ddffdd; } 103 | .highlight .gi .x { 104 | color: #000000; 105 | background-color: #aaffaa; } 106 | .highlight .go { 107 | color: #888888; } 108 | .highlight .gp { 109 | color: #555555; } 110 | .highlight .gs { 111 | font-weight: bold; } 112 | .highlight .gu { 113 | color: #aaaaaa; } 114 | .highlight .gt { 115 | color: #aa0000; } 116 | .highlight .kc { 117 | color: #000000; 118 | font-weight: bold; } 119 | .highlight .kd { 120 | color: #000000; 121 | font-weight: bold; } 122 | .highlight .kp { 123 | color: #000000; 124 | font-weight: bold; } 125 | .highlight .kr { 126 | color: #000000; 127 | font-weight: bold; } 128 | .highlight .kt { 129 | color: #445588; } 130 | .highlight .m { 131 | color: #009999; } 132 | .highlight .s { 133 | color: #d14; } 134 | .highlight .na { 135 | color: #008080; } 136 | .highlight .nb { 137 | color: #0086B3; } 138 | .highlight .nc { 139 | color: #445588; 140 | font-weight: bold; } 141 | .highlight .no { 142 | color: #008080; } 143 | .highlight .ni { 144 | color: #800080; } 145 | .highlight .ne { 146 | color: #990000; 147 | font-weight: bold; } 148 | .highlight .nf { 149 | color: #990000; } 150 | .highlight .nn { 151 | color: #555555; } 152 | .highlight .nt { 153 | color: #000080; } 154 | .highlight .nv { 155 | color: #008080; } 156 | .highlight .ow { 157 | color: #000000; 158 | font-weight: bold; } 159 | .highlight .w { 160 | color: #bbbbbb; } 161 | .highlight .mf { 162 | color: #009999; } 163 | .highlight .mh { 164 | color: #009999; } 165 | .highlight .mi { 166 | color: #009999; } 167 | .highlight .mo { 168 | color: #009999; } 169 | .highlight .sb { 170 | color: #d14; } 171 | .highlight .sc { 172 | color: #d14; } 173 | .highlight .sd { 174 | color: #d14; } 175 | .highlight .s2 { 176 | color: #d14; } 177 | .highlight .se { 178 | color: #d14; } 179 | .highlight .sh { 180 | color: #d14; } 181 | .highlight .si { 182 | color: #d14; } 183 | .highlight .sx { 184 | color: #d14; } 185 | .highlight .sr { 186 | color: #009926; } 187 | .highlight .s1 { 188 | color: #d14; } 189 | .highlight .ss { 190 | color: #990073; } 191 | .highlight .bp { 192 | color: #999999; } 193 | .highlight .vc { 194 | color: #008080; } 195 | .highlight .vg { 196 | color: #008080; } 197 | .highlight .vi { 198 | color: #008080; } 199 | .highlight .il { 200 | color: #009999; } 201 | -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/css/jazzy.css: -------------------------------------------------------------------------------- 1 | *, *:before, *:after { 2 | box-sizing: inherit; } 3 | 4 | body { 5 | margin: 0; 6 | background: #fff; 7 | color: #333; 8 | font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; 9 | letter-spacing: .2px; 10 | -webkit-font-smoothing: antialiased; 11 | box-sizing: border-box; } 12 | 13 | h1 { 14 | font-size: 2rem; 15 | font-weight: 700; 16 | margin: 1.275em 0 0.6em; } 17 | 18 | h2 { 19 | font-size: 1.75rem; 20 | font-weight: 700; 21 | margin: 1.275em 0 0.3em; } 22 | 23 | h3 { 24 | font-size: 1.5rem; 25 | font-weight: 700; 26 | margin: 1em 0 0.3em; } 27 | 28 | h4 { 29 | font-size: 1.25rem; 30 | font-weight: 700; 31 | margin: 1.275em 0 0.85em; } 32 | 33 | h5 { 34 | font-size: 1rem; 35 | font-weight: 700; 36 | margin: 1.275em 0 0.85em; } 37 | 38 | h6 { 39 | font-size: 1rem; 40 | font-weight: 700; 41 | margin: 1.275em 0 0.85em; 42 | color: #777; } 43 | 44 | p { 45 | margin: 0 0 1em; } 46 | 47 | ul, ol { 48 | padding: 0 0 0 2em; 49 | margin: 0 0 0.85em; } 50 | 51 | blockquote { 52 | margin: 0 0 0.85em; 53 | padding: 0 15px; 54 | color: #858585; 55 | border-left: 4px solid #e5e5e5; } 56 | 57 | img { 58 | max-width: 100%; } 59 | 60 | a { 61 | color: #4183c4; 62 | text-decoration: none; } 63 | a:hover, a:focus { 64 | outline: 0; 65 | text-decoration: underline; } 66 | a.discouraged { 67 | text-decoration: line-through; } 68 | a.discouraged:hover, a.discouraged:focus { 69 | text-decoration: underline line-through; } 70 | 71 | table { 72 | background: #fff; 73 | width: 100%; 74 | border-collapse: collapse; 75 | border-spacing: 0; 76 | overflow: auto; 77 | margin: 0 0 0.85em; } 78 | 79 | tr:nth-child(2n) { 80 | background-color: #fbfbfb; } 81 | 82 | th, td { 83 | padding: 6px 13px; 84 | border: 1px solid #ddd; } 85 | 86 | hr { 87 | height: 1px; 88 | border: none; 89 | background-color: #ddd; } 90 | 91 | pre { 92 | margin: 0 0 1.275em; 93 | padding: .85em 1em; 94 | overflow: auto; 95 | background: #f7f7f7; 96 | font-size: .85em; 97 | font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; } 98 | 99 | code { 100 | font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; } 101 | 102 | .item-container p > code, .item-container li > code, .top-matter p > code, .top-matter li > code { 103 | background: #f7f7f7; 104 | padding: .2em; } 105 | .item-container p > code:before, .item-container p > code:after, .item-container li > code:before, .item-container li > code:after, .top-matter p > code:before, .top-matter p > code:after, .top-matter li > code:before, .top-matter li > code:after { 106 | letter-spacing: -.2em; 107 | content: "\00a0"; } 108 | 109 | pre code { 110 | padding: 0; 111 | white-space: pre; } 112 | 113 | .content-wrapper { 114 | display: flex; 115 | flex-direction: column; } 116 | @media (min-width: 768px) { 117 | .content-wrapper { 118 | flex-direction: row; } } 119 | .header { 120 | display: flex; 121 | padding: 8px; 122 | font-size: 0.875em; 123 | background: #444; 124 | color: #999; } 125 | 126 | .header-col { 127 | margin: 0; 128 | padding: 0 8px; } 129 | 130 | .header-col--primary { 131 | flex: 1; } 132 | 133 | .header-link { 134 | color: #fff; } 135 | 136 | .header-icon { 137 | padding-right: 6px; 138 | vertical-align: -4px; 139 | height: 16px; } 140 | 141 | .breadcrumbs { 142 | font-size: 0.875em; 143 | padding: 8px 16px; 144 | margin: 0; 145 | background: #fbfbfb; 146 | border-bottom: 1px solid #ddd; } 147 | 148 | .carat { 149 | height: 10px; 150 | margin: 0 5px; } 151 | 152 | .navigation { 153 | order: 2; } 154 | @media (min-width: 768px) { 155 | .navigation { 156 | order: 1; 157 | width: 25%; 158 | max-width: 300px; 159 | padding-bottom: 64px; 160 | overflow: hidden; 161 | word-wrap: normal; 162 | background: #fbfbfb; 163 | border-right: 1px solid #ddd; } } 164 | .nav-groups { 165 | list-style-type: none; 166 | padding-left: 0; } 167 | 168 | .nav-group-name { 169 | border-bottom: 1px solid #ddd; 170 | padding: 8px 0 8px 16px; } 171 | 172 | .nav-group-name-link { 173 | color: #333; } 174 | 175 | .nav-group-tasks { 176 | margin: 8px 0; 177 | padding: 0 0 0 8px; } 178 | 179 | .nav-group-task { 180 | font-size: 1em; 181 | list-style-type: none; 182 | white-space: nowrap; } 183 | 184 | .nav-group-task-link { 185 | color: #808080; } 186 | 187 | .main-content { 188 | order: 1; } 189 | @media (min-width: 768px) { 190 | .main-content { 191 | order: 2; 192 | flex: 1; 193 | padding-bottom: 60px; } } 194 | .section { 195 | padding: 0 32px; 196 | border-bottom: 1px solid #ddd; } 197 | 198 | .section-content { 199 | max-width: 834px; 200 | margin: 0 auto; 201 | padding: 16px 0; } 202 | 203 | .section-name { 204 | color: #666; 205 | display: block; } 206 | .section-name p { 207 | margin-bottom: inherit; } 208 | 209 | .declaration .highlight { 210 | overflow-x: initial; 211 | padding: 8px 0; 212 | margin: 0; 213 | background-color: transparent; 214 | border: none; } 215 | 216 | .task-group-section { 217 | border-top: 1px solid #ddd; } 218 | 219 | .task-group { 220 | padding-top: 0px; } 221 | 222 | .task-name-container a[name]:before { 223 | content: ""; 224 | display: block; } 225 | 226 | .section-name-container { 227 | position: relative; } 228 | .section-name-container .section-name-link { 229 | position: absolute; 230 | top: 0; 231 | left: 0; 232 | bottom: 0; 233 | right: 0; 234 | margin-bottom: 0; } 235 | .section-name-container .section-name { 236 | position: relative; 237 | pointer-events: none; 238 | z-index: 1; } 239 | .section-name-container .section-name a { 240 | pointer-events: auto; } 241 | 242 | .item-container { 243 | padding: 0; } 244 | 245 | .item { 246 | padding-top: 8px; 247 | width: 100%; 248 | list-style-type: none; } 249 | .item a[name]:before { 250 | content: ""; 251 | display: block; } 252 | .item .token, .item .direct-link { 253 | display: inline-block; 254 | text-indent: -20px; 255 | padding-left: 3px; 256 | margin-left: 20px; 257 | font-size: 1rem; } 258 | .item .declaration-note { 259 | font-size: .85em; 260 | color: #808080; 261 | font-style: italic; } 262 | 263 | .pointer-container { 264 | border-bottom: 1px solid #ddd; 265 | left: -23px; 266 | padding-bottom: 13px; 267 | position: relative; 268 | width: 110%; } 269 | 270 | .pointer { 271 | left: 21px; 272 | top: 7px; 273 | display: block; 274 | position: absolute; 275 | width: 12px; 276 | height: 12px; 277 | border-left: 1px solid #ddd; 278 | border-top: 1px solid #ddd; 279 | background: #fff; 280 | transform: rotate(45deg); } 281 | 282 | .height-container { 283 | display: none; 284 | position: relative; 285 | width: 100%; 286 | overflow: hidden; } 287 | .height-container .section { 288 | background: #fff; 289 | border: 1px solid #ddd; 290 | border-top-width: 0; 291 | padding-top: 10px; 292 | padding-bottom: 5px; 293 | padding: 8px 16px; } 294 | 295 | .aside, .language { 296 | padding: 6px 12px; 297 | margin: 12px 0; 298 | border-left: 5px solid #dddddd; 299 | overflow-y: hidden; } 300 | .aside .aside-title, .language .aside-title { 301 | font-size: 9px; 302 | letter-spacing: 2px; 303 | text-transform: uppercase; 304 | padding-bottom: 0; 305 | margin: 0; 306 | color: #aaa; 307 | -webkit-user-select: none; } 308 | .aside p:last-child, .language p:last-child { 309 | margin-bottom: 0; } 310 | 311 | .language { 312 | border-left: 5px solid #cde9f4; } 313 | .language .aside-title { 314 | color: #4183c4; } 315 | 316 | .aside-warning, .aside-deprecated, .aside-unavailable { 317 | border-left: 5px solid #ff6666; } 318 | .aside-warning .aside-title, .aside-deprecated .aside-title, .aside-unavailable .aside-title { 319 | color: #ff0000; } 320 | 321 | .graybox { 322 | border-collapse: collapse; 323 | width: 100%; } 324 | .graybox p { 325 | margin: 0; 326 | word-break: break-word; 327 | min-width: 50px; } 328 | .graybox td { 329 | border: 1px solid #ddd; 330 | padding: 5px 25px 5px 10px; 331 | vertical-align: middle; } 332 | .graybox tr td:first-of-type { 333 | text-align: right; 334 | padding: 7px; 335 | vertical-align: top; 336 | word-break: normal; 337 | width: 40px; } 338 | 339 | .slightly-smaller { 340 | font-size: 0.9em; } 341 | 342 | .footer { 343 | padding: 8px 16px; 344 | background: #444; 345 | color: #ddd; 346 | font-size: 0.8em; } 347 | .footer p { 348 | margin: 8px 0; } 349 | .footer a { 350 | color: #fff; } 351 | 352 | html.dash .header, html.dash .breadcrumbs, html.dash .navigation { 353 | display: none; } 354 | 355 | html.dash .height-container { 356 | display: block; } 357 | 358 | form[role=search] input { 359 | font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; 360 | font-size: 14px; 361 | line-height: 24px; 362 | padding: 0 10px; 363 | margin: 0; 364 | border: none; 365 | border-radius: 1em; } 366 | .loading form[role=search] input { 367 | background: white url(../img/spinner.gif) center right 4px no-repeat; } 368 | 369 | form[role=search] .tt-menu { 370 | margin: 0; 371 | min-width: 300px; 372 | background: #fbfbfb; 373 | color: #333; 374 | border: 1px solid #ddd; } 375 | 376 | form[role=search] .tt-highlight { 377 | font-weight: bold; } 378 | 379 | form[role=search] .tt-suggestion { 380 | font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; 381 | padding: 0 8px; } 382 | form[role=search] .tt-suggestion span { 383 | display: table-cell; 384 | white-space: nowrap; } 385 | form[role=search] .tt-suggestion .doc-parent-name { 386 | width: 100%; 387 | text-align: right; 388 | font-weight: normal; 389 | font-size: 0.9em; 390 | padding-left: 16px; } 391 | 392 | form[role=search] .tt-suggestion:hover, 393 | form[role=search] .tt-suggestion.tt-cursor { 394 | cursor: pointer; 395 | background-color: #4183c4; 396 | color: #fff; } 397 | 398 | form[role=search] .tt-suggestion:hover .doc-parent-name, 399 | form[role=search] .tt-suggestion.tt-cursor .doc-parent-name { 400 | color: #fff; } 401 | -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/img/carat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/swift-html-entities/d8ca73197f59ce260c71bd6d7f6eb8bbdccf508b/docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/img/carat.png -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/img/dash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/swift-html-entities/d8ca73197f59ce260c71bd6d7f6eb8bbdccf508b/docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/img/dash.png -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/img/gh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/swift-html-entities/d8ca73197f59ce260c71bd6d7f6eb8bbdccf508b/docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/img/gh.png -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/img/spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/swift-html-entities/d8ca73197f59ce260c71bd6d7f6eb8bbdccf508b/docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/img/spinner.gif -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/js/jazzy.js: -------------------------------------------------------------------------------- 1 | window.jazzy = {'docset': false} 2 | if (typeof window.dash != 'undefined') { 3 | document.documentElement.className += ' dash' 4 | window.jazzy.docset = true 5 | } 6 | if (navigator.userAgent.match(/xcode/i)) { 7 | document.documentElement.className += ' xcode' 8 | window.jazzy.docset = true 9 | } 10 | 11 | function toggleItem($link, $content) { 12 | var animationDuration = 300; 13 | $link.toggleClass('token-open'); 14 | $content.slideToggle(animationDuration); 15 | } 16 | 17 | function itemLinkToContent($link) { 18 | return $link.parent().parent().next(); 19 | } 20 | 21 | // On doc load + hash-change, open any targetted item 22 | function openCurrentItemIfClosed() { 23 | if (window.jazzy.docset) { 24 | return; 25 | } 26 | var $link = $(`a[name="${location.hash.substring(1)}"]`).nextAll('.token'); 27 | $content = itemLinkToContent($link); 28 | if ($content.is(':hidden')) { 29 | toggleItem($link, $content); 30 | } 31 | } 32 | 33 | $(openCurrentItemIfClosed); 34 | $(window).on('hashchange', openCurrentItemIfClosed); 35 | 36 | // On item link ('token') click, toggle its discussion 37 | $('.token').on('click', function(event) { 38 | if (window.jazzy.docset) { 39 | return; 40 | } 41 | var $link = $(this); 42 | toggleItem($link, itemLinkToContent($link)); 43 | 44 | // Keeps the document from jumping to the hash. 45 | var href = $link.attr('href'); 46 | if (history.pushState) { 47 | history.pushState({}, '', href); 48 | } else { 49 | location.hash = href; 50 | } 51 | event.preventDefault(); 52 | }); 53 | 54 | // Clicks on links to the current, closed, item need to open the item 55 | $("a:not('.token')").on('click', function() { 56 | if (location == this.href) { 57 | openCurrentItemIfClosed(); 58 | } 59 | }); 60 | 61 | // KaTeX rendering 62 | if ("katex" in window) { 63 | $($('.math').each( (_, element) => { 64 | katex.render(element.textContent, element, { 65 | displayMode: $(element).hasClass('m-block'), 66 | throwOnError: false, 67 | trust: true 68 | }); 69 | })) 70 | } 71 | -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/js/jazzy.search.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | var $typeahead = $('[data-typeahead]'); 3 | var $form = $typeahead.parents('form'); 4 | var searchURL = $form.attr('action'); 5 | 6 | function displayTemplate(result) { 7 | return result.name; 8 | } 9 | 10 | function suggestionTemplate(result) { 11 | var t = '
'; 12 | t += '' + result.name + ''; 13 | if (result.parent_name) { 14 | t += '' + result.parent_name + ''; 15 | } 16 | t += '
'; 17 | return t; 18 | } 19 | 20 | $typeahead.one('focus', function() { 21 | $form.addClass('loading'); 22 | 23 | $.getJSON(searchURL).then(function(searchData) { 24 | const searchIndex = lunr(function() { 25 | this.ref('url'); 26 | this.field('name'); 27 | this.field('abstract'); 28 | for (const [url, doc] of Object.entries(searchData)) { 29 | this.add({url: url, name: doc.name, abstract: doc.abstract}); 30 | } 31 | }); 32 | 33 | $typeahead.typeahead( 34 | { 35 | highlight: true, 36 | minLength: 3, 37 | autoselect: true 38 | }, 39 | { 40 | limit: 10, 41 | display: displayTemplate, 42 | templates: { suggestion: suggestionTemplate }, 43 | source: function(query, sync) { 44 | const lcSearch = query.toLowerCase(); 45 | const results = searchIndex.query(function(q) { 46 | q.term(lcSearch, { boost: 100 }); 47 | q.term(lcSearch, { 48 | boost: 10, 49 | wildcard: lunr.Query.wildcard.TRAILING 50 | }); 51 | }).map(function(result) { 52 | var doc = searchData[result.ref]; 53 | doc.url = result.ref; 54 | return doc; 55 | }); 56 | sync(results); 57 | } 58 | } 59 | ); 60 | $form.removeClass('loading'); 61 | $typeahead.trigger('focus'); 62 | }); 63 | }); 64 | 65 | var baseURL = searchURL.slice(0, -"search.json".length); 66 | 67 | $typeahead.on('typeahead:select', function(e, result) { 68 | window.location = baseURL + result.url; 69 | }); 70 | }); 71 | -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Resources/Documents/search.json: -------------------------------------------------------------------------------- 1 | {"Extensions/String/HTMLEscapeOptions.html#/s:SS12HTMLEntitiesE17HTMLEscapeOptionsV18allowUnsafeSymbolsSbvpZ":{"name":"allowUnsafeSymbols","abstract":"

Specifies if all ASCII characters should be skipped when escaping text

","parent_name":"HTMLEscapeOptions"},"Extensions/String/HTMLEscapeOptions.html#/s:SS12HTMLEntitiesE17HTMLEscapeOptionsV7decimalSbvpZ":{"name":"decimal","abstract":"

Specifies if decimal escapes should be used instead of hexadecimal escapes

","parent_name":"HTMLEscapeOptions"},"Extensions/String/HTMLEscapeOptions.html#/s:SS12HTMLEntitiesE17HTMLEscapeOptionsV16encodeEverythingSbvpZ":{"name":"encodeEverything","abstract":"

Specifies if all characters should be escaped, even if some are safe characters

","parent_name":"HTMLEscapeOptions"},"Extensions/String/HTMLEscapeOptions.html#/s:SS12HTMLEntitiesE17HTMLEscapeOptionsV18useNamedReferencesSbvpZ":{"name":"useNamedReferences","abstract":"

Specifies if named character references should be used whenever possible

","parent_name":"HTMLEscapeOptions"},"Extensions/String/HTMLEscapeOptions.html":{"name":"HTMLEscapeOptions","abstract":"

Global HTML escape options

","parent_name":"String"},"Extensions/String.html#/s:SS12HTMLEntitiesE10htmlEscape18allowUnsafeSymbols7decimal16encodeEverything18useNamedReferencesSSSb_S3btF":{"name":"htmlEscape(allowUnsafeSymbols:decimal:encodeEverything:useNamedReferences:)","abstract":"

Return string as HTML escaped by replacing non-ASCII and unsafe characters","parent_name":"String"},"Extensions/String.html#/s:SS12HTMLEntitiesE12htmlUnescape6strictSSSb_tKF":{"name":"htmlUnescape(strict:)","abstract":"

Return string as HTML unescaped by replacing HTML character references with their","parent_name":"String"},"Extensions/String.html#/s:SS12HTMLEntitiesE12htmlUnescapeSSyF":{"name":"htmlUnescape()","abstract":"

Return string as HTML unescaped by replacing HTML character references with their","parent_name":"String"},"Extensions/String.html":{"name":"String","abstract":"

This String extension provides utility functions to convert strings to their"},"Enums/ParseError.html#/s:12HTMLEntities10ParseErrorO26DeprecatedNumericReferenceyACSScACmF":{"name":"DeprecatedNumericReference(_:)","abstract":"

“If that number is one of the numbers in the first column of the following","parent_name":"ParseError"},"Enums/ParseError.html#/s:12HTMLEntities10ParseErrorO26DisallowedNumericReferenceyACSScACmF":{"name":"DisallowedNumericReference(_:)","abstract":"

“[I]f the number is in the range 0x0001 to 0x0008, 0x000D to 0x001F, 0x007F","parent_name":"ParseError"},"Enums/ParseError.html#/s:12HTMLEntities10ParseErrorO15IllegalArgumentyACSScACmF":{"name":"IllegalArgument(_:)","abstract":"

This should NEVER be hit in code execution. If this error is thrown, then","parent_name":"ParseError"},"Enums/ParseError.html#/s:12HTMLEntities10ParseErrorO21InvalidNamedReferenceyACSScACmF":{"name":"InvalidNamedReference(_:)","abstract":"

“[I]f the characters after the U+0026 AMPERSAND character (&) consist of","parent_name":"ParseError"},"Enums/ParseError.html#/s:12HTMLEntities10ParseErrorO25MalformedNumericReferenceyACSScACmF":{"name":"MalformedNumericReference(_:)","abstract":"

“If no characters match the range, then don’t consume any characters","parent_name":"ParseError"},"Enums/ParseError.html#/s:12HTMLEntities10ParseErrorO16MissingSemicolonyACSScACmF":{"name":"MissingSemicolon(_:)","abstract":"

“[I]f the next character is a U+003B SEMICOLON, consume that too.","parent_name":"ParseError"},"Enums/ParseError.html#/s:12HTMLEntities10ParseErrorO24OutsideValidUnicodeRangeyACSScACmF":{"name":"OutsideValidUnicodeRange(_:)","abstract":"

“[I]f the number is in the range 0xD800 to 0xDFFF or is greater","parent_name":"ParseError"},"Enums/ParseError.html":{"name":"ParseError","abstract":"

Enums used to delineate the different kinds of parse errors"},"Enums.html":{"name":"Enumerations","abstract":"

The following enumerations are available globally.

"},"Extensions.html":{"name":"Extensions","abstract":"

The following extensions are available globally.

"}} -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.docset/Contents/Resources/docSet.dsidx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/swift-html-entities/d8ca73197f59ce260c71bd6d7f6eb8bbdccf508b/docs/docsets/HTMLEntities.docset/Contents/Resources/docSet.dsidx -------------------------------------------------------------------------------- /docs/docsets/HTMLEntities.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/swift-html-entities/d8ca73197f59ce260c71bd6d7f6eb8bbdccf508b/docs/docsets/HTMLEntities.tgz -------------------------------------------------------------------------------- /docs/img/carat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/swift-html-entities/d8ca73197f59ce260c71bd6d7f6eb8bbdccf508b/docs/img/carat.png -------------------------------------------------------------------------------- /docs/img/dash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/swift-html-entities/d8ca73197f59ce260c71bd6d7f6eb8bbdccf508b/docs/img/dash.png -------------------------------------------------------------------------------- /docs/img/gh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/swift-html-entities/d8ca73197f59ce260c71bd6d7f6eb8bbdccf508b/docs/img/gh.png -------------------------------------------------------------------------------- /docs/img/spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kitura/swift-html-entities/d8ca73197f59ce260c71bd6d7f6eb8bbdccf508b/docs/img/spinner.gif -------------------------------------------------------------------------------- /docs/js/jazzy.js: -------------------------------------------------------------------------------- 1 | window.jazzy = {'docset': false} 2 | if (typeof window.dash != 'undefined') { 3 | document.documentElement.className += ' dash' 4 | window.jazzy.docset = true 5 | } 6 | if (navigator.userAgent.match(/xcode/i)) { 7 | document.documentElement.className += ' xcode' 8 | window.jazzy.docset = true 9 | } 10 | 11 | function toggleItem($link, $content) { 12 | var animationDuration = 300; 13 | $link.toggleClass('token-open'); 14 | $content.slideToggle(animationDuration); 15 | } 16 | 17 | function itemLinkToContent($link) { 18 | return $link.parent().parent().next(); 19 | } 20 | 21 | // On doc load + hash-change, open any targetted item 22 | function openCurrentItemIfClosed() { 23 | if (window.jazzy.docset) { 24 | return; 25 | } 26 | var $link = $(`a[name="${location.hash.substring(1)}"]`).nextAll('.token'); 27 | $content = itemLinkToContent($link); 28 | if ($content.is(':hidden')) { 29 | toggleItem($link, $content); 30 | } 31 | } 32 | 33 | $(openCurrentItemIfClosed); 34 | $(window).on('hashchange', openCurrentItemIfClosed); 35 | 36 | // On item link ('token') click, toggle its discussion 37 | $('.token').on('click', function(event) { 38 | if (window.jazzy.docset) { 39 | return; 40 | } 41 | var $link = $(this); 42 | toggleItem($link, itemLinkToContent($link)); 43 | 44 | // Keeps the document from jumping to the hash. 45 | var href = $link.attr('href'); 46 | if (history.pushState) { 47 | history.pushState({}, '', href); 48 | } else { 49 | location.hash = href; 50 | } 51 | event.preventDefault(); 52 | }); 53 | 54 | // Clicks on links to the current, closed, item need to open the item 55 | $("a:not('.token')").on('click', function() { 56 | if (location == this.href) { 57 | openCurrentItemIfClosed(); 58 | } 59 | }); 60 | 61 | // KaTeX rendering 62 | if ("katex" in window) { 63 | $($('.math').each( (_, element) => { 64 | katex.render(element.textContent, element, { 65 | displayMode: $(element).hasClass('m-block'), 66 | throwOnError: false, 67 | trust: true 68 | }); 69 | })) 70 | } 71 | -------------------------------------------------------------------------------- /docs/js/jazzy.search.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | var $typeahead = $('[data-typeahead]'); 3 | var $form = $typeahead.parents('form'); 4 | var searchURL = $form.attr('action'); 5 | 6 | function displayTemplate(result) { 7 | return result.name; 8 | } 9 | 10 | function suggestionTemplate(result) { 11 | var t = '
'; 12 | t += '' + result.name + ''; 13 | if (result.parent_name) { 14 | t += '' + result.parent_name + ''; 15 | } 16 | t += '
'; 17 | return t; 18 | } 19 | 20 | $typeahead.one('focus', function() { 21 | $form.addClass('loading'); 22 | 23 | $.getJSON(searchURL).then(function(searchData) { 24 | const searchIndex = lunr(function() { 25 | this.ref('url'); 26 | this.field('name'); 27 | this.field('abstract'); 28 | for (const [url, doc] of Object.entries(searchData)) { 29 | this.add({url: url, name: doc.name, abstract: doc.abstract}); 30 | } 31 | }); 32 | 33 | $typeahead.typeahead( 34 | { 35 | highlight: true, 36 | minLength: 3, 37 | autoselect: true 38 | }, 39 | { 40 | limit: 10, 41 | display: displayTemplate, 42 | templates: { suggestion: suggestionTemplate }, 43 | source: function(query, sync) { 44 | const lcSearch = query.toLowerCase(); 45 | const results = searchIndex.query(function(q) { 46 | q.term(lcSearch, { boost: 100 }); 47 | q.term(lcSearch, { 48 | boost: 10, 49 | wildcard: lunr.Query.wildcard.TRAILING 50 | }); 51 | }).map(function(result) { 52 | var doc = searchData[result.ref]; 53 | doc.url = result.ref; 54 | return doc; 55 | }); 56 | sync(results); 57 | } 58 | } 59 | ); 60 | $form.removeClass('loading'); 61 | $typeahead.trigger('focus'); 62 | }); 63 | }); 64 | 65 | var baseURL = searchURL.slice(0, -"search.json".length); 66 | 67 | $typeahead.on('typeahead:select', function(e, result) { 68 | window.location = baseURL + result.url; 69 | }); 70 | }); 71 | -------------------------------------------------------------------------------- /docs/search.json: -------------------------------------------------------------------------------- 1 | {"Extensions/String/HTMLEscapeOptions.html#/s:SS12HTMLEntitiesE17HTMLEscapeOptionsV18allowUnsafeSymbolsSbvpZ":{"name":"allowUnsafeSymbols","abstract":"

Specifies if all ASCII characters should be skipped when escaping text

","parent_name":"HTMLEscapeOptions"},"Extensions/String/HTMLEscapeOptions.html#/s:SS12HTMLEntitiesE17HTMLEscapeOptionsV7decimalSbvpZ":{"name":"decimal","abstract":"

Specifies if decimal escapes should be used instead of hexadecimal escapes

","parent_name":"HTMLEscapeOptions"},"Extensions/String/HTMLEscapeOptions.html#/s:SS12HTMLEntitiesE17HTMLEscapeOptionsV16encodeEverythingSbvpZ":{"name":"encodeEverything","abstract":"

Specifies if all characters should be escaped, even if some are safe characters

","parent_name":"HTMLEscapeOptions"},"Extensions/String/HTMLEscapeOptions.html#/s:SS12HTMLEntitiesE17HTMLEscapeOptionsV18useNamedReferencesSbvpZ":{"name":"useNamedReferences","abstract":"

Specifies if named character references should be used whenever possible

","parent_name":"HTMLEscapeOptions"},"Extensions/String/HTMLEscapeOptions.html":{"name":"HTMLEscapeOptions","abstract":"

Global HTML escape options

","parent_name":"String"},"Extensions/String.html#/s:SS12HTMLEntitiesE10htmlEscape18allowUnsafeSymbols7decimal16encodeEverything18useNamedReferencesSSSb_S3btF":{"name":"htmlEscape(allowUnsafeSymbols:decimal:encodeEverything:useNamedReferences:)","abstract":"

Return string as HTML escaped by replacing non-ASCII and unsafe characters","parent_name":"String"},"Extensions/String.html#/s:SS12HTMLEntitiesE12htmlUnescape6strictSSSb_tKF":{"name":"htmlUnescape(strict:)","abstract":"

Return string as HTML unescaped by replacing HTML character references with their","parent_name":"String"},"Extensions/String.html#/s:SS12HTMLEntitiesE12htmlUnescapeSSyF":{"name":"htmlUnescape()","abstract":"

Return string as HTML unescaped by replacing HTML character references with their","parent_name":"String"},"Extensions/String.html":{"name":"String","abstract":"

This String extension provides utility functions to convert strings to their"},"Enums/ParseError.html#/s:12HTMLEntities10ParseErrorO26DeprecatedNumericReferenceyACSScACmF":{"name":"DeprecatedNumericReference(_:)","abstract":"

“If that number is one of the numbers in the first column of the following","parent_name":"ParseError"},"Enums/ParseError.html#/s:12HTMLEntities10ParseErrorO26DisallowedNumericReferenceyACSScACmF":{"name":"DisallowedNumericReference(_:)","abstract":"

“[I]f the number is in the range 0x0001 to 0x0008, 0x000D to 0x001F, 0x007F","parent_name":"ParseError"},"Enums/ParseError.html#/s:12HTMLEntities10ParseErrorO15IllegalArgumentyACSScACmF":{"name":"IllegalArgument(_:)","abstract":"

This should NEVER be hit in code execution. If this error is thrown, then","parent_name":"ParseError"},"Enums/ParseError.html#/s:12HTMLEntities10ParseErrorO21InvalidNamedReferenceyACSScACmF":{"name":"InvalidNamedReference(_:)","abstract":"

“[I]f the characters after the U+0026 AMPERSAND character (&) consist of","parent_name":"ParseError"},"Enums/ParseError.html#/s:12HTMLEntities10ParseErrorO25MalformedNumericReferenceyACSScACmF":{"name":"MalformedNumericReference(_:)","abstract":"

“If no characters match the range, then don’t consume any characters","parent_name":"ParseError"},"Enums/ParseError.html#/s:12HTMLEntities10ParseErrorO16MissingSemicolonyACSScACmF":{"name":"MissingSemicolon(_:)","abstract":"

“[I]f the next character is a U+003B SEMICOLON, consume that too.","parent_name":"ParseError"},"Enums/ParseError.html#/s:12HTMLEntities10ParseErrorO24OutsideValidUnicodeRangeyACSScACmF":{"name":"OutsideValidUnicodeRange(_:)","abstract":"

“[I]f the number is in the range 0xD800 to 0xDFFF or is greater","parent_name":"ParseError"},"Enums/ParseError.html":{"name":"ParseError","abstract":"

Enums used to delineate the different kinds of parse errors"},"Enums.html":{"name":"Enumerations","abstract":"

The following enumerations are available globally.

"},"Extensions.html":{"name":"Extensions","abstract":"

The following extensions are available globally.

"}} --------------------------------------------------------------------------------