Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-n committed Nov 30, 2020
2 parents 6af6616 + 7f3ef7d commit 714017d
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 5 deletions.
12 changes: 12 additions & 0 deletions Sources/HighlightedTextEditor/Presets/Markdown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ fileprivate let inlineCodeRegex = try! NSRegularExpression(pattern: "`[^`]*`", o
fileprivate let codeBlockRegex = try! NSRegularExpression(pattern: "(`){3}((?!\\1).)+\\1{3}", options: [.dotMatchesLineSeparators])
fileprivate let headingRegex = try! NSRegularExpression(pattern: "^#{1,6}\\s.*$", options: [.anchorsMatchLines])
fileprivate let linkOrImageRegex = try! NSRegularExpression(pattern: "!?\\[([^\\[\\]]*)\\]\\((.*?)\\)", options: [])
fileprivate let linkOrImageTagRegex = try! NSRegularExpression(pattern: "!?\\[([^\\[\\]]*)\\]\\[(.*?)\\]", options: [])
fileprivate let boldRegex = try! NSRegularExpression(pattern: "((\\*|_){2})((?!\\1).)+\\1", options: [])
fileprivate let underscoreEmphasisRegex = try! NSRegularExpression(pattern: "(?<!_)_[^_]+_(?!\\*)", options: [])
fileprivate let asteriskEmphasisRegex = try! NSRegularExpression(pattern: "(?<!\\*)(\\*)((?!\\1).)+\\1(?!\\*)", options: [])
Expand All @@ -15,6 +16,10 @@ fileprivate let unorderedListRegex = try! NSRegularExpression(pattern: "^(\\-|\\
fileprivate let orderedListRegex = try! NSRegularExpression(pattern: "^\\d*\\.\\s", options: [.anchorsMatchLines])
fileprivate let buttonRegex = try! NSRegularExpression(pattern: "<\\s*button[^>]*>(.*?)<\\s*/\\s*button>", options: [])
fileprivate let strikethroughRegex = try! NSRegularExpression(pattern: "(~)((?!\\1).)+\\1", options: [])
fileprivate let tagRegex = try! NSRegularExpression(pattern: "^\\[([^\\[\\]]*)\\]:", options: [.anchorsMatchLines])
fileprivate let footnoteRegex = try! NSRegularExpression(pattern: "\\[\\^(.*?)\\]", options: [])
// courtesy https://www.regular-expressions.info/examples.html
fileprivate let htmlRegex = try! NSRegularExpression(pattern: "<([A-Z][A-Z0-9]*)\\b[^>]*>(.*?)</\\1>", options: [.dotMatchesLineSeparators, .caseInsensitive])

#if os(macOS)
let codeFont = NSFont.monospacedSystemFont(ofSize: NSFont.systemFontSize, weight: .thin)
Expand Down Expand Up @@ -52,6 +57,7 @@ public extension Sequence where Iterator.Element == HighlightRule {
TextFormattingRule(key: .kern, value: 0.5)
]),
HighlightRule(pattern: linkOrImageRegex, formattingRule: TextFormattingRule(key: .underlineStyle, value: NSUnderlineStyle.single.rawValue)),
HighlightRule(pattern: linkOrImageTagRegex, formattingRule: TextFormattingRule(key: .underlineStyle, value: NSUnderlineStyle.single.rawValue)),
HighlightRule(pattern: boldRegex, formattingRule: TextFormattingRule(fontTraits: boldTraits)),
HighlightRule(pattern: asteriskEmphasisRegex, formattingRule: TextFormattingRule(fontTraits: emphasisTraits)),
HighlightRule(pattern: underscoreEmphasisRegex, formattingRule: TextFormattingRule(fontTraits: emphasisTraits)),
Expand All @@ -64,6 +70,12 @@ public extension Sequence where Iterator.Element == HighlightRule {
HighlightRule(pattern: strikethroughRegex, formattingRules: [
TextFormattingRule(key: .strikethroughStyle, value: NSUnderlineStyle.single.rawValue),
TextFormattingRule(key: .strikethroughColor, value: textColor)
]),
HighlightRule(pattern: tagRegex, formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)),
HighlightRule(pattern: footnoteRegex, formattingRule: TextFormattingRule(key: .foregroundColor, value: lighterColor)),
HighlightRule(pattern: htmlRegex, formattingRules: [
TextFormattingRule(key: .font, value: codeFont),
TextFormattingRule(key: .foregroundColor, value: lighterColor)
])
]
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Essayist/Essayist.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "file:///Users/kylenazario/apps/HighlightedTextEditor";
requirement = {
branch = main;
branch = develop;
kind = branch;
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"package": "HighlightedTextEditor",
"repositoryURL": "/Users/kylenazario/apps/HighlightedTextEditor",
"state": {
"branch": "main",
"revision": "dc0700a30c03f240f74276e5913a2a5bd52f28c9",
"branch": "develop",
"revision": "4a4bf35da682f1697b7b77c15f02f02a06c8af5c",
"version": null
}
},
Expand Down
6 changes: 6 additions & 0 deletions Tests/Essayist/iOS-EssayistUITests/MarkdownSample.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ _This is italic text_

~~Strikethrough~~

<aside>html tag</aside>

This is a footnote [^1].

[1]: Footnote content

## Blockquotes

> Blockquotes can also be nested...
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions Tests/Essayist/iOS-EssayistUITests/iOS_EssayistUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ class iOS_EssayistUITests: XCTestCase {
returnButton.tap()
app.keys["C"].tap()
app.keys["a"].tap()
sleep(2)
app.keys["r"].tap()
sleep(4)
app.keys["s"].tap()

XCTAssertEqual(hlteTextView.value as! String, "A\n\nB\n\nCars\n\nD\n\n")
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Tests/appkit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ test_project_name='Essayist'
script_dirname=$(dirname "$0")
cd $script_dirname

xcodebuild -resolvePackageDependencies
xcodebuild test -sdk macosx11.0 -destination 'platform=OS X,arch=x86_64' -scheme "$test_project_name (macOS)" -project $test_project_path

0 comments on commit 714017d

Please sign in to comment.