Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Cu-Toof committed Aug 6, 2017
0 parents commit bfa14d4
Show file tree
Hide file tree
Showing 52 changed files with 3,047 additions and 0 deletions.
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.3
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# references:
# * http://www.objc.io/issue-6/travis-ci.html
# * https://github.com/supermarin/xcpretty#usage

osx_image: xcode7.3
language: objective-c
# cache: cocoapods
# podfile: Example/Podfile
# before_install:
# - gem install cocoapods # Since Travis is not always on latest version
# - pod install --project-directory=Example
script:
- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/MarkDownEditor.xcworkspace -scheme MarkDownEditor-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty
- pod lib lint
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2017 Cu-Toof <toanf9dn@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
43 changes: 43 additions & 0 deletions MarkDownEditor.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#
# Be sure to run `pod lib lint MarkDownEditor.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
s.name = 'MarkDownEditor'
s.version = '1.0.0'
s.summary = 'Read MarkDown File.'

# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!

s.description = <<-DESC
MarkDownEditor help you read MarkDown file in iOS.
DESC

s.homepage = 'https://github.com/Cu-Toof/MarkDownEditor'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Cu-Toof' => 'toanf9dn@gmail.com' }
s.source = { :git => 'https://github.com/Cu-Toof/MarkDownEditor.git', :tag => s.version.to_s }
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

s.ios.deployment_target = '8.0'

s.source_files = 'MarkDownEditor/Classes/**/*'

# s.resource_bundles = {
# 'MarkDownEditor' => ['MarkDownEditor/Assets/*.png']
# }

# s.public_header_files = 'Pod/Classes/**/*.h'
s.frameworks = 'UIKit'
s.dependency 'cmark', '~> 0.21.0'
s.dependency 'Ono', '~> 1.1.3'
end
Empty file added MarkDownEditor/Assets/.gitkeep
Empty file.
Empty file added MarkDownEditor/Classes/.gitkeep
Empty file.
26 changes: 26 additions & 0 deletions MarkDownEditor/Classes/CMAttributeRun.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// CMAttributeRun.h
// MarkDownEditor
//
// Created by Indragie on 1/15/15.
// Copyright (c) 2015 Indragie Karunaratne. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CMPlatformDefines.h"

@interface CMAttributeRun : NSObject
@property (nonatomic, readonly) NSDictionary *attributes;
@property (nonatomic, readonly) CMFontSymbolicTraits fontTraits;
@property (nonatomic) NSInteger orderedListItemNumber;
@property (nonatomic, readonly) BOOL listTight;

- (instancetype)initWithAttributes:(NSDictionary *)attributes
fontTraits:(CMFontSymbolicTraits)fontTraits
orderedListNumber:(NSInteger)orderedListNumber;

@end

CMAttributeRun * CMDefaultAttributeRun(NSDictionary *attributes);
CMAttributeRun * CMTraitAttributeRun(NSDictionary *attributes, CMFontSymbolicTraits traits);
CMAttributeRun * CMOrderedListAttributeRun(NSDictionary *attributes, NSInteger startingNumber);
40 changes: 40 additions & 0 deletions MarkDownEditor/Classes/CMAttributeRun.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// CMAttributeRun.m
// MarkDownEditor
//
// Created by Indragie on 1/15/15.
// Copyright (c) 2015 Indragie Karunaratne. All rights reserved.
//

#import "CMAttributeRun.h"

CMAttributeRun * CMDefaultAttributeRun(NSDictionary *attributes)
{
return [[CMAttributeRun alloc] initWithAttributes:attributes fontTraits:0 orderedListNumber:0];
}

CMAttributeRun * CMTraitAttributeRun(NSDictionary *attributes, CMFontSymbolicTraits traits)
{
return [[CMAttributeRun alloc] initWithAttributes:attributes fontTraits:traits orderedListNumber:0];
}

CMAttributeRun * CMOrderedListAttributeRun(NSDictionary *attributes, NSInteger startingNumber)
{
return [[CMAttributeRun alloc] initWithAttributes:attributes fontTraits:0 orderedListNumber:startingNumber];
}

@implementation CMAttributeRun

- (instancetype)initWithAttributes:(NSDictionary *)attributes
fontTraits:(CMFontSymbolicTraits)fontTraits
orderedListNumber:(NSInteger)orderedListNumber
{
if ((self = [super init])) {
_attributes = attributes;
_fontTraits = fontTraits;
_orderedListItemNumber = orderedListNumber;
}
return self;
}

@end
47 changes: 47 additions & 0 deletions MarkDownEditor/Classes/CMAttributedStringRenderer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// CMAttributedStringRenderer.h
// MarkDownEditor
//
// Created by Indragie on 1/14/15.
// Copyright (c) 2015 Indragie Karunaratne. All rights reserved.
//

#import <Foundation/Foundation.h>

@class CMDocument;
@class CMTextAttributes;
@protocol CMHTMLElementTransformer;
/**
* Renders an attributed string from a Markdown document
*/
@interface CMAttributedStringRenderer : NSObject

/**
* Designated initializer.
*
* @param document A Markdown document.
* @param attributes Attributes used to style the string.
*
* @return An initialized instance of the receiver.
*/
- (instancetype)initWithDocument:(CMDocument *)document attributes:(CMTextAttributes *)attributes;

/**
* Registers a handler to transform HTML elements.
*
* Only a single transformer can be registered for an element. If a transformer
* is already registered for an element, it will be replaced.
*
* @param transformer The transformer to register.
*/
- (void)registerHTMLElementTransformer:(id<CMHTMLElementTransformer>)transformer;

/**
* Renders an attributed string from the Markdown document.
*
* @return An attributed string containing the contents of the Markdown document,
* styled using the attributes set on the receiver.
*/
- (NSAttributedString *)render;

@end
Loading

0 comments on commit bfa14d4

Please sign in to comment.