├── .gitignore ├── LICENSE ├── MarkNoteParserOC ├── MarkNoteParserOC.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── MarkNoteParserOC │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── ImageTag.h │ ├── ImageTag.m │ ├── Info.plist │ ├── LinkTag.h │ ├── LinkTag.m │ ├── MarkNoteParser.h │ ├── MarkNoteParser.m │ ├── NSString+Addition.h │ ├── NSString+Addition.m │ ├── ReferenceDefinition.h │ ├── ReferenceDefinition.m │ ├── ReferenceUsageInfo.h │ ├── ReferenceUsageInfo.m │ ├── URLTag.h │ ├── URLTag.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── MarkNoteParserOCTests │ ├── Info.plist │ ├── MarkNoteParserOCTests.m │ └── NSStringAdditionTests.m └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 MarkNote 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 | 23 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A944C0F91BC16615005495AF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A944C0F81BC16615005495AF /* main.m */; }; 11 | A944C0FC1BC16615005495AF /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A944C0FB1BC16615005495AF /* AppDelegate.m */; }; 12 | A944C0FF1BC16615005495AF /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A944C0FE1BC16615005495AF /* ViewController.m */; }; 13 | A944C1021BC16615005495AF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A944C1001BC16615005495AF /* Main.storyboard */; }; 14 | A944C1041BC16615005495AF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A944C1031BC16615005495AF /* Assets.xcassets */; }; 15 | A944C1071BC16615005495AF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A944C1051BC16615005495AF /* LaunchScreen.storyboard */; }; 16 | A944C1121BC16615005495AF /* MarkNoteParserOCTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A944C1111BC16615005495AF /* MarkNoteParserOCTests.m */; }; 17 | A944C11E1BC17AF0005495AF /* MarkNoteParser.m in Sources */ = {isa = PBXBuildFile; fileRef = A944C11D1BC17AF0005495AF /* MarkNoteParser.m */; settings = {ASSET_TAGS = (); }; }; 18 | A944C1211BC17DCB005495AF /* URLTag.m in Sources */ = {isa = PBXBuildFile; fileRef = A944C1201BC17DCB005495AF /* URLTag.m */; settings = {ASSET_TAGS = (); }; }; 19 | A944C1241BC18079005495AF /* NSString+Addition.m in Sources */ = {isa = PBXBuildFile; fileRef = A944C1231BC18079005495AF /* NSString+Addition.m */; settings = {ASSET_TAGS = (); }; }; 20 | A944C1261BC181AE005495AF /* NSStringAdditionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A944C1251BC181AE005495AF /* NSStringAdditionTests.m */; settings = {ASSET_TAGS = (); }; }; 21 | A944C12B1BC1F529005495AF /* LinkTag.m in Sources */ = {isa = PBXBuildFile; fileRef = A944C12A1BC1F529005495AF /* LinkTag.m */; settings = {ASSET_TAGS = (); }; }; 22 | A944C12E1BC1F58D005495AF /* ImageTag.m in Sources */ = {isa = PBXBuildFile; fileRef = A944C12D1BC1F58D005495AF /* ImageTag.m */; settings = {ASSET_TAGS = (); }; }; 23 | A944C1311BC1F723005495AF /* ReferenceDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = A944C1301BC1F723005495AF /* ReferenceDefinition.m */; settings = {ASSET_TAGS = (); }; }; 24 | A944C1341BC1F772005495AF /* ReferenceUsageInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = A944C1331BC1F772005495AF /* ReferenceUsageInfo.m */; settings = {ASSET_TAGS = (); }; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXContainerItemProxy section */ 28 | A944C10E1BC16615005495AF /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = A944C0EC1BC16615005495AF /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = A944C0F31BC16615005495AF; 33 | remoteInfo = MarkNoteParserOC; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXFileReference section */ 38 | A944C0F41BC16615005495AF /* MarkNoteParserOC.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MarkNoteParserOC.app; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | A944C0F81BC16615005495AF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 40 | A944C0FA1BC16615005495AF /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 41 | A944C0FB1BC16615005495AF /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 42 | A944C0FD1BC16615005495AF /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 43 | A944C0FE1BC16615005495AF /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 44 | A944C1011BC16615005495AF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 45 | A944C1031BC16615005495AF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 46 | A944C1061BC16615005495AF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 47 | A944C1081BC16615005495AF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 48 | A944C10D1BC16615005495AF /* MarkNoteParserOCTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MarkNoteParserOCTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 49 | A944C1111BC16615005495AF /* MarkNoteParserOCTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MarkNoteParserOCTests.m; sourceTree = ""; }; 50 | A944C1131BC16615005495AF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | A944C11C1BC17AF0005495AF /* MarkNoteParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkNoteParser.h; sourceTree = ""; }; 52 | A944C11D1BC17AF0005495AF /* MarkNoteParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MarkNoteParser.m; sourceTree = ""; }; 53 | A944C11F1BC17DCB005495AF /* URLTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLTag.h; sourceTree = ""; }; 54 | A944C1201BC17DCB005495AF /* URLTag.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = URLTag.m; sourceTree = ""; }; 55 | A944C1221BC18079005495AF /* NSString+Addition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Addition.h"; sourceTree = ""; }; 56 | A944C1231BC18079005495AF /* NSString+Addition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Addition.m"; sourceTree = ""; }; 57 | A944C1251BC181AE005495AF /* NSStringAdditionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSStringAdditionTests.m; sourceTree = ""; }; 58 | A944C1291BC1F529005495AF /* LinkTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkTag.h; sourceTree = ""; }; 59 | A944C12A1BC1F529005495AF /* LinkTag.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LinkTag.m; sourceTree = ""; }; 60 | A944C12C1BC1F58D005495AF /* ImageTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageTag.h; sourceTree = ""; }; 61 | A944C12D1BC1F58D005495AF /* ImageTag.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageTag.m; sourceTree = ""; }; 62 | A944C12F1BC1F723005495AF /* ReferenceDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReferenceDefinition.h; sourceTree = ""; }; 63 | A944C1301BC1F723005495AF /* ReferenceDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReferenceDefinition.m; sourceTree = ""; }; 64 | A944C1321BC1F772005495AF /* ReferenceUsageInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReferenceUsageInfo.h; sourceTree = ""; }; 65 | A944C1331BC1F772005495AF /* ReferenceUsageInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReferenceUsageInfo.m; sourceTree = ""; }; 66 | /* End PBXFileReference section */ 67 | 68 | /* Begin PBXFrameworksBuildPhase section */ 69 | A944C0F11BC16615005495AF /* Frameworks */ = { 70 | isa = PBXFrameworksBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | A944C10A1BC16615005495AF /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | /* End PBXFrameworksBuildPhase section */ 84 | 85 | /* Begin PBXGroup section */ 86 | A944C0EB1BC16615005495AF = { 87 | isa = PBXGroup; 88 | children = ( 89 | A944C0F61BC16615005495AF /* MarkNoteParserOC */, 90 | A944C1101BC16615005495AF /* MarkNoteParserOCTests */, 91 | A944C0F51BC16615005495AF /* Products */, 92 | ); 93 | sourceTree = ""; 94 | }; 95 | A944C0F51BC16615005495AF /* Products */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | A944C0F41BC16615005495AF /* MarkNoteParserOC.app */, 99 | A944C10D1BC16615005495AF /* MarkNoteParserOCTests.xctest */, 100 | ); 101 | name = Products; 102 | sourceTree = ""; 103 | }; 104 | A944C0F61BC16615005495AF /* MarkNoteParserOC */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | A944C1281BC1F0EB005495AF /* Categories */, 108 | A944C1271BC1F0D6005495AF /* Model */, 109 | A944C0FA1BC16615005495AF /* AppDelegate.h */, 110 | A944C0FB1BC16615005495AF /* AppDelegate.m */, 111 | A944C0FD1BC16615005495AF /* ViewController.h */, 112 | A944C0FE1BC16615005495AF /* ViewController.m */, 113 | A944C1001BC16615005495AF /* Main.storyboard */, 114 | A944C1031BC16615005495AF /* Assets.xcassets */, 115 | A944C1051BC16615005495AF /* LaunchScreen.storyboard */, 116 | A944C1081BC16615005495AF /* Info.plist */, 117 | A944C0F71BC16615005495AF /* Supporting Files */, 118 | ); 119 | path = MarkNoteParserOC; 120 | sourceTree = ""; 121 | }; 122 | A944C0F71BC16615005495AF /* Supporting Files */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | A944C0F81BC16615005495AF /* main.m */, 126 | ); 127 | name = "Supporting Files"; 128 | sourceTree = ""; 129 | }; 130 | A944C1101BC16615005495AF /* MarkNoteParserOCTests */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | A944C1111BC16615005495AF /* MarkNoteParserOCTests.m */, 134 | A944C1131BC16615005495AF /* Info.plist */, 135 | A944C1251BC181AE005495AF /* NSStringAdditionTests.m */, 136 | ); 137 | path = MarkNoteParserOCTests; 138 | sourceTree = ""; 139 | }; 140 | A944C1271BC1F0D6005495AF /* Model */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | A944C11C1BC17AF0005495AF /* MarkNoteParser.h */, 144 | A944C11D1BC17AF0005495AF /* MarkNoteParser.m */, 145 | A944C11F1BC17DCB005495AF /* URLTag.h */, 146 | A944C1201BC17DCB005495AF /* URLTag.m */, 147 | A944C1291BC1F529005495AF /* LinkTag.h */, 148 | A944C12A1BC1F529005495AF /* LinkTag.m */, 149 | A944C12C1BC1F58D005495AF /* ImageTag.h */, 150 | A944C12D1BC1F58D005495AF /* ImageTag.m */, 151 | A944C12F1BC1F723005495AF /* ReferenceDefinition.h */, 152 | A944C1301BC1F723005495AF /* ReferenceDefinition.m */, 153 | A944C1321BC1F772005495AF /* ReferenceUsageInfo.h */, 154 | A944C1331BC1F772005495AF /* ReferenceUsageInfo.m */, 155 | ); 156 | name = Model; 157 | sourceTree = ""; 158 | }; 159 | A944C1281BC1F0EB005495AF /* Categories */ = { 160 | isa = PBXGroup; 161 | children = ( 162 | A944C1221BC18079005495AF /* NSString+Addition.h */, 163 | A944C1231BC18079005495AF /* NSString+Addition.m */, 164 | ); 165 | name = Categories; 166 | sourceTree = ""; 167 | }; 168 | /* End PBXGroup section */ 169 | 170 | /* Begin PBXNativeTarget section */ 171 | A944C0F31BC16615005495AF /* MarkNoteParserOC */ = { 172 | isa = PBXNativeTarget; 173 | buildConfigurationList = A944C1161BC16615005495AF /* Build configuration list for PBXNativeTarget "MarkNoteParserOC" */; 174 | buildPhases = ( 175 | A944C0F01BC16615005495AF /* Sources */, 176 | A944C0F11BC16615005495AF /* Frameworks */, 177 | A944C0F21BC16615005495AF /* Resources */, 178 | ); 179 | buildRules = ( 180 | ); 181 | dependencies = ( 182 | ); 183 | name = MarkNoteParserOC; 184 | productName = MarkNoteParserOC; 185 | productReference = A944C0F41BC16615005495AF /* MarkNoteParserOC.app */; 186 | productType = "com.apple.product-type.application"; 187 | }; 188 | A944C10C1BC16615005495AF /* MarkNoteParserOCTests */ = { 189 | isa = PBXNativeTarget; 190 | buildConfigurationList = A944C1191BC16615005495AF /* Build configuration list for PBXNativeTarget "MarkNoteParserOCTests" */; 191 | buildPhases = ( 192 | A944C1091BC16615005495AF /* Sources */, 193 | A944C10A1BC16615005495AF /* Frameworks */, 194 | A944C10B1BC16615005495AF /* Resources */, 195 | ); 196 | buildRules = ( 197 | ); 198 | dependencies = ( 199 | A944C10F1BC16615005495AF /* PBXTargetDependency */, 200 | ); 201 | name = MarkNoteParserOCTests; 202 | productName = MarkNoteParserOCTests; 203 | productReference = A944C10D1BC16615005495AF /* MarkNoteParserOCTests.xctest */; 204 | productType = "com.apple.product-type.bundle.unit-test"; 205 | }; 206 | /* End PBXNativeTarget section */ 207 | 208 | /* Begin PBXProject section */ 209 | A944C0EC1BC16615005495AF /* Project object */ = { 210 | isa = PBXProject; 211 | attributes = { 212 | LastUpgradeCheck = 0700; 213 | ORGANIZATIONNAME = marknote; 214 | TargetAttributes = { 215 | A944C0F31BC16615005495AF = { 216 | CreatedOnToolsVersion = 7.0.1; 217 | }; 218 | A944C10C1BC16615005495AF = { 219 | CreatedOnToolsVersion = 7.0.1; 220 | TestTargetID = A944C0F31BC16615005495AF; 221 | }; 222 | }; 223 | }; 224 | buildConfigurationList = A944C0EF1BC16615005495AF /* Build configuration list for PBXProject "MarkNoteParserOC" */; 225 | compatibilityVersion = "Xcode 3.2"; 226 | developmentRegion = English; 227 | hasScannedForEncodings = 0; 228 | knownRegions = ( 229 | en, 230 | Base, 231 | ); 232 | mainGroup = A944C0EB1BC16615005495AF; 233 | productRefGroup = A944C0F51BC16615005495AF /* Products */; 234 | projectDirPath = ""; 235 | projectRoot = ""; 236 | targets = ( 237 | A944C0F31BC16615005495AF /* MarkNoteParserOC */, 238 | A944C10C1BC16615005495AF /* MarkNoteParserOCTests */, 239 | ); 240 | }; 241 | /* End PBXProject section */ 242 | 243 | /* Begin PBXResourcesBuildPhase section */ 244 | A944C0F21BC16615005495AF /* Resources */ = { 245 | isa = PBXResourcesBuildPhase; 246 | buildActionMask = 2147483647; 247 | files = ( 248 | A944C1071BC16615005495AF /* LaunchScreen.storyboard in Resources */, 249 | A944C1041BC16615005495AF /* Assets.xcassets in Resources */, 250 | A944C1021BC16615005495AF /* Main.storyboard in Resources */, 251 | ); 252 | runOnlyForDeploymentPostprocessing = 0; 253 | }; 254 | A944C10B1BC16615005495AF /* Resources */ = { 255 | isa = PBXResourcesBuildPhase; 256 | buildActionMask = 2147483647; 257 | files = ( 258 | ); 259 | runOnlyForDeploymentPostprocessing = 0; 260 | }; 261 | /* End PBXResourcesBuildPhase section */ 262 | 263 | /* Begin PBXSourcesBuildPhase section */ 264 | A944C0F01BC16615005495AF /* Sources */ = { 265 | isa = PBXSourcesBuildPhase; 266 | buildActionMask = 2147483647; 267 | files = ( 268 | A944C12B1BC1F529005495AF /* LinkTag.m in Sources */, 269 | A944C0FF1BC16615005495AF /* ViewController.m in Sources */, 270 | A944C1241BC18079005495AF /* NSString+Addition.m in Sources */, 271 | A944C11E1BC17AF0005495AF /* MarkNoteParser.m in Sources */, 272 | A944C12E1BC1F58D005495AF /* ImageTag.m in Sources */, 273 | A944C1341BC1F772005495AF /* ReferenceUsageInfo.m in Sources */, 274 | A944C1211BC17DCB005495AF /* URLTag.m in Sources */, 275 | A944C0FC1BC16615005495AF /* AppDelegate.m in Sources */, 276 | A944C1311BC1F723005495AF /* ReferenceDefinition.m in Sources */, 277 | A944C0F91BC16615005495AF /* main.m in Sources */, 278 | ); 279 | runOnlyForDeploymentPostprocessing = 0; 280 | }; 281 | A944C1091BC16615005495AF /* Sources */ = { 282 | isa = PBXSourcesBuildPhase; 283 | buildActionMask = 2147483647; 284 | files = ( 285 | A944C1121BC16615005495AF /* MarkNoteParserOCTests.m in Sources */, 286 | A944C1261BC181AE005495AF /* NSStringAdditionTests.m in Sources */, 287 | ); 288 | runOnlyForDeploymentPostprocessing = 0; 289 | }; 290 | /* End PBXSourcesBuildPhase section */ 291 | 292 | /* Begin PBXTargetDependency section */ 293 | A944C10F1BC16615005495AF /* PBXTargetDependency */ = { 294 | isa = PBXTargetDependency; 295 | target = A944C0F31BC16615005495AF /* MarkNoteParserOC */; 296 | targetProxy = A944C10E1BC16615005495AF /* PBXContainerItemProxy */; 297 | }; 298 | /* End PBXTargetDependency section */ 299 | 300 | /* Begin PBXVariantGroup section */ 301 | A944C1001BC16615005495AF /* Main.storyboard */ = { 302 | isa = PBXVariantGroup; 303 | children = ( 304 | A944C1011BC16615005495AF /* Base */, 305 | ); 306 | name = Main.storyboard; 307 | sourceTree = ""; 308 | }; 309 | A944C1051BC16615005495AF /* LaunchScreen.storyboard */ = { 310 | isa = PBXVariantGroup; 311 | children = ( 312 | A944C1061BC16615005495AF /* Base */, 313 | ); 314 | name = LaunchScreen.storyboard; 315 | sourceTree = ""; 316 | }; 317 | /* End PBXVariantGroup section */ 318 | 319 | /* Begin XCBuildConfiguration section */ 320 | A944C1141BC16615005495AF /* Debug */ = { 321 | isa = XCBuildConfiguration; 322 | buildSettings = { 323 | ALWAYS_SEARCH_USER_PATHS = NO; 324 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 325 | CLANG_CXX_LIBRARY = "libc++"; 326 | CLANG_ENABLE_MODULES = YES; 327 | CLANG_ENABLE_OBJC_ARC = YES; 328 | CLANG_WARN_BOOL_CONVERSION = YES; 329 | CLANG_WARN_CONSTANT_CONVERSION = YES; 330 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 331 | CLANG_WARN_EMPTY_BODY = YES; 332 | CLANG_WARN_ENUM_CONVERSION = YES; 333 | CLANG_WARN_INT_CONVERSION = YES; 334 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 335 | CLANG_WARN_UNREACHABLE_CODE = YES; 336 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 337 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 338 | COPY_PHASE_STRIP = NO; 339 | DEBUG_INFORMATION_FORMAT = dwarf; 340 | ENABLE_STRICT_OBJC_MSGSEND = YES; 341 | ENABLE_TESTABILITY = YES; 342 | GCC_C_LANGUAGE_STANDARD = gnu99; 343 | GCC_DYNAMIC_NO_PIC = NO; 344 | GCC_NO_COMMON_BLOCKS = YES; 345 | GCC_OPTIMIZATION_LEVEL = 0; 346 | GCC_PREPROCESSOR_DEFINITIONS = ( 347 | "DEBUG=1", 348 | "$(inherited)", 349 | ); 350 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 351 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 352 | GCC_WARN_UNDECLARED_SELECTOR = YES; 353 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 354 | GCC_WARN_UNUSED_FUNCTION = YES; 355 | GCC_WARN_UNUSED_VARIABLE = YES; 356 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 357 | MTL_ENABLE_DEBUG_INFO = YES; 358 | ONLY_ACTIVE_ARCH = YES; 359 | SDKROOT = iphoneos; 360 | TARGETED_DEVICE_FAMILY = "1,2"; 361 | }; 362 | name = Debug; 363 | }; 364 | A944C1151BC16615005495AF /* Release */ = { 365 | isa = XCBuildConfiguration; 366 | buildSettings = { 367 | ALWAYS_SEARCH_USER_PATHS = NO; 368 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 369 | CLANG_CXX_LIBRARY = "libc++"; 370 | CLANG_ENABLE_MODULES = YES; 371 | CLANG_ENABLE_OBJC_ARC = YES; 372 | CLANG_WARN_BOOL_CONVERSION = YES; 373 | CLANG_WARN_CONSTANT_CONVERSION = YES; 374 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 375 | CLANG_WARN_EMPTY_BODY = YES; 376 | CLANG_WARN_ENUM_CONVERSION = YES; 377 | CLANG_WARN_INT_CONVERSION = YES; 378 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 379 | CLANG_WARN_UNREACHABLE_CODE = YES; 380 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 381 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 382 | COPY_PHASE_STRIP = NO; 383 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 384 | ENABLE_NS_ASSERTIONS = NO; 385 | ENABLE_STRICT_OBJC_MSGSEND = YES; 386 | GCC_C_LANGUAGE_STANDARD = gnu99; 387 | GCC_NO_COMMON_BLOCKS = YES; 388 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 389 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 390 | GCC_WARN_UNDECLARED_SELECTOR = YES; 391 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 392 | GCC_WARN_UNUSED_FUNCTION = YES; 393 | GCC_WARN_UNUSED_VARIABLE = YES; 394 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 395 | MTL_ENABLE_DEBUG_INFO = NO; 396 | SDKROOT = iphoneos; 397 | TARGETED_DEVICE_FAMILY = "1,2"; 398 | VALIDATE_PRODUCT = YES; 399 | }; 400 | name = Release; 401 | }; 402 | A944C1171BC16615005495AF /* Debug */ = { 403 | isa = XCBuildConfiguration; 404 | buildSettings = { 405 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 406 | INFOPLIST_FILE = MarkNoteParserOC/Info.plist; 407 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 408 | PRODUCT_BUNDLE_IDENTIFIER = marknote.MarkNoteParserOC; 409 | PRODUCT_NAME = "$(TARGET_NAME)"; 410 | }; 411 | name = Debug; 412 | }; 413 | A944C1181BC16615005495AF /* Release */ = { 414 | isa = XCBuildConfiguration; 415 | buildSettings = { 416 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 417 | INFOPLIST_FILE = MarkNoteParserOC/Info.plist; 418 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 419 | PRODUCT_BUNDLE_IDENTIFIER = marknote.MarkNoteParserOC; 420 | PRODUCT_NAME = "$(TARGET_NAME)"; 421 | }; 422 | name = Release; 423 | }; 424 | A944C11A1BC16615005495AF /* Debug */ = { 425 | isa = XCBuildConfiguration; 426 | buildSettings = { 427 | BUNDLE_LOADER = "$(TEST_HOST)"; 428 | INFOPLIST_FILE = MarkNoteParserOCTests/Info.plist; 429 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 430 | PRODUCT_BUNDLE_IDENTIFIER = marknote.MarkNoteParserOCTests; 431 | PRODUCT_NAME = "$(TARGET_NAME)"; 432 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MarkNoteParserOC.app/MarkNoteParserOC"; 433 | }; 434 | name = Debug; 435 | }; 436 | A944C11B1BC16615005495AF /* Release */ = { 437 | isa = XCBuildConfiguration; 438 | buildSettings = { 439 | BUNDLE_LOADER = "$(TEST_HOST)"; 440 | INFOPLIST_FILE = MarkNoteParserOCTests/Info.plist; 441 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 442 | PRODUCT_BUNDLE_IDENTIFIER = marknote.MarkNoteParserOCTests; 443 | PRODUCT_NAME = "$(TARGET_NAME)"; 444 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MarkNoteParserOC.app/MarkNoteParserOC"; 445 | }; 446 | name = Release; 447 | }; 448 | /* End XCBuildConfiguration section */ 449 | 450 | /* Begin XCConfigurationList section */ 451 | A944C0EF1BC16615005495AF /* Build configuration list for PBXProject "MarkNoteParserOC" */ = { 452 | isa = XCConfigurationList; 453 | buildConfigurations = ( 454 | A944C1141BC16615005495AF /* Debug */, 455 | A944C1151BC16615005495AF /* Release */, 456 | ); 457 | defaultConfigurationIsVisible = 0; 458 | defaultConfigurationName = Release; 459 | }; 460 | A944C1161BC16615005495AF /* Build configuration list for PBXNativeTarget "MarkNoteParserOC" */ = { 461 | isa = XCConfigurationList; 462 | buildConfigurations = ( 463 | A944C1171BC16615005495AF /* Debug */, 464 | A944C1181BC16615005495AF /* Release */, 465 | ); 466 | defaultConfigurationIsVisible = 0; 467 | }; 468 | A944C1191BC16615005495AF /* Build configuration list for PBXNativeTarget "MarkNoteParserOCTests" */ = { 469 | isa = XCConfigurationList; 470 | buildConfigurations = ( 471 | A944C11A1BC16615005495AF /* Debug */, 472 | A944C11B1BC16615005495AF /* Release */, 473 | ); 474 | defaultConfigurationIsVisible = 0; 475 | }; 476 | /* End XCConfigurationList section */ 477 | }; 478 | rootObject = A944C0EC1BC16615005495AF /* Project object */; 479 | } 480 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 4/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 4/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/ImageTag.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageTag.h 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 5/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "URLTag.h" 12 | 13 | @interface ImageTag : NSObject 14 | 15 | @property (nonatomic,strong) URLTag* url; 16 | @property (nonatomic,strong) NSString* alt; 17 | 18 | - (NSString*) toHtml ; 19 | 20 | 21 | 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/ImageTag.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageTag.m 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 5/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import "ImageTag.h" 10 | #import "URLTag.h" 11 | 12 | @implementation ImageTag 13 | 14 | - (NSString*) toHtml { 15 | if (self.url.title.length > 0 ){ 16 | return [NSString stringWithFormat: @"\"%@\"",self.url.url,self.alt, self.url.title]; 17 | } else { 18 | return [NSString stringWithFormat: @"\"%@\"",self.url.url,self.alt]; 19 | } 20 | 21 | } 22 | 23 | 24 | 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/LinkTag.h: -------------------------------------------------------------------------------- 1 | // 2 | // LinkTag.h 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 5/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "URLTag.h" 12 | 13 | @interface LinkTag : NSObject 14 | 15 | @property (nonatomic,strong) URLTag* url; 16 | @property (nonatomic,strong) NSString* text; 17 | 18 | - (NSString*) toHtml ; 19 | @end 20 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/LinkTag.m: -------------------------------------------------------------------------------- 1 | // 2 | // LinkTag.m 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 5/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import "LinkTag.h" 10 | 11 | @implementation LinkTag 12 | 13 | - (NSString*) toHtml { 14 | if (self.url.title.length > 0 ){ 15 | return [NSString stringWithFormat: @"%@", 16 | self.url.url, 17 | self.url.title, 18 | self.text ]; 19 | } else { 20 | return [NSString stringWithFormat:@"%@",self.url.url,self.text]; 21 | } 22 | 23 | } 24 | @end 25 | 26 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/MarkNoteParser.h: -------------------------------------------------------------------------------- 1 | // 2 | // MarkNoteParser.h 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 4/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "URLTag.h" 11 | #import "LinkTag.h" 12 | #import "ImageTag.h" 13 | #import "ReferenceDefinition.h" 14 | #import "ReferenceUsageInfo.h" 15 | 16 | 17 | 18 | 19 | @interface MarkNoteParser : NSObject{ 20 | BOOL bInTable; 21 | NSMutableString* _output; 22 | int nCurrentBulletLevel ; 23 | BOOL isInParagraph ; 24 | BOOL isAfterEmptyLine; 25 | NSMutableArray* tableColsAlignment ; 26 | 27 | NSMutableArray* blockEndTags; 28 | BOOL isCurrentLineNeedBr ; 29 | NSMutableArray* arrReferenceInfo ; 30 | NSMutableArray* arrReferenceUsage ; 31 | } 32 | 33 | @property (nonatomic,strong) NSMutableString* outputString; 34 | 35 | +(NSArray*)detectPositions:(NSArray *)toFind inStr:(NSString* )inStr; 36 | +(NSString*) toHtml:(NSString*)input; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/MarkNoteParser.m: -------------------------------------------------------------------------------- 1 | // 2 | // MarkNoteParser.m 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 4/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import "MarkNoteParser.h" 10 | #import "NSString+Addition.h" 11 | 12 | const unichar headerChar = '#'; 13 | 14 | 15 | 16 | 17 | 18 | @implementation MarkNoteParser 19 | @synthesize outputString = _output; 20 | 21 | -(id) init{ 22 | self = [super init]; 23 | 24 | bInTable = false; 25 | _output = [NSMutableString stringWithCapacity:0]; 26 | isInParagraph = false; 27 | isAfterEmptyLine = false; 28 | tableColsAlignment = [NSMutableArray array]; 29 | blockEndTags = [NSMutableArray array]; 30 | isCurrentLineNeedBr = false; 31 | arrReferenceInfo = [NSMutableArray array]; 32 | arrReferenceUsage = [NSMutableArray array]; 33 | return self; 34 | } 35 | 36 | 37 | 38 | +(NSString*) toHtml:(NSString*)input{ 39 | MarkNoteParser* instance = [[MarkNoteParser alloc]init]; 40 | //instance.output = "" 41 | [instance parse:input]; 42 | return instance.outputString; 43 | } 44 | 45 | 46 | -(void) parse :(NSString*)input{ 47 | //[self proceedHTMLTags:input]; 48 | [ self proceedCodeBlock:input]; 49 | [self proceedReference]; 50 | } 51 | 52 | 53 | -(void) proceedReference{ 54 | for (ReferenceUsageInfo* refer in arrReferenceUsage) { 55 | NSPredicate *predicte = [NSPredicate predicateWithFormat: 56 | @"key like [c] %@", refer.key.lowercaseString]; 57 | NSArray* hitted = [arrReferenceInfo filteredArrayUsingPredicate:predicte]; 58 | if (hitted.count > 0) { 59 | ReferenceDefinition* found = hitted[0]; 60 | NSString* actual = @""; 61 | switch (refer.type) { 62 | case Link: 63 | if (found.url.title.length > 0) { 64 | actual = [NSString stringWithFormat: @"%@",found.url.url,found.url.title,refer.title]; 65 | } else { 66 | actual = [NSString stringWithFormat: @"%@",found.url.url,refer.title]; 67 | 68 | } 69 | break; 70 | case Image: 71 | if (found.url.title.length > 0){ 72 | actual = [NSString stringWithFormat: @"\"%@\"",found.url.url,refer.title,found.url.title]; 73 | 74 | 75 | } else { 76 | actual = [NSString stringWithFormat: @"\"%@\"/",found.url.url,refer.title]; 77 | 78 | } 79 | break; 80 | } 81 | _output = [NSMutableString stringWithString: [_output stringByReplacingOccurrencesOfString:[refer placeHolder] withString:actual]]; 82 | 83 | } 84 | } 85 | } 86 | 87 | -(void) proceedCodeBlock:(NSString*)string{ 88 | 89 | 90 | int blockCount = 0; 91 | NSRange searchRange = NSMakeRange(0,string.length); 92 | NSString *codeTag = @"\n```"; 93 | NSRange foundRange; 94 | NSRange proceedRange; 95 | while (searchRange.location < string.length) { 96 | searchRange.length = string.length - searchRange.location; 97 | foundRange = [string rangeOfString:codeTag options:NSLiteralSearch range:searchRange]; 98 | if (foundRange.location != NSNotFound) { 99 | blockCount ++; 100 | // found an occurrence of the substring! do stuff here 101 | proceedRange = NSMakeRange(searchRange.location , foundRange.location - searchRange.location); 102 | 103 | //isInCodeBlock = !isInCodeBlock; // code block flag 104 | searchRange.location = foundRange.location + foundRange.length; 105 | 106 | } else { 107 | // no more substring to find 108 | //break; 109 | proceedRange = searchRange;//NSMakeRange(searchRange.location, foundRange.location); 110 | } 111 | // proceed contents before code 112 | if (blockCount % 2 == 1) { // code block just begins 113 | if(proceedRange.length >0 ){ 114 | [self proceedHTMLTags:[string substringWithRange:proceedRange]]; 115 | } 116 | NSString* cssClass = @"no-highlight"; 117 | 118 | if(searchRange.location < string.length) { 119 | NSRange rangeOfNewLine = [string rangeOfString:@"\n" options:NSLiteralSearch range: 120 | NSMakeRange(searchRange.location, string.length - searchRange.location) ] ; 121 | if (rangeOfNewLine.location != NSNotFound) { 122 | NSRange cssRange = NSMakeRange(searchRange.location , rangeOfNewLine.location - searchRange.location ); 123 | searchRange.location += cssRange.length; 124 | NSString *codeName = [[string substringWithRange:cssRange] trim]; 125 | if (codeName.length>0) { 126 | cssClass = [NSString stringWithFormat: @"prettyprint lang-%@",codeName]; 127 | } 128 | 129 | } 130 | } 131 | 132 | [_output appendFormat:@"
\n",cssClass];
133 |         } else { // code block ends
134 |             if (blockCount > 0 && foundRange.location != NSNotFound) {
135 |                 
136 |                 if(proceedRange.length >0 ){
137 |                     [_output appendString:
138 |                      [[[string substringWithRange:proceedRange] stringByReplacingOccurrencesOfString:@"<" withString:@"<"]
139 |                       stringByReplacingOccurrencesOfString:@">" withString:@">"]
140 |                      ];
141 |                 }
142 |                 
143 |                 [_output appendString:@"
\n"]; 144 | } else { 145 | if(proceedRange.length >0 ){ 146 | [self proceedHTMLTags:[string substringWithRange:proceedRange]]; 147 | } 148 | } 149 | } 150 | 151 | if (foundRange.location == NSNotFound) { 152 | break; 153 | } 154 | 155 | } 156 | 157 | 158 | } 159 | 160 | -(void) proceedHTMLTags:(NSString*)input{ 161 | NSUInteger currentPos = 0; 162 | NSUInteger tagBegin = [input indexOf:@"<"]; 163 | if (tagBegin !=NSNotFound) { 164 | if (tagBegin >= 1) { 165 | NSString* tmp = [input substringWithRange:NSMakeRange(currentPos, tagBegin - currentPos)]; 166 | [self proceedNoHtml:tmp]; 167 | 168 | } 169 | //currentPos = tagBegin 170 | if (tagBegin < input.length - 1) { 171 | NSString* left = [input substringWithRange:NSMakeRange(tagBegin, input.length - tagBegin)]; 172 | 173 | NSUInteger endTag = [left indexOf:@">"]; 174 | if (endTag != NSNotFound) { 175 | // found 176 | if ([left characterAtIndex: endTag - 1] == '/') { 177 | //auto close: 178 | [_output appendString: [left substringToIndex: endTag + 1]]; 179 | if (endTag < left.length - 2 ){ 180 | [self proceedHTMLTags:[left substringFromIndex: endTag + 1 ]]; 181 | } 182 | } else { 183 | // there is a close tag 184 | currentPos = endTag; 185 | if (endTag <= left.length - 1) { 186 | left = [left substringFromIndex: endTag + 1 ]; 187 | endTag = [left indexOf:@">"]; 188 | if (endTag !=NSNotFound ){ 189 | [_output appendString:[ input substringWithRange:NSMakeRange(tagBegin, endTag + currentPos + 2)]]; 190 | //substring(tagBegin, end: tagBegin + endTag + currentPos + 1) //+ 191 | if (endTag < left.length - 1) { 192 | left = [left substringFromIndex:endTag + 1 ]; 193 | //.substringFromIndex(left.startIndex.advancedBy( endTag + 1 )) 194 | [self proceedHTMLTags:left]; 195 | return; 196 | } 197 | } else { 198 | [self proceedNoHtml:input]; 199 | return; 200 | } 201 | } else { 202 | [_output appendString: input]; 203 | return; 204 | } 205 | } 206 | }else { 207 | // not found 208 | [self proceedNoHtml:left]; 209 | } 210 | } 211 | }else { 212 | [self proceedNoHtml:input]; 213 | } 214 | } 215 | -(void) proceedNoHtml:(NSString*)input{ 216 | 217 | //NSArray* lines = [input componentsSeparatedByString:@"\n" ]; 218 | NSString* preProceeded = [input stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"]; 219 | preProceeded = [preProceeded stringByReplacingOccurrencesOfString:@"\n" withString:@" \n"]; 220 | 221 | NSArray* lines = [preProceeded componentsSeparatedByString:@"\n" ]; 222 | //for rawline in lines { 223 | for (int i = 0; i < lines.count; i++){ 224 | isCurrentLineNeedBr = true; 225 | 226 | NSString* line = [lines[i] trim]; 227 | 228 | 229 | if (bInTable && line.length > 0) { 230 | [self handleTableLine:line isHead:false]; 231 | } else { 232 | // not in block 233 | if (line.length == 0) { 234 | // empty line 235 | [self closeTags]; 236 | [self closeParagraph]; 237 | [self closeTable]; 238 | isAfterEmptyLine = true; 239 | isCurrentLineNeedBr = false; 240 | continue; 241 | }else { 242 | isAfterEmptyLine = false; 243 | } 244 | 245 | if ([line indexOf:@"- "] == 0 246 | || [line indexOf:@"* "] == 0 247 | || [line indexOf:@"+ "] == 0 ){ 248 | if (nCurrentBulletLevel == 0 ){ 249 | [_output appendString:@"
    \n"]; 250 | [blockEndTags addObject:@"
\n"]; 251 | nCurrentBulletLevel = 1; 252 | isCurrentLineNeedBr = false; 253 | 254 | } 255 | [_output appendString:@"
  • "]; 256 | NSString* newline = [line substringWithRange:NSMakeRange(@"- ".length, line.length - @"- ".length)]; 257 | //.substring("- ".length, end: line.length - 1) 258 | [self handleLine:newline]; 259 | [_output appendString:@"
  • \n"]; 260 | continue; 261 | } else { 262 | if (nCurrentBulletLevel > 0) { 263 | nCurrentBulletLevel = 0; 264 | [_output appendString:@"\n"]; 265 | } 266 | } 267 | 268 | 269 | 270 | if (i + 1 <= lines.count - 1) { 271 | NSString* nextLine = [lines[i + 1] trim]; 272 | if ([nextLine contains3PlusandOnlyChars:@"="]){ 273 | [_output appendFormat: @"

    %@

    \n",line ]; 274 | i++; 275 | continue; 276 | } else if ([nextLine contains3PlusandOnlyChars:@"-"]){ 277 | [_output appendFormat: @"

    %@

    \n",line ]; 278 | i++; 279 | continue; 280 | } else if ( [nextLine indexOf:@"|"] != NSNotFound 281 | && [line indexOf:@"|"] != NSNotFound 282 | && [[[[nextLine stringByReplacingOccurrencesOfString:@"|" withString:@""] stringByReplacingOccurrencesOfString:@"-" withString:@""] 283 | stringByReplacingOccurrencesOfString:@":" withString:@""] 284 | stringByReplacingOccurrencesOfString:@" " withString:@""].length ==0 ) 285 | 286 | 287 | { 288 | 289 | [self beginTable:nextLine]; 290 | [self handleTableLine:line isHead:true]; 291 | i++; 292 | continue; 293 | } 294 | } 295 | 296 | 297 | [self handleLine:line]; 298 | if (isCurrentLineNeedBr 299 | && lines.count > 1 300 | && lines[i].length > 2 301 | 302 | && [[lines[i] substringFromIndex:lines[i].length - 2] isEqualToString:@" "] ){ 303 | [_output appendString:@"
    "]; 304 | } 305 | 306 | //output += "

    " 307 | } 308 | }//end for 309 | [self closeTags]; 310 | [self closeParagraph]; 311 | 312 | } 313 | 314 | 315 | 316 | 317 | 318 | -(void) parseInLine:(NSString*)line { 319 | int len = (int)line.length; 320 | //int start = 0; 321 | for (int i = 0; i < len && i>=0 ; i++) { 322 | 323 | unichar ch = [line characterAtIndex:i]; 324 | 325 | switch (ch) { 326 | case '*': 327 | case '_': 328 | case '~': 329 | { 330 | if (i + 1 > len - 1) { 331 | [_output appendFormat:@"%c", ch]; 332 | return; 333 | } 334 | NSString* strong = @"strong"; 335 | if (ch == '~') { 336 | strong = @"del"; 337 | } 338 | if ([line characterAtIndex:i + 1] == ch) { 339 | //possible ** 340 | NSString* remaining = [line substringFromIndex: i + 2]; 341 | i += [self scanClosedChar: [MarkNoteParser charArray:ch len: 2] 342 | inStr: remaining 343 | tag: strong] + 1; 344 | } else { 345 | NSString* remaining = [line substringFromIndex: i + 1]; 346 | i += [self scanClosedChar: [NSString stringWithFormat:@"%c",ch ] 347 | inStr:remaining 348 | tag: @"em"] ; 349 | } 350 | } 351 | break; 352 | case '`': 353 | {NSString* remaining = [line substringFromIndex: i + 1]; 354 | i += [self scanClosedChar:@"`" 355 | inStr: remaining 356 | tag: @"code"]; 357 | isCurrentLineNeedBr = false;} 358 | break; 359 | 360 | case '!': 361 | { 362 | 363 | if (i >= line.length - 1 || [line characterAtIndex: i + 1] != '[') { 364 | 365 | [_output appendFormat:@"%c", ch]; 366 | continue; 367 | } 368 | i++; 369 | NSString* remaining = [line substringFromIndex: i + 1]; 370 | NSArray* posArray = [MarkNoteParser detectPositions:@[@"]",@"(",@")"] inStr: remaining]; 371 | if (posArray.count == 3) { 372 | ImageTag* img = [[ImageTag alloc] init]; 373 | img.alt = [line substringWithRange:NSMakeRange(i + 1, posArray[0].intValue )]; 374 | URLTag* urlTag = [[URLTag alloc]init]; 375 | urlTag.url = [line substringWithRange:NSMakeRange(i + 1 + posArray[1].intValue + 1, posArray[2].intValue - posArray[1].intValue -1)]; 376 | //line.substring( i + 1 + posArray[1] + 1, end: i + 1 + posArray[2] - 1) 377 | img.url = urlTag; 378 | [_output appendString: [img toHtml]]; 379 | i += posArray[2].intValue + 1; 380 | }else { 381 | // check image reference defintion 382 | NSArray* posArray2 = [MarkNoteParser detectPositions:@[@"]",@"[",@"]"] 383 | inStr: remaining]; 384 | if (posArray2.count == 3) { 385 | //is reference usage 386 | NSString* title = [line substringWithRange:NSMakeRange(i + 1, posArray2[0].intValue)]; 387 | 388 | NSString* url = [line substringWithRange:NSMakeRange(i + 1 + posArray2[1].intValue + 1, posArray2[2].intValue - posArray2[1].intValue -1)]; 389 | //.substring( i + 1 + posArray2[1] + 1, end: i + 1 + posArray2[2] - 1) 390 | ReferenceUsageInfo* refer = [[ReferenceUsageInfo alloc] init]; 391 | refer.type = Image; 392 | refer.key = url.lowercaseString; 393 | refer.title = title; 394 | [arrReferenceUsage addObject:refer]; 395 | 396 | [_output appendString: [refer placeHolder]]; 397 | i += posArray2[2].intValue + 1 + 1; 398 | } 399 | } 400 | } 401 | break; 402 | 403 | case '[': 404 | { 405 | NSString* remaining = [line substringFromIndex: i + 1]; 406 | NSArray* posArray = [MarkNoteParser detectPositions:@[@"]",@"(",@")"] 407 | inStr: remaining]; 408 | if (posArray.count == 3) { 409 | LinkTag* link = [[LinkTag alloc] init]; 410 | link.text = [line substringWithRange:NSMakeRange(i + 1, posArray[0].intValue) ]; 411 | //.substring(i + 1, end: i + 1 + posArray[0] - 1) 412 | NSString* surl = [line substringWithRange: NSMakeRange(i + 1 + posArray[1].intValue + 1, posArray[2].intValue - posArray[1].intValue - 1 )]; 413 | URLTag* urlTag = [[URLTag alloc] initWithString:surl]; 414 | 415 | link.url = urlTag; 416 | [_output appendString: [link toHtml] ]; 417 | i += posArray[2].intValue + 1; 418 | }else { 419 | // check reference defintion 420 | NSUInteger pos = [remaining indexOf:@"]:"]; 421 | if (pos != NSNotFound && pos < remaining.length - @"]:".length) { 422 | // is reference definition 423 | ReferenceDefinition* info = [ReferenceDefinition new]; 424 | info.key = [remaining substringToIndex:pos]; 425 | //.substringToIndex(remaining.startIndex.advancedBy( pos )) 426 | NSString* remaining2 = [remaining substringFromIndex: pos + @"]:".length ]; 427 | URLTag* urlTag = [[URLTag alloc] initWithString:remaining2]; 428 | info.url = urlTag; 429 | 430 | [arrReferenceInfo addObject:info]; 431 | i += pos + @"]:".length + remaining2.length; 432 | } else { 433 | NSArray* posArray2 = [MarkNoteParser detectPositions:@[@"]",@"[",@"]"] 434 | inStr: remaining]; 435 | if (posArray2.count == 3) { 436 | //is reference usage 437 | NSString* title = [line substringWithRange:NSMakeRange(i + 1, posArray2[0].intValue)]; 438 | 439 | NSString* url = [line substringWithRange:NSMakeRange(i + 1 + posArray2[1].intValue + 1, posArray2[2].intValue - posArray2[1].intValue -1 )]; 440 | 441 | ReferenceUsageInfo* refer = [ReferenceUsageInfo new]; 442 | refer.type = Link; 443 | refer.key = url.lowercaseString; 444 | refer.title = title; 445 | [arrReferenceUsage addObject: refer]; 446 | [_output appendString: [refer placeHolder]]; 447 | i += pos + posArray2[2].intValue + 1 + 1; 448 | } 449 | } 450 | } 451 | } 452 | break; 453 | case '\"': 454 | [_output appendString:@"""]; 455 | break; 456 | default: 457 | //do nothing 458 | [_output appendFormat:@"%C", ch]; 459 | } 460 | } 461 | } 462 | 463 | 464 | -(void) handleLine:(NSString*)rawline { 465 | 466 | if ([rawline contains3PlusandOnlyChars:@"-"] 467 | || [rawline contains3PlusandOnlyChars:@"*"] 468 | || [rawline contains3PlusandOnlyChars:@"_"]){ 469 | [self closeParagraph]; 470 | [_output appendString:@"
    \n"]; 471 | return; 472 | } 473 | NSString* line = rawline; 474 | NSMutableArray* endTags = [NSMutableArray array]; 475 | 476 | int pos = 0; 477 | 478 | if ([line characterAtIndex:0] == '>') { 479 | [_output appendString:@"
    "]; 480 | line = [line substringFromIndex:1]; 481 | [endTags addObject:@"
    "]; 482 | } 483 | 484 | int nFindHead = [self calculateHeadLevel:line]; 485 | if (nFindHead > 0) { 486 | isCurrentLineNeedBr = false; 487 | 488 | [_output appendFormat:@"",nFindHead]; 489 | [endTags addObject: [NSString stringWithFormat: @"",nFindHead]]; 490 | pos += nFindHead; 491 | } else { 492 | [self beginParagraph]; 493 | } 494 | 495 | //line = this.handleImage(line, sb) 496 | 497 | NSString* remaining = [[line substringFromIndex:pos] trim]; 498 | [self parseInLine:remaining]; 499 | //output += "\n" 500 | 501 | for (int i = (int)(endTags.count) - 1; i >= 0; i--) { 502 | [_output appendString: endTags[i]]; 503 | } 504 | 505 | //output += "\n" 506 | 507 | } 508 | 509 | 510 | -(void) handleTableLine:(NSString*)rawline isHead:(BOOL)isHead { 511 | if ([rawline characterAtIndex:rawline.length-1] == '|'){ 512 | rawline = [rawline substringToIndex:rawline.length-1]; 513 | } 514 | if ([rawline characterAtIndex:0] == '|'){ 515 | rawline = [rawline substringFromIndex:1]; 516 | } 517 | NSArray* cols = [rawline componentsSeparatedByString:@"|"]; 518 | 519 | [_output appendString:@""]; 520 | int i = 0; 521 | 522 | for(NSString* col in cols) { 523 | NSString* colAlign = tableColsAlignment[i]; 524 | 525 | if (isHead) { 526 | NSString* colAlighStr = [NSString stringWithFormat:@"",colAlign ]; 527 | [_output appendString: colAlign.length > 0 ? colAlighStr : @""]; 528 | [self parseInLine:col]; 529 | [_output appendString:@""]; 530 | } else { 531 | NSString* colAlighStr = [NSString stringWithFormat:@"",colAlign ]; 532 | [_output appendString:colAlign.length > 0 ? colAlighStr : @""]; 533 | [self parseInLine:col]; 534 | 535 | [_output appendString:@""]; 536 | } 537 | i++; 538 | } 539 | [_output appendString:@""]; 540 | } 541 | 542 | -(void) beginTable:(NSString*)alignmentLine{ 543 | if (!bInTable ){ 544 | bInTable = true; 545 | [_output appendString:@""]; 546 | [tableColsAlignment removeAllObjects]; 547 | NSArray * arr = [[alignmentLine trim] componentsSeparatedByString:@"|"]; 548 | for (NSString* col in arr) { 549 | if ([col indexOf:@":-"] != NSNotFound && [col indexOf:@"-:"] != NSNotFound ){ 550 | [tableColsAlignment addObject:@"style=\"text-align: center;\""]; 551 | }else if ([col indexOf:@"-:"] != NSNotFound){ 552 | [tableColsAlignment addObject:@"style=\"text-align: right;\""]; 553 | }else { 554 | [tableColsAlignment addObject:@"" ]; 555 | } 556 | } 557 | } 558 | } 559 | 560 | 561 | -(int) calculateHeadLevel:(NSString*)line{ 562 | int nFindHead = 0; 563 | //int pos = 0; 564 | for (int i = 0; i <= 6 && i < [line length]; i++ ){ 565 | //pos = i ; 566 | if ([line characterAtIndex:i]== headerChar) { 567 | nFindHead = i + 1; 568 | } else { 569 | break; 570 | } 571 | } 572 | return nFindHead; 573 | } 574 | 575 | -(void) closeTags{ 576 | for (int i = (int)blockEndTags.count - 1; i >= 0; i--) { 577 | [_output appendString: blockEndTags[i]]; 578 | //blockEndTags.removeAtIndex(i) 579 | } 580 | //blockEndTags.removeAll(keepCapacity: false) 581 | [blockEndTags removeAllObjects]; 582 | } 583 | 584 | -(void) closeParagraph{ 585 | if (isInParagraph) { 586 | isInParagraph = false; 587 | [_output appendString: @"

    \n"]; 588 | } 589 | } 590 | 591 | -(void) beginParagraph{ 592 | if (!isInParagraph) { 593 | isInParagraph = true; 594 | [_output appendString: @"

    "]; 595 | } 596 | } 597 | 598 | 599 | -(void) closeTable{ 600 | if (bInTable) { 601 | bInTable = false; 602 | [_output appendString: @"

    "]; 603 | } 604 | } 605 | 606 | -(NSUInteger) scanClosedChar:(NSString*)ch inStr:(NSString*)inStr tag:(NSString*)tag { 607 | NSUInteger pos = [inStr indexOf:ch]; 608 | if (pos != NSNotFound) { 609 | NSString* temp = [inStr substringToIndex:pos]; 610 | [_output appendFormat:@"<%@>%@", 611 | tag, 612 | temp, 613 | tag]; 614 | return pos + ch.length; 615 | } else { 616 | [_output appendString:ch]; 617 | return ch.length - 1; 618 | } 619 | 620 | } 621 | 622 | 623 | +(NSString*) charArray:(unichar)ch len:(int)len{ 624 | NSMutableString* sb = [[NSMutableString alloc] init]; 625 | for (int i = 0 ; i < len ; i++) { 626 | [sb appendFormat:@"%c",ch]; 627 | } 628 | NSString* result = [NSString stringWithString:sb]; 629 | [sb setString: @""]; 630 | return result; 631 | } 632 | 633 | +(NSArray*)detectPositions:(NSArray *)toFind inStr:(NSString* )inStr{ 634 | NSMutableArray* posArray = [NSMutableArray array];// [Int]() 635 | NSUInteger count = toFind.count; 636 | int lastPos = 0; 637 | for (int i = 0; i < count ; i++){ 638 | NSUInteger pos = [[inStr substringFromIndex:lastPos] indexOf:toFind[i]]; 639 | 640 | if (pos != NSNotFound) { 641 | lastPos += pos; 642 | [posArray addObject:[NSNumber numberWithInt:lastPos] ]; 643 | // [posArray append:lastPos]; 644 | }else { 645 | return posArray; 646 | } 647 | } 648 | return posArray; 649 | } 650 | 651 | 652 | 653 | @end 654 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/NSString+Addition.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Addition.h 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 4/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSString(Addition) 12 | 13 | -(NSString*)trim; 14 | -(NSUInteger) indexOf:(NSString*) toFind; 15 | -(BOOL) contains3PlusandOnlyChars:(NSString*) ch; 16 | 17 | @end 18 | 19 | 20 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/NSString+Addition.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Addition.m 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 4/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import "NSString+Addition.h" 10 | 11 | @implementation NSString(Addition) 12 | 13 | -(NSString*)trim{ 14 | 15 | NSString *trimmedString = [self stringByTrimmingCharactersInSet: 16 | [NSCharacterSet whitespaceAndNewlineCharacterSet]]; 17 | return trimmedString; 18 | } 19 | 20 | -(NSUInteger) indexOf:(NSString*) toFind{ 21 | return [self rangeOfString:toFind].location; 22 | } 23 | 24 | -(BOOL) contains3PlusandOnlyChars:(NSString*) ch{ 25 | return (self.length >= 3 26 | && [self indexOf:ch] == 0 27 | && [self stringByReplacingOccurrencesOfString:ch withString:@""].length == 0); 28 | } 29 | 30 | 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/ReferenceDefinition.h: -------------------------------------------------------------------------------- 1 | // 2 | // ReferenceDefinition.h 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 5/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "URLTag.h" 11 | 12 | @interface ReferenceDefinition : NSObject 13 | 14 | @property (nonatomic,strong) URLTag* url; 15 | @property (nonatomic,strong) NSString* key; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/ReferenceDefinition.m: -------------------------------------------------------------------------------- 1 | // 2 | // ReferenceDefinition.m 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 5/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import "ReferenceDefinition.h" 10 | 11 | @implementation ReferenceDefinition 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/ReferenceUsageInfo.h: -------------------------------------------------------------------------------- 1 | // 2 | // ReferenceUsageInfo.h 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 5/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "URLTag.h" 11 | 12 | @interface ReferenceUsageInfo : NSObject 13 | 14 | 15 | @property (nonatomic,strong) NSString* title; 16 | @property (nonatomic,strong) NSString* key; 17 | @property (nonatomic,assign) ReferenceType type; 18 | 19 | 20 | - (NSString*) placeHolder ; 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/ReferenceUsageInfo.m: -------------------------------------------------------------------------------- 1 | // 2 | // ReferenceUsageInfo.m 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 5/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import "ReferenceUsageInfo.h" 10 | 11 | @implementation ReferenceUsageInfo 12 | 13 | 14 | - (NSString*) placeHolder { 15 | return [NSString stringWithFormat: @"ReferenceUsageInfo%@%@",self.key,self.title ]; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/URLTag.h: -------------------------------------------------------------------------------- 1 | // 2 | // URLTag.h 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 4/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef enum {Link, Image} ReferenceType; 12 | 13 | @interface URLTag : NSObject 14 | 15 | @property (nonatomic,strong) NSString* url; 16 | @property (nonatomic,strong) NSString* title; 17 | 18 | -(id)initWithString:(NSString*) surl; 19 | 20 | @end 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/URLTag.m: -------------------------------------------------------------------------------- 1 | // 2 | // URLTag.m 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 4/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import "URLTag.h" 10 | #import "NSString+Addition.h" 11 | 12 | @implementation URLTag 13 | 14 | -(id)initWithString:(NSString*) surl{ 15 | 16 | self = [super init]; 17 | if (self) { 18 | self.title = @""; 19 | self.url = @""; 20 | NSString* trimmed = [surl trim]; 21 | NSArray *arr = [trimmed componentsSeparatedByString:@" "]; 22 | if (arr.count > 1) { 23 | self.url = arr[0].lowercaseString; 24 | self.title = [arr[1] stringByReplacingOccurrencesOfString:@"\"" withString:@""]; 25 | 26 | } else { 27 | self.url = arr[0].lowercaseString; 28 | } 29 | } 30 | return self; 31 | 32 | 33 | } 34 | 35 | 36 | -(NSString*) description{ 37 | return self.url; 38 | } 39 | @end 40 | 41 | 42 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 4/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 4/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view, typically from a nib. 20 | } 21 | 22 | - (void)didReceiveMemoryWarning { 23 | [super didReceiveMemoryWarning]; 24 | // Dispose of any resources that can be recreated. 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOC/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 4/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOCTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOCTests/MarkNoteParserOCTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // MarkNoteParserOCTests.m 3 | // MarkNoteParserOCTests 4 | // 5 | // Created by marknote on 4/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "MarkNoteParser.h" 12 | 13 | #define let NSString* 14 | 15 | #define assertHtmlEauql(expected, actual) ( XCTAssertEqualObjects( ignorNewline(expected ),ignorNewline(actual))) 16 | 17 | @interface MarkNoteParserOCTests : XCTestCase 18 | //- (void) htmlEquals:(NSString*) expected ,(NSString*) actual; 19 | @end 20 | 21 | @implementation MarkNoteParserOCTests 22 | 23 | 24 | 25 | - (void)setUp { 26 | [super setUp]; 27 | // Put setup code here. This method is called before the invocation of each test method in the class. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | NSString* ignorNewline(NSString* input){ 36 | 37 | return [[[input stringByReplacingOccurrencesOfString:@"\n" withString:@"" ] stringByReplacingOccurrencesOfString:@"\r" withString:@""]stringByReplacingOccurrencesOfString:@" " withString:@""]; 38 | } 39 | 40 | NSString* markdown(NSString* input){ 41 | NSString* result = [MarkNoteParser toHtml:input]; 42 | return result; 43 | } 44 | 45 | - (void) testHeading { 46 | assertHtmlEauql(@"

    Hello

    ",markdown(@"# Hello")); 47 | assertHtmlEauql(@"

    Hello

    " ,markdown(@"## Hello")); 48 | assertHtmlEauql(@"

    Hello

    " ,markdown(@"### Hello")); 49 | assertHtmlEauql(@"

    Hello

    " ,markdown(@"#### Hello")); 50 | assertHtmlEauql(@"
    Hello
    " ,markdown(@"##### Hello")); 51 | assertHtmlEauql(@"
    Hello
    " ,markdown(@"###### Hello")); 52 | } 53 | 54 | - (void) testUTF8Heading{ 55 | assertHtmlEauql(@"

    Markdown 快速参考

    " ,markdown(@"# Markdown 快速参考")); 56 | } 57 | 58 | - (void) testFencedCode { 59 | assertHtmlEauql(@"
    println(\"Hello\")\n
    \n" ,markdown(@"\n```swift\nprintln(\"Hello\")\n```")); 60 | } 61 | 62 | - (void) testFencedCodeHTML { 63 | assertHtmlEauql(@"
    code
    \n" ,markdown(@"\n```\n
    code
    \n```\n")); 64 | } 65 | 66 | - (void) testInLineCode { 67 | NSString *act = markdown(@"I like `swift`"); 68 | NSString *exp = @"

    I like swift\n

    "; 69 | assertHtmlEauql( exp , act); 70 | 71 | 72 | } 73 | 74 | - (void) testDefLinks { 75 | assertHtmlEauql(@"

    Title

    " , markdown(@"[Title][Google]\n [Google]:www.google.com\n")); 76 | assertHtmlEauql(@"

    text

    " , markdown(@"[text][Google]\n[Google]:www.google.com \"GoogleSearch\"\n")); 77 | } 78 | 79 | - (void) testDefImages { 80 | assertHtmlEauql(@"

    \"Title\"/

    ", markdown(@"![Title][image]\n [image]:aaa\n")); 81 | assertHtmlEauql(@"

    \"text\"

    " , markdown(@"![text][image]\n[image]:aaa \"TTTT\"\n")); 82 | assertHtmlEauql(@"

    \"alt

    " , markdown(@"![alt text][logo]\n[logo]: icon48.png \"Logo Title Text\"")); 83 | } 84 | 85 | 86 | 87 | - (void) testInlineLinks { 88 | assertHtmlEauql(@"

    Google

    \n" , markdown(@"[Google](www.google.com)")); 89 | assertHtmlEauql(@"

    Google

    \n" , markdown(@"[Google](www.google.com \"googlehome\")")); 90 | 91 | } 92 | 93 | - (void)testInlineImages { 94 | assertHtmlEauql(@"

    \"abc\"

    \n" , markdown(@"![abc](url)")); 95 | 96 | } 97 | 98 | - (void) testInlineImages2 { 99 | assertHtmlEauql(@"

    !\"abc\"

    \n" , markdown(@"!![abc](url)")); 100 | 101 | } 102 | - (void) testHRule { 103 | assertHtmlEauql(@"
    \n" ,markdown(@"-----")); 104 | assertHtmlEauql(@"
    \n" ,markdown(@"***")); 105 | assertHtmlEauql(@"
    \n" ,markdown(@"___")); 106 | } 107 | - (void) testLHeading { 108 | assertHtmlEauql(@"

    Hello

    \n", markdown(@"Hello\n=====")); 109 | assertHtmlEauql(@"

    Hello

    \n" ,markdown(@"Hello\n-----")); 110 | } 111 | 112 | - (void) testBlockQuote { 113 | assertHtmlEauql(@"

    Hello

    " ,markdown(@">### Hello")); 114 | } 115 | 116 | - (void)testInlineCode { 117 | assertHtmlEauql(@"

    Hello

    \n" ,markdown(@"`Hello`\n")); 118 | } 119 | 120 | - (void)testBlockCode { 121 | assertHtmlEauql(@"
    \r\nHello\r\n
    \n" ,markdown(@"\n``` \r\nHello\r\n```\n")); 122 | } 123 | 124 | - (void) testDoubleEmphasis{ 125 | assertHtmlEauql(@"

    Hello

    \n" ,markdown(@"**Hello**")); 126 | assertHtmlEauql(@"

    World

    \n" ,markdown(@"__World__")); 127 | assertHtmlEauql(@"

    Hello

    \n" ,markdown(@"~~Hello~~")); 128 | 129 | } 130 | - (void) testDoubleEmphasis2 { 131 | assertHtmlEauql(@"

    123Hello456

    \n" ,markdown(@"123**Hello**456")); 132 | assertHtmlEauql(@"

    123World456

    \n" ,markdown(@"123__World__456")); 133 | } 134 | 135 | - (void)testEmphasis { 136 | assertHtmlEauql(@"

    a * abc

    " ,markdown(@"a * abc")); 137 | assertHtmlEauql(@"

    Hello

    \n" ,markdown(@"*Hello*")); 138 | assertHtmlEauql(@"

    World

    \n" ,markdown(@"_World_")); 139 | assertHtmlEauql(@"

    123Hello456

    \n" ,markdown(@"123*Hello*456")); 140 | assertHtmlEauql(@"

    123World456

    \n" ,markdown(@"123_World_456")); 141 | assertHtmlEauql(@"

    123Hello456123world456

    \n" ,markdown(@"123*Hello*456123*world*456")); 142 | assertHtmlEauql(@"

    123World456123world456

    \n" ,markdown(@"123_World_456123*world*456")); 143 | 144 | //assertHtmlEauql(@"

    在前后各加一个 或者 _, 即可实现 斜体*。

    " ,markdown(@"在前后各加一个 * 或者 _, 即可实现 *斜体* 。")); 145 | } 146 | 147 | - (void) testBulletList 148 | { 149 | let input = @"A bulleted list:\n- a\n- b\n- c\n"; 150 | let expected = @"

    A bulleted list:

    • a
    • b
    • c

    "; 151 | let actual = markdown(input); 152 | assertHtmlEauql(expected ,actual); 153 | } 154 | 155 | 156 | 157 | 158 | - (void) testHTMLTag{ 159 | 160 | let input = @""; 161 | let expected = @""; 162 | let actual = markdown(input); 163 | assertHtmlEauql(expected ,actual); 164 | } 165 | 166 | - (void) testMixedHTMLTag{ 167 | 168 | let input = @"\n## Inline HTML\nYou can also use raw HTML in your Markdown"; 169 | let expected = @"

    Inline HTML

    You can also use raw HTML in your Markdown

    "; 170 | let actual = markdown(input); 171 | assertHtmlEauql(expected ,actual); 172 | } 173 | 174 | - (void) testHTMLTag2{ 175 | 176 | let input = @"111
    123222"; 177 | let expected = @"

    111

    123

    222

    "; 178 | let actual = markdown(input); 179 | assertHtmlEauql(expected ,actual); 180 | } 181 | 182 | 183 | - (void) testEmbeddedHTML{ 184 | let input = @"Don't modify this note. Your changes will be overrided."; 185 | let expected = @"Don't modify this note. Your changes will be overrided."; 186 | let actual = markdown(input); 187 | assertHtmlEauql(expected ,actual); 188 | 189 | } 190 | 191 | - (void) testHTMLInCode{ 192 | 193 | let input = @"\n```\n<html>\n```\n"; 194 | let expected = @"
    <html>
    "; 195 | let actual = markdown(input); 196 | assertHtmlEauql(expected ,actual); 197 | } 198 | 199 | - (void) testNewLine{ 200 | 201 | let input = @"abc \n123"; 202 | let expected = @"

    abc
    123

    "; 203 | let actual = markdown(input); 204 | assertHtmlEauql(expected ,actual); 205 | } 206 | 207 | 208 | 209 | 210 | - (void) testTable{ 211 | 212 | let input = @"|a|b|c|\n|------|-----|-----|\n|1|2|3|\n\n\n"; 213 | let expected = @"
    abc
    123
    "; 214 | let actual = markdown(input); 215 | assertHtmlEauql(expected ,actual); 216 | } 217 | 218 | - (void) testTableWithoutOuterPipe{ 219 | 220 | NSString* input = @"a|b|c\n------|-----|-----\n1|2|3\n\n\n"; 221 | NSString* expected = @"
    abc
    123
    "; 222 | NSString* actual = markdown(input); 223 | assertHtmlEauql(expected ,actual); 224 | } 225 | 226 | - (void) testTableWithColumnAignment{ 227 | 228 | NSString* input = @"a|b|c\n------|:-----:|-----:\n1|2|3\n\n\n"; 229 | NSString* expected = @"
    abc
    123
    "; 230 | NSString* actual = markdown(input); 231 | assertHtmlEauql(expected ,actual); 232 | } 233 | 234 | 235 | 236 | 237 | 238 | - (void) testDetectPositions { 239 | NSArray* expected = @[[NSNumber numberWithInt: 1], 240 | [NSNumber numberWithInt: 2], 241 | [NSNumber numberWithInt: 3]]; 242 | NSArray* actual = [MarkNoteParser detectPositions:@[@"1",@"2",@"3"] inStr:@"0123"]; 243 | XCTAssertEqualObjects(expected, actual); 244 | 245 | } 246 | 247 | - (void)testDetectPositions2{ 248 | 249 | NSArray* expected = @[[NSNumber numberWithInt: 2], 250 | [NSNumber numberWithInt: 4], 251 | [NSNumber numberWithInt: 5]]; 252 | NSArray* actual = [MarkNoteParser detectPositions:@[@"2",@"4",@"5"] inStr:@"012345"]; 253 | XCTAssertEqualObjects(expected, actual); 254 | 255 | 256 | } 257 | 258 | 259 | 260 | 261 | 262 | @end 263 | -------------------------------------------------------------------------------- /MarkNoteParserOC/MarkNoteParserOCTests/NSStringAdditionTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSStringAdditionTests.m 3 | // MarkNoteParserOC 4 | // 5 | // Created by marknote on 4/10/15. 6 | // Copyright © 2015 marknote. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NSString+Addition.h" 11 | 12 | @interface NSStringAdditionTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation NSStringAdditionTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | -(void) testTrim{ 29 | NSString* string = @" this text has spaces before and after "; 30 | NSString* actual = [string trim]; 31 | XCTAssertEqualObjects(@"this text has spaces before and after", actual); 32 | 33 | } 34 | 35 | -(void) testSplitEmptyLiens{ 36 | NSArray* expectedArr = @[@"1",@"",@"3"]; 37 | XCTAssertEqualObjects(expectedArr,[@"1\n\n3" componentsSeparatedByString:@"\n"]); 38 | expectedArr = @[@"A bulleted list:",@"- a",@"- b",@"- c",@""]; 39 | XCTAssertEqualObjects(expectedArr,[@"A bulleted list:\n- a\n- b\n- c\n" componentsSeparatedByString:@"\n"]); 40 | 41 | } 42 | -(void) testSplitStringWithMidSpace{ 43 | NSString* input = @"1 2" ; 44 | NSArray* expectedArr = @[@"1",@"2"]; 45 | NSArray* arr = [input componentsSeparatedByString:@" "]; 46 | XCTAssertEqualObjects(expectedArr, arr); 47 | } 48 | 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MarkNote Parser 2 | 3 | 4 | Objective-C version: https://github.com/marknote/MarkNoteParserObjC 5 | Swift version: https://github.com/marknote/MarknoteParser 6 | 7 | 8 | A dead simple markdown parser implemented in both **Swift** and **Objective-C** with performance in mind, which can help you to transform markdown code into HTML. 9 | Most of markdown parsers highly depend on regular expression while MarkNote Parser avoids doing so. 10 | 11 | ## Purpose 12 | 13 | At the beginning my app [MarkNote](https://itunes.apple.com/us/app/marknote/id991297585?ls=1&mt=8) was using [marked](https://github.com/chjj/marked) to render markdown as HTML. 14 | After trying to find a relevant markdown parser in Swfit/Object-c while no luck, I decided to build my own. 15 | 16 | 17 | ## Usage 18 | 19 | ### Using swift version 20 | - Cope 2 files into your project: 21 | -- **StringExtensions.swift** , extension of String class; 22 | -- **MarkNoteParser.swift**, the parser class; 23 | 24 | - Use the method MarkNoteParser.toHtml to convert markdown text to HTML string, like this: 25 | 26 | ```swift 27 | func markdown(input :String)->String{ 28 | let result = MarkNoteParser.toHtml(input) 29 | println("input: \(input) result:\(result)") 30 | return result 31 | } 32 | ``` 33 | ### Using objetive-c version 34 | - Cope all files under "MarkNoteParserOC" folder into your project, and import the header file like this 35 | 36 | ```objective-c 37 | #import "MarkNoteParser.h" 38 | ``` 39 | - Then you can call MarkNoteParser to parse your markdown document: 40 | 41 | ```objective-c 42 | NSString* result = [MarkNoteParser toHtml:input]; 43 | return result; 44 | ``` 45 | 46 | ## Features 47 | 48 | ### headers 49 | 50 | ```markdown 51 | # H1 52 | ## H2 53 | ### H3 54 | ``` 55 | will be transformed into: 56 | 57 | ```html 58 |

    H1

    H2

    H3

    59 | ``` 60 | 61 | ### Emphasis 62 | 63 | ```markdown 64 | Emphasis, aka italics, with *asterisks* or _underscores_. 65 | Strong emphasis, aka bold, with **asterisks** or __underscores__. 66 | Strikethrough uses two tildes. ~~Scratch this.~~ 67 | ``` 68 | will be transformed into: 69 | 70 | ```html 71 |

    Emphasis, aka italics, with asterisks or underscores.

    72 |

    Strong emphasis, aka bold, with asterisks or underscores.

    73 |

    Strikethrough uses two tildes. Scratch this.

    74 | ``` 75 | 76 | ### Links 77 | 78 | ```markdown 79 | [I'm an inline-style link](https://www.google.com) 80 | [I'm an inline-style link with title](https://www.google.com "Google's Homepage") 81 | ``` 82 | 83 | will be transformed into: 84 | 85 | ```html 86 |

    I'm an inline-style link

    87 |

    I'm an inline-style link with title

    88 | ``` 89 | ### Images 90 | 91 | ```markdown 92 | ![alt text](https://avatars3.githubusercontent.com/u/12975088?v=3&s=40 "Logo Title") 93 | ``` 94 | will be transformed into: 95 | ```html 96 | alt text 97 | ``` 98 | ### Code 99 | 100 |
    101 | ```
    102 | var s = "JavaScript syntax highlighting";
    103 | alert(s);
    104 | ```
    105 | 
    106 | 107 | will be transformed into: 108 | ```html 109 |
    110 | var s = "JavaScript syntax highlighting";
    111 | alert(s);
    112 | 
    113 | ``` 114 | 115 | ### Table 116 | 117 | ```markdown 118 | | Tables | Are | Cool | 119 | | ------------- |:-------------:| -----:| 120 | | col 3 is | right-aligned | $1600 | 121 | | col 2 is | centered | $12 | 122 | | zebra stripes | are neat | $1 | 123 | ``` 124 | 125 | will be transformed into: 126 | 127 | ```html 128 |
    Tables Are Cool
    col 3 is right-aligned $1600
    col 2 is centered $12
    zebra stripes are neat $1

    The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.

    129 | ``` 130 | 131 | 132 | ## Feedback 133 | 134 | If you have any suggestion or feedback, feel free to drop me a message or follow me on [twitter @markmarknote](https://twitter.com/markmarknote) --------------------------------------------------------------------------------