├── .gitignore ├── .travis.yml ├── Example ├── Util │ ├── Errors.swift │ └── Input.swift └── main.swift ├── LICENSE ├── Markdown Table Gen.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ ├── Example.xcscheme │ ├── MarkdownTableGenerator.xcscheme │ └── MarkdownTableGeneratorTests.xcscheme ├── MarkdownTableGenerator ├── Info.plist ├── MarkdownTable.swift └── MarkdownTableGenerator.h ├── MarkdownTableGeneratorTests ├── Info.plist └── MarkdownTableGeneratorTests.swift ├── README.md └── codecov.yml /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | .DS_Store 4 | build/ 5 | *.pbxuser 6 | !default.pbxuser 7 | *.mode1v3 8 | !default.mode1v3 9 | *.mode2v3 10 | !default.mode2v3 11 | *.perspectivev3 12 | !default.perspectivev3 13 | xcuserdata 14 | *.xccheckout 15 | *.moved-aside 16 | DerivedData 17 | *.hmap 18 | *.ipa 19 | *.xcuserstate 20 | .build 21 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode9.3 3 | env: 4 | global: 5 | - LC_CTYPE=en_US.UTF-8 6 | - LANG=en_US.UTF-8 7 | - PROJECT="Markdown Table Gen.xcodeproj" 8 | - MACOS_FRAMEWORK_SCHEME="MarkdownTableGenerator" 9 | - EXAMPLE_SCHEME="Example" 10 | matrix: 11 | 12 | - DESTINATION="arch=x86_64" SCHEME="$MACOS_FRAMEWORK_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="YES" CODE_COV="YES" 13 | 14 | script: 15 | - set -o pipefail 16 | - xcodebuild -version 17 | - xcodebuild -showsdks 18 | 19 | # Build Framework in Debug and Run Tests if specified 20 | - if [ $RUN_TESTS == "YES" ]; then 21 | travis_retry xcodebuild -project "$PROJECT" -scheme "$SCHEME" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test | xcpretty; 22 | else 23 | travis_retry xcodebuild -project "$PROJECT" -scheme "$SCHEME" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO build | xcpretty; 24 | fi 25 | 26 | # Build Framework in Release and Run Tests if specified 27 | - if [ $RUN_TESTS == "YES" ]; then 28 | travis_retry xcodebuild -project "$PROJECT" -scheme "$SCHEME" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test | xcpretty; 29 | else 30 | travis_retry xcodebuild -project "$PROJECT" -scheme "$SCHEME" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=NO build | xcpretty; 31 | fi 32 | 33 | # Build Example in Debug if specified 34 | - if [ $BUILD_EXAMPLE == "YES" ]; then 35 | travis_retry xcodebuild -project "$PROJECT" -scheme "$EXAMPLE_SCHEME" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO build | xcpretty; 36 | fi 37 | 38 | # Build and report code coverage if specified 39 | - if [ $CODE_COV == "YES" ]; then 40 | xcodebuild -project "$PROJECT" -scheme "$SCHEME" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=YES ENABLE_TESTABILITY=YES -enableCodeCoverage YES test; 41 | fi 42 | 43 | after_success: 44 | - bash <(curl -s https://codecov.io/bash) 45 | 46 | -------------------------------------------------------------------------------- /Example/Util/Errors.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Errors.swift 3 | // Example 4 | // 5 | // Created by Louis D'hauwe on 25/03/2018. 6 | // Copyright © 2018 Silver Fox. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | func runtimeError(_ message: String) -> Never { 12 | print("❌ \(message)") 13 | exit(1) 14 | } 15 | -------------------------------------------------------------------------------- /Example/Util/Input.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Input.swift 3 | // Example 4 | // 5 | // Created by Louis D'hauwe on 25/03/2018. 6 | // Copyright © 2018 Silver Fox. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | func readInt() -> Int? { 12 | guard let line = readLine() else { 13 | return nil 14 | } 15 | 16 | return Int(line) 17 | } 18 | -------------------------------------------------------------------------------- /Example/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // Example 4 | // 5 | // Created by Louis D'hauwe on 21/01/2018. 6 | // Copyright © 2018 Silver Fox. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import MarkdownTableGenerator 11 | 12 | print("Enter the number of colums:") 13 | guard let numberOfColumns = readInt(), numberOfColumns > 0 else { 14 | runtimeError("Invalid number of columns") 15 | } 16 | 17 | print("Enter data (separated by commas):") 18 | guard let dataStr = readLine() else { 19 | runtimeError("Invalid data") 20 | } 21 | 22 | var data = dataStr.split(separator: ",").map { $0.trimmingCharacters(in: .whitespacesAndNewlines) } 23 | 24 | print("Output:\n") 25 | 26 | let output = markdownTable(for: data, numberOfColumns: numberOfColumns) 27 | 28 | print(output) 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Louis D'hauwe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Markdown Table Gen.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | BE927514201522F100BD2761 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE927513201522F100BD2761 /* main.swift */; }; 11 | BEFE541B2067F2EA00FEFE93 /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEFE541A2067F2EA00FEFE93 /* Errors.swift */; }; 12 | BEFE542920682CA100FEFE93 /* Input.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEFE542820682CA100FEFE93 /* Input.swift */; }; 13 | BEFE54352068379900FEFE93 /* MarkdownTableGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = BEFE54332068379900FEFE93 /* MarkdownTableGenerator.h */; settings = {ATTRIBUTES = (Public, ); }; }; 14 | BEFE54392068379E00FEFE93 /* MarkdownTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEFE542A2068304800FEFE93 /* MarkdownTable.swift */; }; 15 | BEFE543B206837C400FEFE93 /* MarkdownTableGenerator.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEFE54312068379900FEFE93 /* MarkdownTableGenerator.framework */; }; 16 | BEFE5447206956B900FEFE93 /* MarkdownTableGeneratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEFE5446206956B900FEFE93 /* MarkdownTableGeneratorTests.swift */; }; 17 | BEFE5449206956B900FEFE93 /* MarkdownTableGenerator.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEFE54312068379900FEFE93 /* MarkdownTableGenerator.framework */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | BEFE544A206956B900FEFE93 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = BE927508201522F100BD2761 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = BEFE54302068379900FEFE93; 26 | remoteInfo = MarkdownTableGenerator; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXCopyFilesBuildPhase section */ 31 | BE92750E201522F100BD2761 /* CopyFiles */ = { 32 | isa = PBXCopyFilesBuildPhase; 33 | buildActionMask = 2147483647; 34 | dstPath = /usr/share/man/man1/; 35 | dstSubfolderSpec = 0; 36 | files = ( 37 | ); 38 | runOnlyForDeploymentPostprocessing = 1; 39 | }; 40 | /* End PBXCopyFilesBuildPhase section */ 41 | 42 | /* Begin PBXFileReference section */ 43 | BE927510201522F100BD2761 /* Example */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Example; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | BE927513201522F100BD2761 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; 45 | BEFE541A2067F2EA00FEFE93 /* Errors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = ""; }; 46 | BEFE542820682CA100FEFE93 /* Input.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Input.swift; sourceTree = ""; }; 47 | BEFE542A2068304800FEFE93 /* MarkdownTable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkdownTable.swift; sourceTree = ""; }; 48 | BEFE54312068379900FEFE93 /* MarkdownTableGenerator.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MarkdownTableGenerator.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 49 | BEFE54332068379900FEFE93 /* MarkdownTableGenerator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MarkdownTableGenerator.h; sourceTree = ""; }; 50 | BEFE54342068379900FEFE93 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | BEFE5444206956B900FEFE93 /* MarkdownTableGeneratorTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MarkdownTableGeneratorTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | BEFE5446206956B900FEFE93 /* MarkdownTableGeneratorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkdownTableGeneratorTests.swift; sourceTree = ""; }; 53 | BEFE5448206956B900FEFE93 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | /* End PBXFileReference section */ 55 | 56 | /* Begin PBXFrameworksBuildPhase section */ 57 | BE92750D201522F100BD2761 /* Frameworks */ = { 58 | isa = PBXFrameworksBuildPhase; 59 | buildActionMask = 2147483647; 60 | files = ( 61 | BEFE543B206837C400FEFE93 /* MarkdownTableGenerator.framework in Frameworks */, 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | BEFE542D2068379900FEFE93 /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | BEFE5441206956B900FEFE93 /* Frameworks */ = { 73 | isa = PBXFrameworksBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | BEFE5449206956B900FEFE93 /* MarkdownTableGenerator.framework in Frameworks */, 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | /* End PBXFrameworksBuildPhase section */ 81 | 82 | /* Begin PBXGroup section */ 83 | BE927507201522F100BD2761 = { 84 | isa = PBXGroup; 85 | children = ( 86 | BE927512201522F100BD2761 /* Example */, 87 | BEFE54322068379900FEFE93 /* MarkdownTableGenerator */, 88 | BEFE5445206956B900FEFE93 /* MarkdownTableGeneratorTests */, 89 | BE927511201522F100BD2761 /* Products */, 90 | BEFE543A206837C400FEFE93 /* Frameworks */, 91 | ); 92 | sourceTree = ""; 93 | }; 94 | BE927511201522F100BD2761 /* Products */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | BE927510201522F100BD2761 /* Example */, 98 | BEFE54312068379900FEFE93 /* MarkdownTableGenerator.framework */, 99 | BEFE5444206956B900FEFE93 /* MarkdownTableGeneratorTests.xctest */, 100 | ); 101 | name = Products; 102 | sourceTree = ""; 103 | }; 104 | BE927512201522F100BD2761 /* Example */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | BEFE54192067F2E000FEFE93 /* Util */, 108 | BE927513201522F100BD2761 /* main.swift */, 109 | ); 110 | path = Example; 111 | sourceTree = ""; 112 | }; 113 | BEFE54192067F2E000FEFE93 /* Util */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | BEFE541A2067F2EA00FEFE93 /* Errors.swift */, 117 | BEFE542820682CA100FEFE93 /* Input.swift */, 118 | ); 119 | path = Util; 120 | sourceTree = ""; 121 | }; 122 | BEFE54322068379900FEFE93 /* MarkdownTableGenerator */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | BEFE54332068379900FEFE93 /* MarkdownTableGenerator.h */, 126 | BEFE542A2068304800FEFE93 /* MarkdownTable.swift */, 127 | BEFE54342068379900FEFE93 /* Info.plist */, 128 | ); 129 | path = MarkdownTableGenerator; 130 | sourceTree = ""; 131 | }; 132 | BEFE543A206837C400FEFE93 /* Frameworks */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | ); 136 | name = Frameworks; 137 | sourceTree = ""; 138 | }; 139 | BEFE5445206956B900FEFE93 /* MarkdownTableGeneratorTests */ = { 140 | isa = PBXGroup; 141 | children = ( 142 | BEFE5446206956B900FEFE93 /* MarkdownTableGeneratorTests.swift */, 143 | BEFE5448206956B900FEFE93 /* Info.plist */, 144 | ); 145 | path = MarkdownTableGeneratorTests; 146 | sourceTree = ""; 147 | }; 148 | /* End PBXGroup section */ 149 | 150 | /* Begin PBXHeadersBuildPhase section */ 151 | BEFE542E2068379900FEFE93 /* Headers */ = { 152 | isa = PBXHeadersBuildPhase; 153 | buildActionMask = 2147483647; 154 | files = ( 155 | BEFE54352068379900FEFE93 /* MarkdownTableGenerator.h in Headers */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXHeadersBuildPhase section */ 160 | 161 | /* Begin PBXNativeTarget section */ 162 | BE92750F201522F100BD2761 /* Example */ = { 163 | isa = PBXNativeTarget; 164 | buildConfigurationList = BE927517201522F100BD2761 /* Build configuration list for PBXNativeTarget "Example" */; 165 | buildPhases = ( 166 | BE92750C201522F100BD2761 /* Sources */, 167 | BE92750D201522F100BD2761 /* Frameworks */, 168 | BE92750E201522F100BD2761 /* CopyFiles */, 169 | ); 170 | buildRules = ( 171 | ); 172 | dependencies = ( 173 | ); 174 | name = Example; 175 | productName = "Markdown Table Gen"; 176 | productReference = BE927510201522F100BD2761 /* Example */; 177 | productType = "com.apple.product-type.tool"; 178 | }; 179 | BEFE54302068379900FEFE93 /* MarkdownTableGenerator */ = { 180 | isa = PBXNativeTarget; 181 | buildConfigurationList = BEFE54382068379900FEFE93 /* Build configuration list for PBXNativeTarget "MarkdownTableGenerator" */; 182 | buildPhases = ( 183 | BEFE542C2068379900FEFE93 /* Sources */, 184 | BEFE542D2068379900FEFE93 /* Frameworks */, 185 | BEFE542E2068379900FEFE93 /* Headers */, 186 | BEFE542F2068379900FEFE93 /* Resources */, 187 | ); 188 | buildRules = ( 189 | ); 190 | dependencies = ( 191 | ); 192 | name = MarkdownTableGenerator; 193 | productName = MarkdownTableGenerator; 194 | productReference = BEFE54312068379900FEFE93 /* MarkdownTableGenerator.framework */; 195 | productType = "com.apple.product-type.framework"; 196 | }; 197 | BEFE5443206956B900FEFE93 /* MarkdownTableGeneratorTests */ = { 198 | isa = PBXNativeTarget; 199 | buildConfigurationList = BEFE544C206956B900FEFE93 /* Build configuration list for PBXNativeTarget "MarkdownTableGeneratorTests" */; 200 | buildPhases = ( 201 | BEFE5440206956B900FEFE93 /* Sources */, 202 | BEFE5441206956B900FEFE93 /* Frameworks */, 203 | BEFE5442206956B900FEFE93 /* Resources */, 204 | ); 205 | buildRules = ( 206 | ); 207 | dependencies = ( 208 | BEFE544B206956B900FEFE93 /* PBXTargetDependency */, 209 | ); 210 | name = MarkdownTableGeneratorTests; 211 | productName = MarkdownTableGeneratorTests; 212 | productReference = BEFE5444206956B900FEFE93 /* MarkdownTableGeneratorTests.xctest */; 213 | productType = "com.apple.product-type.bundle.unit-test"; 214 | }; 215 | /* End PBXNativeTarget section */ 216 | 217 | /* Begin PBXProject section */ 218 | BE927508201522F100BD2761 /* Project object */ = { 219 | isa = PBXProject; 220 | attributes = { 221 | LastSwiftUpdateCheck = 0920; 222 | LastUpgradeCheck = 0930; 223 | ORGANIZATIONNAME = "Silver Fox"; 224 | TargetAttributes = { 225 | BE92750F201522F100BD2761 = { 226 | CreatedOnToolsVersion = 9.2; 227 | ProvisioningStyle = Automatic; 228 | }; 229 | BEFE54302068379900FEFE93 = { 230 | CreatedOnToolsVersion = 9.2; 231 | ProvisioningStyle = Manual; 232 | }; 233 | BEFE5443206956B900FEFE93 = { 234 | CreatedOnToolsVersion = 9.2; 235 | ProvisioningStyle = Automatic; 236 | }; 237 | }; 238 | }; 239 | buildConfigurationList = BE92750B201522F100BD2761 /* Build configuration list for PBXProject "Markdown Table Gen" */; 240 | compatibilityVersion = "Xcode 8.0"; 241 | developmentRegion = en; 242 | hasScannedForEncodings = 0; 243 | knownRegions = ( 244 | en, 245 | ); 246 | mainGroup = BE927507201522F100BD2761; 247 | productRefGroup = BE927511201522F100BD2761 /* Products */; 248 | projectDirPath = ""; 249 | projectRoot = ""; 250 | targets = ( 251 | BE92750F201522F100BD2761 /* Example */, 252 | BEFE54302068379900FEFE93 /* MarkdownTableGenerator */, 253 | BEFE5443206956B900FEFE93 /* MarkdownTableGeneratorTests */, 254 | ); 255 | }; 256 | /* End PBXProject section */ 257 | 258 | /* Begin PBXResourcesBuildPhase section */ 259 | BEFE542F2068379900FEFE93 /* Resources */ = { 260 | isa = PBXResourcesBuildPhase; 261 | buildActionMask = 2147483647; 262 | files = ( 263 | ); 264 | runOnlyForDeploymentPostprocessing = 0; 265 | }; 266 | BEFE5442206956B900FEFE93 /* Resources */ = { 267 | isa = PBXResourcesBuildPhase; 268 | buildActionMask = 2147483647; 269 | files = ( 270 | ); 271 | runOnlyForDeploymentPostprocessing = 0; 272 | }; 273 | /* End PBXResourcesBuildPhase section */ 274 | 275 | /* Begin PBXSourcesBuildPhase section */ 276 | BE92750C201522F100BD2761 /* Sources */ = { 277 | isa = PBXSourcesBuildPhase; 278 | buildActionMask = 2147483647; 279 | files = ( 280 | BEFE542920682CA100FEFE93 /* Input.swift in Sources */, 281 | BEFE541B2067F2EA00FEFE93 /* Errors.swift in Sources */, 282 | BE927514201522F100BD2761 /* main.swift in Sources */, 283 | ); 284 | runOnlyForDeploymentPostprocessing = 0; 285 | }; 286 | BEFE542C2068379900FEFE93 /* Sources */ = { 287 | isa = PBXSourcesBuildPhase; 288 | buildActionMask = 2147483647; 289 | files = ( 290 | BEFE54392068379E00FEFE93 /* MarkdownTable.swift in Sources */, 291 | ); 292 | runOnlyForDeploymentPostprocessing = 0; 293 | }; 294 | BEFE5440206956B900FEFE93 /* Sources */ = { 295 | isa = PBXSourcesBuildPhase; 296 | buildActionMask = 2147483647; 297 | files = ( 298 | BEFE5447206956B900FEFE93 /* MarkdownTableGeneratorTests.swift in Sources */, 299 | ); 300 | runOnlyForDeploymentPostprocessing = 0; 301 | }; 302 | /* End PBXSourcesBuildPhase section */ 303 | 304 | /* Begin PBXTargetDependency section */ 305 | BEFE544B206956B900FEFE93 /* PBXTargetDependency */ = { 306 | isa = PBXTargetDependency; 307 | target = BEFE54302068379900FEFE93 /* MarkdownTableGenerator */; 308 | targetProxy = BEFE544A206956B900FEFE93 /* PBXContainerItemProxy */; 309 | }; 310 | /* End PBXTargetDependency section */ 311 | 312 | /* Begin XCBuildConfiguration section */ 313 | BE927515201522F100BD2761 /* Debug */ = { 314 | isa = XCBuildConfiguration; 315 | buildSettings = { 316 | ALWAYS_SEARCH_USER_PATHS = NO; 317 | CLANG_ANALYZER_NONNULL = YES; 318 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 319 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 320 | CLANG_CXX_LIBRARY = "libc++"; 321 | CLANG_ENABLE_MODULES = YES; 322 | CLANG_ENABLE_OBJC_ARC = YES; 323 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 324 | CLANG_WARN_BOOL_CONVERSION = YES; 325 | CLANG_WARN_COMMA = YES; 326 | CLANG_WARN_CONSTANT_CONVERSION = YES; 327 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 328 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 329 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 330 | CLANG_WARN_EMPTY_BODY = YES; 331 | CLANG_WARN_ENUM_CONVERSION = YES; 332 | CLANG_WARN_INFINITE_RECURSION = YES; 333 | CLANG_WARN_INT_CONVERSION = YES; 334 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 335 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 336 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 337 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 338 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 339 | CLANG_WARN_STRICT_PROTOTYPES = YES; 340 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 341 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 342 | CLANG_WARN_UNREACHABLE_CODE = YES; 343 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 344 | CODE_SIGN_IDENTITY = "Mac Developer"; 345 | COPY_PHASE_STRIP = NO; 346 | DEBUG_INFORMATION_FORMAT = dwarf; 347 | ENABLE_STRICT_OBJC_MSGSEND = YES; 348 | ENABLE_TESTABILITY = YES; 349 | GCC_C_LANGUAGE_STANDARD = gnu11; 350 | GCC_DYNAMIC_NO_PIC = NO; 351 | GCC_NO_COMMON_BLOCKS = YES; 352 | GCC_OPTIMIZATION_LEVEL = 0; 353 | GCC_PREPROCESSOR_DEFINITIONS = ( 354 | "DEBUG=1", 355 | "$(inherited)", 356 | ); 357 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 358 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 359 | GCC_WARN_UNDECLARED_SELECTOR = YES; 360 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 361 | GCC_WARN_UNUSED_FUNCTION = YES; 362 | GCC_WARN_UNUSED_VARIABLE = YES; 363 | MACOSX_DEPLOYMENT_TARGET = 10.13; 364 | MTL_ENABLE_DEBUG_INFO = YES; 365 | ONLY_ACTIVE_ARCH = YES; 366 | SDKROOT = macosx; 367 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 368 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 369 | }; 370 | name = Debug; 371 | }; 372 | BE927516201522F100BD2761 /* Release */ = { 373 | isa = XCBuildConfiguration; 374 | buildSettings = { 375 | ALWAYS_SEARCH_USER_PATHS = NO; 376 | CLANG_ANALYZER_NONNULL = YES; 377 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 378 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 379 | CLANG_CXX_LIBRARY = "libc++"; 380 | CLANG_ENABLE_MODULES = YES; 381 | CLANG_ENABLE_OBJC_ARC = YES; 382 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 383 | CLANG_WARN_BOOL_CONVERSION = YES; 384 | CLANG_WARN_COMMA = YES; 385 | CLANG_WARN_CONSTANT_CONVERSION = YES; 386 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 387 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 388 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 389 | CLANG_WARN_EMPTY_BODY = YES; 390 | CLANG_WARN_ENUM_CONVERSION = YES; 391 | CLANG_WARN_INFINITE_RECURSION = YES; 392 | CLANG_WARN_INT_CONVERSION = YES; 393 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 394 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 395 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 396 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 397 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 398 | CLANG_WARN_STRICT_PROTOTYPES = YES; 399 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 400 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 401 | CLANG_WARN_UNREACHABLE_CODE = YES; 402 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 403 | CODE_SIGN_IDENTITY = "Mac Developer"; 404 | COPY_PHASE_STRIP = NO; 405 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 406 | ENABLE_NS_ASSERTIONS = NO; 407 | ENABLE_STRICT_OBJC_MSGSEND = YES; 408 | GCC_C_LANGUAGE_STANDARD = gnu11; 409 | GCC_NO_COMMON_BLOCKS = YES; 410 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 411 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 412 | GCC_WARN_UNDECLARED_SELECTOR = YES; 413 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 414 | GCC_WARN_UNUSED_FUNCTION = YES; 415 | GCC_WARN_UNUSED_VARIABLE = YES; 416 | MACOSX_DEPLOYMENT_TARGET = 10.13; 417 | MTL_ENABLE_DEBUG_INFO = NO; 418 | SDKROOT = macosx; 419 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 420 | }; 421 | name = Release; 422 | }; 423 | BE927518201522F100BD2761 /* Debug */ = { 424 | isa = XCBuildConfiguration; 425 | buildSettings = { 426 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; 427 | CODE_SIGN_IDENTITY = ""; 428 | CODE_SIGN_STYLE = Automatic; 429 | DEVELOPMENT_TEAM = 6G5LMQ72D8; 430 | LD_RUNPATH_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx @executable_path"; 431 | PRODUCT_NAME = "$(TARGET_NAME)"; 432 | PROVISIONING_PROFILE_SPECIFIER = ""; 433 | SWIFT_FORCE_DYNAMIC_LINK_STDLIB = YES; 434 | SWIFT_FORCE_STATIC_LINK_STDLIB = NO; 435 | SWIFT_VERSION = 4.0; 436 | }; 437 | name = Debug; 438 | }; 439 | BE927519201522F100BD2761 /* Release */ = { 440 | isa = XCBuildConfiguration; 441 | buildSettings = { 442 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; 443 | CODE_SIGN_IDENTITY = ""; 444 | CODE_SIGN_STYLE = Automatic; 445 | DEVELOPMENT_TEAM = 6G5LMQ72D8; 446 | LD_RUNPATH_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx @executable_path"; 447 | PRODUCT_NAME = "$(TARGET_NAME)"; 448 | PROVISIONING_PROFILE_SPECIFIER = ""; 449 | SWIFT_FORCE_DYNAMIC_LINK_STDLIB = YES; 450 | SWIFT_FORCE_STATIC_LINK_STDLIB = NO; 451 | SWIFT_VERSION = 4.0; 452 | }; 453 | name = Release; 454 | }; 455 | BEFE54362068379900FEFE93 /* Debug */ = { 456 | isa = XCBuildConfiguration; 457 | buildSettings = { 458 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; 459 | CODE_SIGN_IDENTITY = ""; 460 | CODE_SIGN_STYLE = Manual; 461 | COMBINE_HIDPI_IMAGES = YES; 462 | CURRENT_PROJECT_VERSION = 1; 463 | DEFINES_MODULE = YES; 464 | DEVELOPMENT_TEAM = ""; 465 | DYLIB_COMPATIBILITY_VERSION = 1; 466 | DYLIB_CURRENT_VERSION = 1; 467 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 468 | FRAMEWORK_VERSION = A; 469 | INFOPLIST_FILE = MarkdownTableGenerator/Info.plist; 470 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 471 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 472 | PRODUCT_BUNDLE_IDENTIFIER = be.silverfox.MarkdownTableGenerator; 473 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 474 | PROVISIONING_PROFILE_SPECIFIER = ""; 475 | SKIP_INSTALL = YES; 476 | SWIFT_VERSION = 4.0; 477 | VERSIONING_SYSTEM = "apple-generic"; 478 | VERSION_INFO_PREFIX = ""; 479 | }; 480 | name = Debug; 481 | }; 482 | BEFE54372068379900FEFE93 /* Release */ = { 483 | isa = XCBuildConfiguration; 484 | buildSettings = { 485 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; 486 | CODE_SIGN_IDENTITY = ""; 487 | CODE_SIGN_STYLE = Manual; 488 | COMBINE_HIDPI_IMAGES = YES; 489 | CURRENT_PROJECT_VERSION = 1; 490 | DEFINES_MODULE = YES; 491 | DEVELOPMENT_TEAM = ""; 492 | DYLIB_COMPATIBILITY_VERSION = 1; 493 | DYLIB_CURRENT_VERSION = 1; 494 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 495 | FRAMEWORK_VERSION = A; 496 | INFOPLIST_FILE = MarkdownTableGenerator/Info.plist; 497 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 498 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 499 | PRODUCT_BUNDLE_IDENTIFIER = be.silverfox.MarkdownTableGenerator; 500 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 501 | PROVISIONING_PROFILE_SPECIFIER = ""; 502 | SKIP_INSTALL = YES; 503 | SWIFT_VERSION = 4.0; 504 | VERSIONING_SYSTEM = "apple-generic"; 505 | VERSION_INFO_PREFIX = ""; 506 | }; 507 | name = Release; 508 | }; 509 | BEFE544D206956B900FEFE93 /* Debug */ = { 510 | isa = XCBuildConfiguration; 511 | buildSettings = { 512 | CODE_SIGN_IDENTITY = ""; 513 | CODE_SIGN_STYLE = Automatic; 514 | COMBINE_HIDPI_IMAGES = YES; 515 | DEVELOPMENT_TEAM = ""; 516 | INFOPLIST_FILE = MarkdownTableGeneratorTests/Info.plist; 517 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 518 | PRODUCT_BUNDLE_IDENTIFIER = be.silverfox.MarkdownTableGeneratorTests; 519 | PRODUCT_NAME = "$(TARGET_NAME)"; 520 | PROVISIONING_PROFILE_SPECIFIER = ""; 521 | SWIFT_VERSION = 4.0; 522 | }; 523 | name = Debug; 524 | }; 525 | BEFE544E206956B900FEFE93 /* Release */ = { 526 | isa = XCBuildConfiguration; 527 | buildSettings = { 528 | CODE_SIGN_IDENTITY = ""; 529 | CODE_SIGN_STYLE = Automatic; 530 | COMBINE_HIDPI_IMAGES = YES; 531 | DEVELOPMENT_TEAM = ""; 532 | INFOPLIST_FILE = MarkdownTableGeneratorTests/Info.plist; 533 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 534 | PRODUCT_BUNDLE_IDENTIFIER = be.silverfox.MarkdownTableGeneratorTests; 535 | PRODUCT_NAME = "$(TARGET_NAME)"; 536 | PROVISIONING_PROFILE_SPECIFIER = ""; 537 | SWIFT_VERSION = 4.0; 538 | }; 539 | name = Release; 540 | }; 541 | /* End XCBuildConfiguration section */ 542 | 543 | /* Begin XCConfigurationList section */ 544 | BE92750B201522F100BD2761 /* Build configuration list for PBXProject "Markdown Table Gen" */ = { 545 | isa = XCConfigurationList; 546 | buildConfigurations = ( 547 | BE927515201522F100BD2761 /* Debug */, 548 | BE927516201522F100BD2761 /* Release */, 549 | ); 550 | defaultConfigurationIsVisible = 0; 551 | defaultConfigurationName = Release; 552 | }; 553 | BE927517201522F100BD2761 /* Build configuration list for PBXNativeTarget "Example" */ = { 554 | isa = XCConfigurationList; 555 | buildConfigurations = ( 556 | BE927518201522F100BD2761 /* Debug */, 557 | BE927519201522F100BD2761 /* Release */, 558 | ); 559 | defaultConfigurationIsVisible = 0; 560 | defaultConfigurationName = Release; 561 | }; 562 | BEFE54382068379900FEFE93 /* Build configuration list for PBXNativeTarget "MarkdownTableGenerator" */ = { 563 | isa = XCConfigurationList; 564 | buildConfigurations = ( 565 | BEFE54362068379900FEFE93 /* Debug */, 566 | BEFE54372068379900FEFE93 /* Release */, 567 | ); 568 | defaultConfigurationIsVisible = 0; 569 | defaultConfigurationName = Release; 570 | }; 571 | BEFE544C206956B900FEFE93 /* Build configuration list for PBXNativeTarget "MarkdownTableGeneratorTests" */ = { 572 | isa = XCConfigurationList; 573 | buildConfigurations = ( 574 | BEFE544D206956B900FEFE93 /* Debug */, 575 | BEFE544E206956B900FEFE93 /* Release */, 576 | ); 577 | defaultConfigurationIsVisible = 0; 578 | defaultConfigurationName = Release; 579 | }; 580 | /* End XCConfigurationList section */ 581 | }; 582 | rootObject = BE927508201522F100BD2761 /* Project object */; 583 | } 584 | -------------------------------------------------------------------------------- /Markdown Table Gen.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Markdown Table Gen.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Markdown Table Gen.xcodeproj/xcshareddata/xcschemes/Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Markdown Table Gen.xcodeproj/xcshareddata/xcschemes/MarkdownTableGenerator.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 43 | 44 | 50 | 51 | 52 | 53 | 54 | 55 | 65 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 84 | 90 | 91 | 92 | 93 | 95 | 96 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /Markdown Table Gen.xcodeproj/xcshareddata/xcschemes/MarkdownTableGeneratorTests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 16 | 18 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 40 | 41 | 42 | 43 | 49 | 50 | 52 | 53 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /MarkdownTableGenerator/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSHumanReadableCopyright 22 | Copyright © 2018 Silver Fox. All rights reserved. 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /MarkdownTableGenerator/MarkdownTable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MarkdownTable.swift 3 | // Markdown Table Gen 4 | // 5 | // Created by Louis D'hauwe on 25/03/2018. 6 | // Copyright © 2018 Silver Fox. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public func markdownTable(for data: [String], numberOfColumns: Int) -> String { 12 | 13 | var data = data 14 | 15 | let extraEmptyCells: Int 16 | 17 | if data.isEmpty { 18 | 19 | extraEmptyCells = numberOfColumns 20 | 21 | } else { 22 | 23 | let numberOfCellsAtBottomRow = Int(abs(Double(data.count).truncatingRemainder(dividingBy: Double(numberOfColumns)))) 24 | 25 | extraEmptyCells = numberOfColumns - numberOfCellsAtBottomRow 26 | 27 | } 28 | 29 | data.append(contentsOf: Array(repeating: " ", count: extraEmptyCells)) 30 | 31 | /// Max length of all data determines the cell width. 32 | let maxLength = data.map({ $0.count }).max() ?? 1 33 | 34 | var output = "" 35 | 36 | let headers1 = Array(repeating: "|", count: numberOfColumns + 1) 37 | let headerSeparator = Array(repeatElement(" ", count: maxLength + 2)).joined() 38 | output += headers1.joined(separator: headerSeparator) + "\n" 39 | 40 | let headers1Separator = Array(repeating: "-", count: maxLength).joined() 41 | 42 | output += headers1.joined(separator: " " + headers1Separator + " ") + "\n" 43 | 44 | var i = 0 45 | 46 | for d in data { 47 | 48 | output += "| \(d)" 49 | 50 | let length = d.count 51 | 52 | let extraSpacingNeeded = maxLength - length 53 | 54 | if extraSpacingNeeded > 0 { 55 | for _ in 0.. 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /MarkdownTableGeneratorTests/MarkdownTableGeneratorTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MarkdownTableGeneratorTests.swift 3 | // MarkdownTableGeneratorTests 4 | // 5 | // Created by Louis D'hauwe on 26/03/2018. 6 | // Copyright © 2018 Silver Fox. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import MarkdownTableGenerator 11 | 12 | class MarkdownTableGeneratorTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testEmptyTable() { 25 | 26 | let numberOfColumns = 4 27 | 28 | let output = markdownTable(for: [], numberOfColumns: numberOfColumns) 29 | 30 | let expectedOutput = """ 31 | | | | | | 32 | | - | - | - | - | 33 | | | | | | 34 | 35 | """ 36 | 37 | XCTAssertEqual(output, expectedOutput) 38 | } 39 | 40 | func testAlphabet() { 41 | 42 | let numberOfColumns = 10 43 | 44 | let data = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] 45 | 46 | let output = markdownTable(for: data, numberOfColumns: numberOfColumns) 47 | 48 | let expectedOutput = """ 49 | | | | | | | | | | | | 50 | | - | - | - | - | - | - | - | - | - | - | 51 | | A | B | C | D | E | F | G | H | I | J | 52 | | K | L | M | N | O | P | Q | R | S | T | 53 | | U | V | W | X | Y | Z | | | | | 54 | 55 | """ 56 | 57 | XCTAssertEqual(output, expectedOutput) 58 | } 59 | 60 | func testWords() { 61 | 62 | let numberOfColumns = 4 63 | 64 | let data = ["Here's", "To", "The", "Crazy", "Ones"] 65 | 66 | let output = markdownTable(for: data, numberOfColumns: numberOfColumns) 67 | 68 | let expectedOutput = """ 69 | | | | | | 70 | | ------ | ------ | ------ | ------ | 71 | | Here's | To | The | Crazy | 72 | | Ones | | | | 73 | 74 | """ 75 | 76 | XCTAssertEqual(output, expectedOutput) 77 | 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Markdown Table Generator 2 |

3 | Travis build status 4 | Codecov 5 |
6 | Swift 7 | Platform: iOS macOS tvOS watchOS 8 |
9 | Twitter 10 | Donate via PayPal 11 |

12 | 13 | This is a little script written in Swift that generates a Markdown table from an array of strings for a given number of columns. 14 | 15 | ## Example 16 | 17 | ```swift 18 | let data = ["Here's", "To", "The", "Crazy", "Ones"] 19 | 20 | print(markdownTable(for: data, numberOfColumns: 4)) 21 | ``` 22 | 23 | ``` 24 | | | | | | 25 | | ------ | ------ | ------ | ------ | 26 | | Here's | To | The | Crazy | 27 | | Ones | | | | 28 | ``` 29 | 30 | | | | | | 31 | | ------ | ------ | ------ | ------ | 32 | | Here's | To | The | Crazy | 33 | | Ones | | | | 34 | 35 | 36 | ## License 37 | 38 | This project is available under the MIT license. See the LICENSE file for more info. 39 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | ignore: 3 | - Example/* 4 | - MarkdownTableGeneratorTests/* --------------------------------------------------------------------------------