Skip to content

Commit b7adfa0

Browse files
Fixes links that contain special characters in the aria-label (#113)
* Fixes links that contain special characters in the aria-label This improvement fixes links such as [Alt text](https://www.website.com/ "some-test"), which has a special character in the aria-label "Some-test" Co-authored-by: Jim van Zummeren <[email protected]>
1 parent c420061 commit b7adfa0

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

Example/Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
PODS:
2-
- markymark (10.1.1)
2+
- markymark (10.1.2)
33
- SwiftLint (0.28.1)
44

55
DEPENDENCIES:
66
- markymark (from `../`)
77
- SwiftLint
88

99
SPEC REPOS:
10-
https://github.com/CocoaPods/Specs.git:
10+
trunk:
1111
- SwiftLint
1212

1313
EXTERNAL SOURCES:
1414
markymark:
1515
:path: "../"
1616

1717
SPEC CHECKSUMS:
18-
markymark: 29adb8789fa6b3db97b04b7585d65f13931b5aa5
18+
markymark: 98903145fd4c412c9b7836c6a40e427652e8cca2
1919
SwiftLint: 7f5f7de0da74a649b16616cb5246ae323489656e
2020

2121
PODFILE CHECKSUM: e6179d5e64bda0057471cea1521ff93bf207a88b
2222

23-
COCOAPODS: 1.10.1
23+
COCOAPODS: 1.11.2

Example/Tests/Rules/Inline/LinkRuleTests.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class LinkRuleTests: XCTestCase {
1919
XCTAssertTrue(sut.recognizesLines(["[Alt text](image.png)"]))
2020
XCTAssertFalse((sut.recognizesLines(["![Alt text](image.png)"])))
2121
XCTAssertTrue(sut.recognizesLines([#"[Alt text](image.png "some title")"#]))
22+
XCTAssertTrue(sut.recognizesLines([#"[Alt text](https://www.website.com/ "some-test")"#]))
2223
}
2324

2425
func test_DoesNotRecognizeLines_When_PrefixedWithExclamationMark() {
@@ -54,6 +55,18 @@ class LinkRuleTests: XCTestCase {
5455
XCTAssertEqual((markDownItem2 as! LinkMarkDownItem).url, "http://www.youtube.com")
5556
}
5657

58+
func testCreateMarkDownItemContainsCorrectLinkWhenUsingAriaLabel() {
59+
// Act
60+
let markDownItem = sut.createMarkDownItemWithLines([#"[Google](http://www.google.com "Google")"#])
61+
let markDownItem2 = sut.createMarkDownItemWithLines([#"[Youtube](http://www.youtube.com "You-tube")"#])
62+
63+
// Assert
64+
XCTAssertEqual((markDownItem as! LinkMarkDownItem).content, "Google")
65+
XCTAssertEqual((markDownItem as! LinkMarkDownItem).url, "http://www.google.com")
66+
XCTAssertEqual((markDownItem2 as! LinkMarkDownItem).content, "Youtube")
67+
XCTAssertEqual((markDownItem2 as! LinkMarkDownItem).url, "http://www.youtube.com")
68+
}
69+
5770
func testGetAllMatches() {
5871
// Arrange
5972
let expectedMatchesRange = NSRange(location: 0, length: 32)

Example/markymark.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>BuildSystemType</key>
6-
<string>Original</string>
5+
<key>PreviewsEnabled</key>
6+
<false/>
77
</dict>
88
</plist>

markymark.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "markymark"
3-
s.version = "10.1.2"
3+
s.version = "10.1.3"
44
s.summary = "Markdown parser for iOS"
55
s.description = <<-DESC
66
Marky Mark is a parser written in Swift that converts markdown into native views. The way it looks is highly customizable and the supported markdown syntax and tags are easy to extend.

markymark/Classes/Rules/Inline/LinkRule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ open class LinkRule: InlineRegexRule {
1212
/// Example: [Google](http://www.google.com "with custom title")
1313
open var expression = NSRegularExpression.expressionWithPattern(
1414
// [ title ] ( URL " optional title " )
15-
#"(?<!!\p{Z}?)\[{1}(.+?)\]\({1}(.+?)( "[[:alnum:][:space:]^"]+")?\)"#
15+
#"(?<!!\p{Z}?)\[{1}(.+?)\]\({1}(.+?)( "[[:print:]^"]+")?\)"#
1616
)
1717

1818
// MARK: Rule

0 commit comments

Comments
 (0)