Skip to content

Commit

Permalink
Update travis
Browse files Browse the repository at this point in the history
  • Loading branch information
freesuraj committed Dec 11, 2016
1 parent ee7b9a2 commit 03dd205
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -40,6 +40,7 @@ xcuserdata
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
Pods/
Podfile.lock

# Carthage
#
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,7 +1,7 @@
sudo: false
language: objective-c

osx_image: xcode7.2
osx_image: xcode8.0
xcode_workspace: TLDR.xcworkspace
xcode_scheme: TLDR
xcode_sdk: iphonesimulator9.2
Expand Down
1 change: 1 addition & 0 deletions TLDR/CommandManager.swift
Expand Up @@ -25,6 +25,7 @@ struct TLDRCommand: Command {
var type: String {
return nameTypeTuple.1
}

var output: NSAttributedString {
guard let content =
FileManager.contentOfFileAtTldrPages(self.nameTypeTuple.1,
Expand Down
8 changes: 8 additions & 0 deletions TLDR/MarkdownParser.swift
Expand Up @@ -9,6 +9,7 @@
import UIKit

struct MarkDownParser {

static func attributedStringOfMarkdownString(_ markdown: String) -> NSAttributedString {
let regexTypes: [RegexType] = [.title, .subTitle, .quote, .list, .block,.italic, .bold, .link]
let output = NSMutableAttributedString(string: markdown, attributes: RegexType.normal.attributes())
Expand Down Expand Up @@ -40,6 +41,7 @@ struct MarkDownParser {
output.endEditing()
return filteredOutput
}

// MARK: Regex Types
enum RegexType {
case title, subTitle, quote, list, block, italic, bold, link, normal
Expand All @@ -65,6 +67,7 @@ struct MarkDownParser {
return Regex(pattern: ".+")
}
}

// Return the attributes for the regex type
func attributes() -> [String: AnyObject] {
switch self {
Expand Down Expand Up @@ -97,6 +100,7 @@ struct MarkDownParser {
NSFontAttributeName: UIFont(name: "Courier", size: 18)!]
}
}

// Returns a tuple of Template and index of the regex group that should remain
func templateIndexToRetain() -> (String, Int) {
switch self {
Expand All @@ -120,6 +124,7 @@ struct MarkDownParser {
return ("$0", 0)
}
}

// Returns the ranges of indices of the regex group that should be deleted
func rangeIndicesToDelete() -> [Int]? {
switch self {
Expand Down Expand Up @@ -149,6 +154,7 @@ struct MarkDownParser {
struct Regex {
let internalExpression: NSRegularExpression
let pattern: String

// Initialization
init(pattern: String) {
self.pattern = pattern
Expand All @@ -158,9 +164,11 @@ struct Regex {
internalExpression = NSRegularExpression()
}
}

func matchesInString(_ input: String) -> [NSTextCheckingResult] {
// swiftlint:disable legacy_constructor
let matches = self.internalExpression.matches(in: input, options: [], range: NSMakeRange(0, input.characters.count))
return matches
}

}

0 comments on commit 03dd205

Please sign in to comment.