Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
2 changes: 1 addition & 1 deletion App/MarkdownParser-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>dk.boedewadt.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
433 changes: 422 additions & 11 deletions MarkdownParser.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0450"
LastUpgradeVersion = "1240"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -37,10 +37,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -55,22 +55,30 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3EB17EA0161F189F00A27750"
BuildableName = "libMarkdownParser.a"
BlueprintName = "MarkdownParser"
ReferencedContainer = "container:MarkdownParser.xcodeproj">
</BuildableReference>
</MacroExpansion>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0450"
LastUpgradeVersion = "1240"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -23,10 +23,19 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3EB17E3B161F17B100A27750"
BuildableName = "MarkdownParserApp.app"
BlueprintName = "MarkdownParserApp"
ReferencedContainer = "container:MarkdownParser.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -39,26 +48,19 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3EB17E3B161F17B100A27750"
BuildableName = "MarkdownParserApp.app"
BlueprintName = "MarkdownParserApp"
ReferencedContainer = "container:MarkdownParser.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3EB17E3B161F17B100A27750"
Expand All @@ -67,16 +69,15 @@
ReferencedContainer = "container:MarkdownParser.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3EB17E3B161F17B100A27750"
Expand Down
30 changes: 30 additions & 0 deletions MarkdownParserMac/MarkdownParserMac-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012 Bödewadt. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
8 changes: 8 additions & 0 deletions MarkdownParserMac/MarkdownParserMac-Prefix.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// Prefix header for all source files of the 'MarkdownParserMac' target in the 'MarkdownParserMac' project
//

#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import "OS-X-ObjC-Compatibility.h"
#endif
17 changes: 17 additions & 0 deletions MarkdownParserMac/NSFont+UIKitAdditions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// NSFont+UIKitAdditions.h
// MarkdownParser
//
// Created by Jan on 18.11.12.
// Copyright (c) 2012 Bödewadt. All rights reserved.
//

#import <AppKit/AppKit.h>

@interface NSFont (UIKitAdditions)

+ (NSFont *)italicSystemFontOfSize:(CGFloat)size;

- (NSFont *)fontWithSize:(CGFloat)size;

@end
27 changes: 27 additions & 0 deletions MarkdownParserMac/NSFont+UIKitAdditions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// NSFont+UIKitAdditions.m
// MarkdownParser
//
// Created by Jan on 18.11.12.
// Copyright (c) 2012 Bödewadt. All rights reserved.
//

#import "NSFont+UIKitAdditions.h"

@implementation NSFont (UIKitAdditions)

// This can’t work, because no italic version of Lucida Grande is available!
+ (NSFont *)italicSystemFontOfSize:(CGFloat)size;
{
NSFont *baseFont = [NSFont systemFontOfSize:((size == 0) ? [NSFont systemFontSize] : size)];
return [[NSFontManager sharedFontManager] convertFont:baseFont toHaveTrait:NSItalicFontMask];
}

- (NSFont *)fontWithSize:(CGFloat)size;
{
NSFontDescriptor *fontDescriptor = [self fontDescriptor];
return [NSFont fontWithDescriptor:fontDescriptor size:((size == 0) ? [NSFont systemFontSize] : size)];
}


@end
2 changes: 2 additions & 0 deletions MarkdownParserMac/en.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

22 changes: 22 additions & 0 deletions MarkdownParserMacTests/MarkdownParserMacTests-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
8 changes: 8 additions & 0 deletions MarkdownParserMacTests/MarkdownParserMacTests-Prefix.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// Prefix header for all source files of the 'MarkdownParserMacTests' target in the 'MarkdownParserMacTests' project
//

#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import "OS-X-ObjC-Compatibility.h"
#endif
2 changes: 2 additions & 0 deletions MarkdownParserMacTests/en.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

4 changes: 4 additions & 0 deletions Source/BOMarkdownParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

#import <Foundation/Foundation.h>

#if __MAC_OS_X_VERSION_MIN_REQUIRED
#import "OS-X-ObjC-Compatibility.h"
#endif

@class UIFont;
@class UIColor;
@class NSMutableParagraphStyle;
Expand Down
29 changes: 24 additions & 5 deletions Source/BOMarkdownParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
#import "BOMarkdownParser.h"

#import "NSAttributedString+Markdown.h"
#import <UIKit/UIKit.h>
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <AppKit/AppKit.h>
#endif

#import "markdown.h"
#import "buffer.h"
Expand All @@ -26,7 +30,7 @@ @interface BOMarkdownParser (Private)

- (void)setupAttributes;
- (void)preParseSetupAttributes;
- (void)addAttribtuesToAttributedString:(NSMutableAttributedString *)output;
- (void)addAttributesToAttributedString:(NSMutableAttributedString *)output;

@end

Expand Down Expand Up @@ -153,7 +157,7 @@ - (NSAttributedString *)parseString:(NSString *)input;
[_output appendAttributedString:[[NSAttributedString alloc] initWithString:bufferString attributes:baseAttributes]];

[_output beginEditing];
[self addAttribtuesToAttributedString:_output];
[self addAttributesToAttributedString:_output];
[_output endEditing];

NSAttributedString *result = [_output copy];
Expand Down Expand Up @@ -182,7 +186,9 @@ - (void)setupAttributes;
self.listAttributes = @{NSParagraphStyleAttributeName: listParagraph};
self.listItemAttributes = @{};

self.font = [UIFont systemFontOfSize:[UIFont systemFontSize]];
#if TARGET_OS_IPHONE
CGFloat defaultSize = [UIFont systemFontSize];
self.font = [UIFont systemFontOfSize:defaultSize];
self.textColor = [UIColor blackColor];

self.emphasizeFont = ^(UIFont *originalFont){
Expand All @@ -194,6 +200,19 @@ - (void)setupAttributes;
CGFloat size = originalFont.pointSize;
return [UIFont boldSystemFontOfSize:size];
};
#else
CGFloat defaultSize = [UIFont systemFontSize];
self.font = [UIFont fontWithName:@"Helvetica" size:defaultSize];
self.textColor = [UIColor blackColor];

self.emphasizeFont = ^(UIFont *originalFont){
return [[NSFontManager sharedFontManager] convertFont:originalFont toHaveTrait:NSItalicFontMask];
};

self.doubleEmphasizeFont = ^(UIFont *originalFont){
return [[NSFontManager sharedFontManager] convertFont:originalFont toHaveTrait:NSBoldFontMask];
};
#endif

self.replaceLinkFont = self.doubleEmphasizeFont;
}
Expand Down Expand Up @@ -230,7 +249,7 @@ - (void)preParseSetupAttributes;
self.currentHeaderAttributes = self.headerAttributes;
}

- (void)addAttribtuesToAttributedString:(NSMutableAttributedString *)output;
- (void)addAttributesToAttributedString:(NSMutableAttributedString *)output;
{
[output updateFontAttributeInRangesWithStartMarker:startEmphMarker endMarker:endEmphMarker usingBlock:self.emphasizeFont];
[output updateFontAttributeInRangesWithStartMarker:startDoubleEmphMarker endMarker:endDoubleEmphMarker usingBlock:self.doubleEmphasizeFont];
Expand Down
7 changes: 5 additions & 2 deletions Source/NSAttributedString+Markdown.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
#import "NSAttributedString+Markdown.h"

#import <libkern/OSAtomic.h>
#import <UIKit/UIKit.h>

#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <AppKit/AppKit.h>
#endif


@implementation NSMutableAttributedString (BOMarkers)
Expand Down
32 changes: 32 additions & 0 deletions Source/OS-X-ObjC-Compatibility.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef _OS_X_OBJC_COMPATIBILITY_H_
#define _OS_X_OBJC_COMPATIBILITY_H_

#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED

#import <MarkdownParserMac/NSFont+UIKitAdditions.h>


// Types
#define UIImage NSImage
#define UIFont NSFont
#define UIColor NSColor

#define CGSize NSSize
#define CGPoint NSPoint
#define CGRect NSRect

// Functions
#define CGSizeMake NSMakeSize
#define CGPointMake NSMakePoint
#define CGRectMake NSMakeRect
#define CGRectDivide NSDivideRect

// Constants
#define CGRectMinXEdge NSMinXEdge
#define CGRectMinYEdge NSMinYEdge
#define CGRectMaxXEdge NSMaxXEdge
#define CGRectMaxYEdge NSMaxYEdge

#endif

#endif /* _OS_X_OBJC_COMPATIBILITY_H_ */
Loading