├── .gitignore ├── LICENSE ├── MarkNoteView ├── MarkNoteView.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── MarkNoteView │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── MarkNoteView │ ├── MarkdownSyntaxProcesser.h │ ├── MarkdownSyntaxProcesser.m │ ├── SyntaxOccurance.h │ ├── SyntaxOccurance.m │ ├── SyntaxRule.h │ ├── SyntaxRule.m │ ├── UITextView+MarkNote.h │ └── UITextView+MarkNote.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── README.md └── screen.png /.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 | -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A9A8E8A51C19A868001BAD13 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A9A8E8A41C19A868001BAD13 /* main.m */; }; 11 | A9A8E8A81C19A868001BAD13 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A9A8E8A71C19A868001BAD13 /* AppDelegate.m */; }; 12 | A9A8E8AB1C19A868001BAD13 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9A8E8AA1C19A868001BAD13 /* ViewController.m */; }; 13 | A9A8E8AE1C19A868001BAD13 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A9A8E8AC1C19A868001BAD13 /* Main.storyboard */; }; 14 | A9A8E8B01C19A868001BAD13 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A9A8E8AF1C19A868001BAD13 /* Assets.xcassets */; }; 15 | A9A8E8B31C19A868001BAD13 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A9A8E8B11C19A868001BAD13 /* LaunchScreen.storyboard */; }; 16 | A9A8E8C11C19A9B4001BAD13 /* MarkdownSyntaxProcesser.m in Sources */ = {isa = PBXBuildFile; fileRef = A9A8E8BC1C19A9B4001BAD13 /* MarkdownSyntaxProcesser.m */; }; 17 | A9A8E8C21C19A9B4001BAD13 /* SyntaxOccurance.m in Sources */ = {isa = PBXBuildFile; fileRef = A9A8E8BE1C19A9B4001BAD13 /* SyntaxOccurance.m */; }; 18 | A9A8E8C31C19A9B4001BAD13 /* UITextView+MarkNote.m in Sources */ = {isa = PBXBuildFile; fileRef = A9A8E8C01C19A9B4001BAD13 /* UITextView+MarkNote.m */; }; 19 | A9A8E8C61C1A4DE6001BAD13 /* SyntaxRule.m in Sources */ = {isa = PBXBuildFile; fileRef = A9A8E8C51C1A4DE6001BAD13 /* SyntaxRule.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | A9A8E8A01C19A868001BAD13 /* MarkNoteView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MarkNoteView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 24 | A9A8E8A41C19A868001BAD13 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 25 | A9A8E8A61C19A868001BAD13 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 26 | A9A8E8A71C19A868001BAD13 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 27 | A9A8E8A91C19A868001BAD13 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 28 | A9A8E8AA1C19A868001BAD13 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 29 | A9A8E8AD1C19A868001BAD13 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 30 | A9A8E8AF1C19A868001BAD13 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 31 | A9A8E8B21C19A868001BAD13 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 32 | A9A8E8B41C19A868001BAD13 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | A9A8E8BB1C19A9B4001BAD13 /* MarkdownSyntaxProcesser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkdownSyntaxProcesser.h; sourceTree = ""; }; 34 | A9A8E8BC1C19A9B4001BAD13 /* MarkdownSyntaxProcesser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MarkdownSyntaxProcesser.m; sourceTree = ""; }; 35 | A9A8E8BD1C19A9B4001BAD13 /* SyntaxOccurance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SyntaxOccurance.h; sourceTree = ""; }; 36 | A9A8E8BE1C19A9B4001BAD13 /* SyntaxOccurance.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SyntaxOccurance.m; sourceTree = ""; }; 37 | A9A8E8BF1C19A9B4001BAD13 /* UITextView+MarkNote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UITextView+MarkNote.h"; sourceTree = ""; }; 38 | A9A8E8C01C19A9B4001BAD13 /* UITextView+MarkNote.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITextView+MarkNote.m"; sourceTree = ""; }; 39 | A9A8E8C41C1A4DE6001BAD13 /* SyntaxRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SyntaxRule.h; sourceTree = ""; }; 40 | A9A8E8C51C1A4DE6001BAD13 /* SyntaxRule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SyntaxRule.m; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | A9A8E89D1C19A868001BAD13 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | /* End PBXFrameworksBuildPhase section */ 52 | 53 | /* Begin PBXGroup section */ 54 | A9A8E8971C19A868001BAD13 = { 55 | isa = PBXGroup; 56 | children = ( 57 | A9A8E8A21C19A868001BAD13 /* MarkNoteViewDemo */, 58 | A9A8E8A11C19A868001BAD13 /* Products */, 59 | ); 60 | sourceTree = ""; 61 | }; 62 | A9A8E8A11C19A868001BAD13 /* Products */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | A9A8E8A01C19A868001BAD13 /* MarkNoteView.app */, 66 | ); 67 | name = Products; 68 | sourceTree = ""; 69 | }; 70 | A9A8E8A21C19A868001BAD13 /* MarkNoteViewDemo */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | A9A8E8BA1C19A9B4001BAD13 /* MarkNoteView */, 74 | A9A8E8A61C19A868001BAD13 /* AppDelegate.h */, 75 | A9A8E8A71C19A868001BAD13 /* AppDelegate.m */, 76 | A9A8E8A91C19A868001BAD13 /* ViewController.h */, 77 | A9A8E8AA1C19A868001BAD13 /* ViewController.m */, 78 | A9A8E8AC1C19A868001BAD13 /* Main.storyboard */, 79 | A9A8E8AF1C19A868001BAD13 /* Assets.xcassets */, 80 | A9A8E8B11C19A868001BAD13 /* LaunchScreen.storyboard */, 81 | A9A8E8B41C19A868001BAD13 /* Info.plist */, 82 | A9A8E8A31C19A868001BAD13 /* Supporting Files */, 83 | ); 84 | name = MarkNoteViewDemo; 85 | path = MarkNoteView; 86 | sourceTree = ""; 87 | }; 88 | A9A8E8A31C19A868001BAD13 /* Supporting Files */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | A9A8E8A41C19A868001BAD13 /* main.m */, 92 | ); 93 | name = "Supporting Files"; 94 | sourceTree = ""; 95 | }; 96 | A9A8E8BA1C19A9B4001BAD13 /* MarkNoteView */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | A9A8E8BB1C19A9B4001BAD13 /* MarkdownSyntaxProcesser.h */, 100 | A9A8E8BC1C19A9B4001BAD13 /* MarkdownSyntaxProcesser.m */, 101 | A9A8E8BD1C19A9B4001BAD13 /* SyntaxOccurance.h */, 102 | A9A8E8BE1C19A9B4001BAD13 /* SyntaxOccurance.m */, 103 | A9A8E8BF1C19A9B4001BAD13 /* UITextView+MarkNote.h */, 104 | A9A8E8C01C19A9B4001BAD13 /* UITextView+MarkNote.m */, 105 | A9A8E8C41C1A4DE6001BAD13 /* SyntaxRule.h */, 106 | A9A8E8C51C1A4DE6001BAD13 /* SyntaxRule.m */, 107 | ); 108 | path = MarkNoteView; 109 | sourceTree = ""; 110 | }; 111 | /* End PBXGroup section */ 112 | 113 | /* Begin PBXNativeTarget section */ 114 | A9A8E89F1C19A868001BAD13 /* MarkNoteView */ = { 115 | isa = PBXNativeTarget; 116 | buildConfigurationList = A9A8E8B71C19A868001BAD13 /* Build configuration list for PBXNativeTarget "MarkNoteView" */; 117 | buildPhases = ( 118 | A9A8E89C1C19A868001BAD13 /* Sources */, 119 | A9A8E89D1C19A868001BAD13 /* Frameworks */, 120 | A9A8E89E1C19A868001BAD13 /* Resources */, 121 | ); 122 | buildRules = ( 123 | ); 124 | dependencies = ( 125 | ); 126 | name = MarkNoteView; 127 | productName = MarkNoteView; 128 | productReference = A9A8E8A01C19A868001BAD13 /* MarkNoteView.app */; 129 | productType = "com.apple.product-type.application"; 130 | }; 131 | /* End PBXNativeTarget section */ 132 | 133 | /* Begin PBXProject section */ 134 | A9A8E8981C19A868001BAD13 /* Project object */ = { 135 | isa = PBXProject; 136 | attributes = { 137 | LastUpgradeCheck = 0710; 138 | ORGANIZATIONNAME = markNote; 139 | TargetAttributes = { 140 | A9A8E89F1C19A868001BAD13 = { 141 | CreatedOnToolsVersion = 7.1; 142 | }; 143 | }; 144 | }; 145 | buildConfigurationList = A9A8E89B1C19A868001BAD13 /* Build configuration list for PBXProject "MarkNoteView" */; 146 | compatibilityVersion = "Xcode 3.2"; 147 | developmentRegion = English; 148 | hasScannedForEncodings = 0; 149 | knownRegions = ( 150 | en, 151 | Base, 152 | ); 153 | mainGroup = A9A8E8971C19A868001BAD13; 154 | productRefGroup = A9A8E8A11C19A868001BAD13 /* Products */; 155 | projectDirPath = ""; 156 | projectRoot = ""; 157 | targets = ( 158 | A9A8E89F1C19A868001BAD13 /* MarkNoteView */, 159 | ); 160 | }; 161 | /* End PBXProject section */ 162 | 163 | /* Begin PBXResourcesBuildPhase section */ 164 | A9A8E89E1C19A868001BAD13 /* Resources */ = { 165 | isa = PBXResourcesBuildPhase; 166 | buildActionMask = 2147483647; 167 | files = ( 168 | A9A8E8B31C19A868001BAD13 /* LaunchScreen.storyboard in Resources */, 169 | A9A8E8B01C19A868001BAD13 /* Assets.xcassets in Resources */, 170 | A9A8E8AE1C19A868001BAD13 /* Main.storyboard in Resources */, 171 | ); 172 | runOnlyForDeploymentPostprocessing = 0; 173 | }; 174 | /* End PBXResourcesBuildPhase section */ 175 | 176 | /* Begin PBXSourcesBuildPhase section */ 177 | A9A8E89C1C19A868001BAD13 /* Sources */ = { 178 | isa = PBXSourcesBuildPhase; 179 | buildActionMask = 2147483647; 180 | files = ( 181 | A9A8E8AB1C19A868001BAD13 /* ViewController.m in Sources */, 182 | A9A8E8C21C19A9B4001BAD13 /* SyntaxOccurance.m in Sources */, 183 | A9A8E8C11C19A9B4001BAD13 /* MarkdownSyntaxProcesser.m in Sources */, 184 | A9A8E8A81C19A868001BAD13 /* AppDelegate.m in Sources */, 185 | A9A8E8C31C19A9B4001BAD13 /* UITextView+MarkNote.m in Sources */, 186 | A9A8E8A51C19A868001BAD13 /* main.m in Sources */, 187 | A9A8E8C61C1A4DE6001BAD13 /* SyntaxRule.m in Sources */, 188 | ); 189 | runOnlyForDeploymentPostprocessing = 0; 190 | }; 191 | /* End PBXSourcesBuildPhase section */ 192 | 193 | /* Begin PBXVariantGroup section */ 194 | A9A8E8AC1C19A868001BAD13 /* Main.storyboard */ = { 195 | isa = PBXVariantGroup; 196 | children = ( 197 | A9A8E8AD1C19A868001BAD13 /* Base */, 198 | ); 199 | name = Main.storyboard; 200 | sourceTree = ""; 201 | }; 202 | A9A8E8B11C19A868001BAD13 /* LaunchScreen.storyboard */ = { 203 | isa = PBXVariantGroup; 204 | children = ( 205 | A9A8E8B21C19A868001BAD13 /* Base */, 206 | ); 207 | name = LaunchScreen.storyboard; 208 | sourceTree = ""; 209 | }; 210 | /* End PBXVariantGroup section */ 211 | 212 | /* Begin XCBuildConfiguration section */ 213 | A9A8E8B51C19A868001BAD13 /* Debug */ = { 214 | isa = XCBuildConfiguration; 215 | buildSettings = { 216 | ALWAYS_SEARCH_USER_PATHS = NO; 217 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 218 | CLANG_CXX_LIBRARY = "libc++"; 219 | CLANG_ENABLE_MODULES = YES; 220 | CLANG_ENABLE_OBJC_ARC = YES; 221 | CLANG_WARN_BOOL_CONVERSION = YES; 222 | CLANG_WARN_CONSTANT_CONVERSION = YES; 223 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 224 | CLANG_WARN_EMPTY_BODY = YES; 225 | CLANG_WARN_ENUM_CONVERSION = YES; 226 | CLANG_WARN_INT_CONVERSION = YES; 227 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 228 | CLANG_WARN_UNREACHABLE_CODE = YES; 229 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 230 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 231 | COPY_PHASE_STRIP = NO; 232 | DEBUG_INFORMATION_FORMAT = dwarf; 233 | ENABLE_STRICT_OBJC_MSGSEND = YES; 234 | ENABLE_TESTABILITY = YES; 235 | GCC_C_LANGUAGE_STANDARD = gnu99; 236 | GCC_DYNAMIC_NO_PIC = NO; 237 | GCC_NO_COMMON_BLOCKS = YES; 238 | GCC_OPTIMIZATION_LEVEL = 0; 239 | GCC_PREPROCESSOR_DEFINITIONS = ( 240 | "DEBUG=1", 241 | "$(inherited)", 242 | ); 243 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 244 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 245 | GCC_WARN_UNDECLARED_SELECTOR = YES; 246 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 247 | GCC_WARN_UNUSED_FUNCTION = YES; 248 | GCC_WARN_UNUSED_VARIABLE = YES; 249 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 250 | MTL_ENABLE_DEBUG_INFO = YES; 251 | ONLY_ACTIVE_ARCH = YES; 252 | SDKROOT = iphoneos; 253 | }; 254 | name = Debug; 255 | }; 256 | A9A8E8B61C19A868001BAD13 /* Release */ = { 257 | isa = XCBuildConfiguration; 258 | buildSettings = { 259 | ALWAYS_SEARCH_USER_PATHS = NO; 260 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 261 | CLANG_CXX_LIBRARY = "libc++"; 262 | CLANG_ENABLE_MODULES = YES; 263 | CLANG_ENABLE_OBJC_ARC = YES; 264 | CLANG_WARN_BOOL_CONVERSION = YES; 265 | CLANG_WARN_CONSTANT_CONVERSION = YES; 266 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 267 | CLANG_WARN_EMPTY_BODY = YES; 268 | CLANG_WARN_ENUM_CONVERSION = YES; 269 | CLANG_WARN_INT_CONVERSION = YES; 270 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 271 | CLANG_WARN_UNREACHABLE_CODE = YES; 272 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 273 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 274 | COPY_PHASE_STRIP = NO; 275 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 276 | ENABLE_NS_ASSERTIONS = NO; 277 | ENABLE_STRICT_OBJC_MSGSEND = YES; 278 | GCC_C_LANGUAGE_STANDARD = gnu99; 279 | GCC_NO_COMMON_BLOCKS = YES; 280 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 281 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 282 | GCC_WARN_UNDECLARED_SELECTOR = YES; 283 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 284 | GCC_WARN_UNUSED_FUNCTION = YES; 285 | GCC_WARN_UNUSED_VARIABLE = YES; 286 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 287 | MTL_ENABLE_DEBUG_INFO = NO; 288 | SDKROOT = iphoneos; 289 | VALIDATE_PRODUCT = YES; 290 | }; 291 | name = Release; 292 | }; 293 | A9A8E8B81C19A868001BAD13 /* Debug */ = { 294 | isa = XCBuildConfiguration; 295 | buildSettings = { 296 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 297 | INFOPLIST_FILE = MarkNoteView/Info.plist; 298 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 299 | PRODUCT_BUNDLE_IDENTIFIER = markNote.MarkNoteView; 300 | PRODUCT_NAME = "$(TARGET_NAME)"; 301 | }; 302 | name = Debug; 303 | }; 304 | A9A8E8B91C19A868001BAD13 /* Release */ = { 305 | isa = XCBuildConfiguration; 306 | buildSettings = { 307 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 308 | INFOPLIST_FILE = MarkNoteView/Info.plist; 309 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 310 | PRODUCT_BUNDLE_IDENTIFIER = markNote.MarkNoteView; 311 | PRODUCT_NAME = "$(TARGET_NAME)"; 312 | }; 313 | name = Release; 314 | }; 315 | /* End XCBuildConfiguration section */ 316 | 317 | /* Begin XCConfigurationList section */ 318 | A9A8E89B1C19A868001BAD13 /* Build configuration list for PBXProject "MarkNoteView" */ = { 319 | isa = XCConfigurationList; 320 | buildConfigurations = ( 321 | A9A8E8B51C19A868001BAD13 /* Debug */, 322 | A9A8E8B61C19A868001BAD13 /* Release */, 323 | ); 324 | defaultConfigurationIsVisible = 0; 325 | defaultConfigurationName = Release; 326 | }; 327 | A9A8E8B71C19A868001BAD13 /* Build configuration list for PBXNativeTarget "MarkNoteView" */ = { 328 | isa = XCConfigurationList; 329 | buildConfigurations = ( 330 | A9A8E8B81C19A868001BAD13 /* Debug */, 331 | A9A8E8B91C19A868001BAD13 /* Release */, 332 | ); 333 | defaultConfigurationIsVisible = 0; 334 | defaultConfigurationName = Release; 335 | }; 336 | /* End XCConfigurationList section */ 337 | }; 338 | rootObject = A9A8E8981C19A868001BAD13 /* Project object */; 339 | } 340 | -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MarkNoteView- A UITextView category to highlight MarkDown syntax. * Copyright (c) 2015, MarkNote. (MIT Licensed) 3 | * https://github.com/marknote/MarkNoteView 4 | */ 5 | 6 | #import 7 | 8 | @interface AppDelegate : UIResponder 9 | 10 | @property (strong, nonatomic) UIWindow *window; 11 | 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * MarkNoteView- A UITextView category to highlight MarkDown syntax. * Copyright (c) 2015, MarkNote. (MIT Licensed) 3 | * https://github.com/marknote/MarkNoteView 4 | */ 5 | 6 | #import "AppDelegate.h" 7 | 8 | @interface AppDelegate () 9 | 10 | @end 11 | 12 | @implementation AppDelegate 13 | 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 16 | // Override point for customization after application launch. 17 | return YES; 18 | } 19 | 20 | - (void)applicationWillResignActive:(UIApplication *)application { 21 | // 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. 22 | // 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. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application { 26 | // 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. 27 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 28 | } 29 | 30 | - (void)applicationWillEnterForeground:(UIApplication *)application { 31 | // 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. 32 | } 33 | 34 | - (void)applicationDidBecomeActive:(UIApplication *)application { 35 | // 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. 36 | } 37 | 38 | - (void)applicationWillTerminate:(UIApplication *)application { 39 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/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 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/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 | -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/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 | # MarkNoteView 25 | 26 | A UITextView category to highlight MarkDown syntax. 27 | 28 | - Set background color for **code** blocks 29 | - Highlight **html** tags 30 | - Highlight **links** and **image** tags 31 | 32 | MarkNoteView is used in my app [MarkNote](https://itunes.apple.com/us/app/marknote/id991297585?ls=1&mt=8) 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/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 | 40 | 41 | -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/MarkNoteView/MarkdownSyntaxProcesser.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MarkNoteView- A UITextView category to highlight MarkDown syntax. * Copyright (c) 2015, MarkNote. (MIT Licensed) 3 | * https://github.com/marknote/MarkNoteView 4 | */ 5 | 6 | 7 | #import 8 | #import "SyntaxOccurance.h" 9 | 10 | 11 | 12 | 13 | @interface MarkdownSyntaxProcesser : NSObject 14 | - (NSMutableArray *)process:(NSString *) text; 15 | @end -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/MarkNoteView/MarkdownSyntaxProcesser.m: -------------------------------------------------------------------------------- 1 | /** 2 | * MarkNoteView- A UITextView category to highlight MarkDown syntax. * Copyright (c) 2015, MarkNote. (MIT Licensed) 3 | * https://github.com/marknote/MarkNoteView 4 | */ 5 | 6 | #import 7 | #import "MarkdownSyntaxProcesser.h" 8 | 9 | 10 | 11 | #define regexp(reg,option) [NSRegularExpression regularExpressionWithPattern:@reg options:option error:NULL] 12 | 13 | 14 | @implementation MarkdownSyntaxProcesser 15 | 16 | SyntaxRule* buildSyntaxRule(NSRegularExpression* exp ,NSDictionary* styles){ 17 | return [[SyntaxRule alloc] initWithExpress:exp Styles:styles]; 18 | } 19 | 20 | - (NSArray*) buildRulesForMarkDown{ 21 | return @[ 22 | 23 | // headers 24 | buildSyntaxRule( 25 | regexp("(#+)(.*)", NSRegularExpressionAnchorsMatchLines), 26 | @{ 27 | NSFontAttributeName : [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline] 28 | }), 29 | //links 30 | buildSyntaxRule( 31 | regexp("(\\!)*\\[([^\\[]*)\\]\\(([^\\)]+)\\)", 0), 32 | @{NSForegroundColorAttributeName : [UIColor colorWithRed:104.0/255.0 green:224.0/255.0 blue:152.0/255.0 alpha:1.0]}), 33 | //bold 34 | buildSyntaxRule( 35 | regexp("(\\*\\*|__)(.*?)\\1", 0), 36 | @{NSFontAttributeName : [UIFont boldSystemFontOfSize:[UIFont systemFontSize]]}), 37 | //Emphasis 38 | buildSyntaxRule( 39 | regexp("\\s(\\*|_)(.*?)\\1\\s", 0), 40 | @{NSFontAttributeName : [UIFont boldSystemFontOfSize:[UIFont systemFontSize]]}), 41 | //deletion 42 | buildSyntaxRule( 43 | regexp("\\~\\~(.*?)\\~\\~", 0), 44 | @{NSStrikethroughStyleAttributeName : @(NSUnderlineStyleSingle)}), 45 | //quotes 46 | buildSyntaxRule( 47 | regexp("\\:\\\"(.*?)\\\"\\:", 0), 48 | @{NSForegroundColorAttributeName : [UIColor lightGrayColor]}), 49 | //InlineCode 50 | buildSyntaxRule( 51 | regexp("`(.*?)`", 0), 52 | @{NSForegroundColorAttributeName : [UIColor brownColor]}), 53 | //block Code 54 | buildSyntaxRule( 55 | regexp("```([\\s\\S]*?)```", 0), 56 | @{ 57 | NSBackgroundColorAttributeName : [UIColor colorWithRed:0.99 green:0.99 blue:0.99 alpha:1.0] 58 | }), 59 | //Blockquotes 60 | buildSyntaxRule( 61 | regexp("\n(>|\\>)(.*)",0), 62 | @{NSBackgroundColorAttributeName : [UIColor colorWithRed:125.0/255.0 green:210.0/255.0 blue:209.0/255.0 alpha:1.0] 63 | }), 64 | /*//ULLists 65 | buildSyntaxRule( 66 | regexp("^\\-([^\\*]*)", NSRegularExpressionAnchorsMatchLines), 67 | @{}), 68 | //InlineCode 69 | buildSyntaxRule( 70 | regexp("^[0-9]+\\.(.*)", 71 | @{}),*/ 72 | //HTML tags 73 | buildSyntaxRule( 74 | regexp("<[^>]+>", 0), 75 | @{NSForegroundColorAttributeName : [UIColor colorWithRed:1.0 green:106.0/255.0 blue:0.0 alpha:1.0]}) 76 | 77 | 78 | ]; 79 | } 80 | 81 | 82 | - (NSMutableArray *)process:(NSString *) text; { 83 | NSMutableArray *markdownSyntaxModels = [NSMutableArray array]; 84 | NSArray* rules = [self buildRulesForMarkDown]; 85 | 86 | for (SyntaxRule * rule in rules) { 87 | 88 | NSArray *matches = [rule.express matchesInString:text 89 | options:0 90 | range:NSMakeRange(0, [text length])]; 91 | for (NSTextCheckingResult *result in matches) { 92 | SyntaxOccurance* occurance = [[SyntaxOccurance alloc] initWithRange:result.range styles:rule.styles]; 93 | [markdownSyntaxModels addObject:occurance]; 94 | } 95 | } 96 | return markdownSyntaxModels; 97 | } 98 | @end -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/MarkNoteView/SyntaxOccurance.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MarkNoteView- A UITextView category to highlight MarkDown syntax. * Copyright (c) 2015, MarkNote. (MIT Licensed) 3 | * https://github.com/marknote/MarkNoteView 4 | */ 5 | 6 | #import 7 | #import "SyntaxRule.h" 8 | 9 | 10 | 11 | @interface SyntaxOccurance : NSObject{ 12 | NSRange _range; 13 | NSDictionary* _styles; 14 | } 15 | @property(readonly) NSRange range; 16 | @property (readonly) NSDictionary* styles; 17 | 18 | - (instancetype)initWithRange:(NSRange) range styles:(NSDictionary*) styles; 19 | 20 | 21 | @end -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/MarkNoteView/SyntaxOccurance.m: -------------------------------------------------------------------------------- 1 | /** 2 | * MarkNoteView- A UITextView category to highlight MarkDown syntax. * Copyright (c) 2015, MarkNote. (MIT Licensed) 3 | * https://github.com/marknote/MarkNoteView 4 | */ 5 | 6 | #import "SyntaxOccurance.h" 7 | 8 | 9 | 10 | 11 | @implementation SyntaxOccurance { 12 | 13 | } 14 | - (instancetype)initWithRange:(NSRange) range styles:(NSDictionary*) styles { 15 | self = [super init]; 16 | if (self) { 17 | _styles = styles; 18 | _range = range; 19 | } 20 | return self; 21 | } 22 | 23 | 24 | 25 | @end -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/MarkNoteView/SyntaxRule.h: -------------------------------------------------------------------------------- 1 | // 2 | // MarkdownRule.h 3 | // MarkNoteView 4 | // 5 | // Created by bill on 11/12/15. 6 | // Copyright © 2015 markNote. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | 13 | @interface SyntaxRule : NSObject{ 14 | NSRegularExpression* _express; 15 | NSDictionary* _styles; 16 | } 17 | 18 | 19 | @property (readonly) NSRegularExpression* express; 20 | @property (readonly) NSDictionary* styles; 21 | 22 | -(instancetype) initWithExpress:(NSRegularExpression*) exp Styles:(NSDictionary*) styles; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/MarkNoteView/SyntaxRule.m: -------------------------------------------------------------------------------- 1 | // 2 | // MarkdownRule.m 3 | // MarkNoteView 4 | // 5 | // Created by bill on 11/12/15. 6 | // Copyright © 2015 markNote. All rights reserved. 7 | // 8 | 9 | #import "SyntaxRule.h" 10 | 11 | @implementation SyntaxRule 12 | 13 | -(instancetype) initWithExpress:(NSRegularExpression*) exp Styles:(NSDictionary*) styles{ 14 | self = [super init]; 15 | if( self){ 16 | _express = exp; 17 | _styles = styles; 18 | } 19 | return self; 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/MarkNoteView/UITextView+MarkNote.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MarkNoteView- A UITextView category to highlight MarkDown syntax. * Copyright (c) 2015, MarkNote. (MIT Licensed) 3 | * https://github.com/marknote/MarkNoteView 4 | */ 5 | 6 | #import 7 | #import 8 | 9 | #import "MarkdownSyntaxProcesser.h" 10 | 11 | 12 | @interface UITextView(MarkNoteView) 13 | - (void)updateSyntax; 14 | @end -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/MarkNoteView/UITextView+MarkNote.m: -------------------------------------------------------------------------------- 1 | /** 2 | * MarkNoteView- A UITextView category to highlight MarkDown syntax. * Copyright (c) 2015, MarkNote. (MIT Licensed) 3 | * https://github.com/marknote/MarkNoteView 4 | */ 5 | 6 | #import "UITextView+MarkNote.h" 7 | #import "MarkdownSyntaxProcesser.h" 8 | #import "SyntaxOccurance.h" 9 | 10 | 11 | 12 | 13 | 14 | @implementation UITextView(MarkNoteView) 15 | 16 | 17 | 18 | 19 | - (MarkdownSyntaxProcesser *)markdownSyntaxGenerator { 20 | static MarkdownSyntaxProcesser *_markdownSyntaxGenerator = nil; 21 | if (_markdownSyntaxGenerator == nil) { 22 | _markdownSyntaxGenerator = [[MarkdownSyntaxProcesser alloc] init]; 23 | } 24 | return _markdownSyntaxGenerator; 25 | } 26 | 27 | - (void)updateSyntax { 28 | NSMutableArray *occurances = [[self markdownSyntaxGenerator] process:self.text]; 29 | NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:self.text]; 30 | [attributedString setAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16.0]} range:NSMakeRange(0, [attributedString length])]; 31 | for (SyntaxOccurance *occurance in occurances) { 32 | [attributedString addAttributes:occurance.styles range:occurance.range]; 33 | } 34 | [occurances removeAllObjects]; 35 | occurances = nil; 36 | [self updateAttributedText:attributedString]; 37 | } 38 | 39 | - (void)updateAttributedText:(NSAttributedString *) attributedString { 40 | self.scrollEnabled = NO; 41 | NSRange selectedRange = self.selectedRange; 42 | self.attributedText = attributedString; 43 | self.selectedRange = selectedRange; 44 | self.scrollEnabled = YES; 45 | } 46 | 47 | 48 | @end -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/ViewController.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MarkNoteView- A UITextView category to highlight MarkDown syntax. * Copyright (c) 2015, MarkNote. (MIT Licensed) 3 | * https://github.com/marknote/MarkNoteView 4 | */ 5 | 6 | #import 7 | 8 | 9 | @interface ViewController : UIViewController{ 10 | IBOutlet UITextView *_textView; 11 | } 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/ViewController.m: -------------------------------------------------------------------------------- 1 | /** 2 | * MarkNoteView- A UITextView category to highlight MarkDown syntax. * Copyright (c) 2015, MarkNote. (MIT Licensed) 3 | * https://github.com/marknote/MarkNoteView 4 | */ 5 | 6 | #import "ViewController.h" 7 | #import "UITextView+MarkNote.h" 8 | 9 | @interface ViewController () 10 | 11 | @end 12 | 13 | @implementation ViewController 14 | 15 | - (void)viewDidLoad { 16 | [super viewDidLoad]; 17 | // Do any additional setup after loading the view, typically from a nib. 18 | [_textView updateSyntax]; 19 | _textView.delegate = self; 20 | } 21 | 22 | - (void)didReceiveMemoryWarning { 23 | [super didReceiveMemoryWarning]; 24 | // Dispose of any resources that can be recreated. 25 | } 26 | 27 | - (void)textViewDidChange:(UITextView *)textView{ 28 | 29 | [_textView updateSyntax]; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /MarkNoteView/MarkNoteView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MarkNoteView 4 | // 5 | // Created by bill on 10/12/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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MarkNoteView 2 | 3 | A UITextView category to highlight MarkDown syntax. 4 | 5 | - Set background color for **code** blocks 6 | - Highlight **html** tags 7 | - Highlight **links** and **image** tags 8 | 9 | A simple demo has been provided in the code 10 | 11 | ![Screen](https://raw.githubusercontent.com/marknote/MarkNoteView/master/screen.png) 12 | 13 | ## Usage 14 | - Put a `UITextView` on you UI either by InterfaceBuilder or code 15 | - Copy and add all files under `MarkNoteView` sub folder into your project 16 | - Include the head file in your viewcontroller 17 | 18 | ``` 19 | #import "UITextView+MarkNote.h" 20 | ``` 21 | - When your text changes, call `updateSyntax ` method 22 | 23 | ``` 24 | - (void)textViewDidChange:(UITextView *)textView{ 25 | 26 | [_textView updateSyntax]; 27 | } 28 | ``` 29 | - That is it! 30 | 31 | Feel free to check the demo app 32 | ## App 33 | 34 | MarkNoteView is used in my app [MarkNote](https://itunes.apple.com/us/app/marknote/id991297585?ls=1&mt=8) 35 | 36 | 37 | ## Questions and feedback 38 | 39 | Twit me @markmarknote https://twitter.com/markmarknote 40 | -------------------------------------------------------------------------------- /screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marknote/MarkNoteView/cc4322fce3da7d9a183bed83a5e5e971da0fd214/screen.png --------------------------------------------------------------------------------