Skip to content

Commit

Permalink
Fixed issue xing#17 Email link detection does not work properly? and x…
Browse files Browse the repository at this point in the history
…ing#12 Ignore Acronym in URL detection
  • Loading branch information
Frank Mao committed Feb 2, 2016
1 parent 46c9237 commit 8bafc9b
Show file tree
Hide file tree
Showing 9 changed files with 12,933 additions and 10,422 deletions.
6 changes: 6 additions & 0 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
C0E302D01AE7A37600F66915 /* single_header.txt in Resources */ = {isa = PBXBuildFile; fileRef = C0E302CF1AE7A37600F66915 /* single_header.txt */; };
C0E302D11AE7A37B00F66915 /* single_header.txt in Resources */ = {isa = PBXBuildFile; fileRef = C0E302CF1AE7A37600F66915 /* single_header.txt */; };
E515B8D61C600F580038B622 /* lists.txt in Resources */ = {isa = PBXBuildFile; fileRef = E515B8D51C600F580038B622 /* lists.txt */; };
E515B8D81C61240B0038B622 /* links_ex.txt in Resources */ = {isa = PBXBuildFile; fileRef = E515B8D71C61240B0038B622 /* links_ex.txt */; };
E515B8D91C6126090038B622 /* links_ex.txt in Resources */ = {isa = PBXBuildFile; fileRef = E515B8D71C61240B0038B622 /* links_ex.txt */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -81,6 +83,7 @@
C0CF278919CB2300005EF111 /* SnapshotTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SnapshotTests.m; sourceTree = "<group>"; };
C0E302CF1AE7A37600F66915 /* single_header.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = single_header.txt; sourceTree = "<group>"; };
E515B8D51C600F580038B622 /* lists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = lists.txt; sourceTree = "<group>"; };
E515B8D71C61240B0038B622 /* links_ex.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = links_ex.txt; sourceTree = "<group>"; };
F373E2C1346E4E0B8B708C6D /* libPods-Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -191,6 +194,7 @@
children = (
C09F673C19DADE7E009CE501 /* headers.txt */,
C09F674219DAE77D009CE501 /* links.txt */,
E515B8D71C61240B0038B622 /* links_ex.txt */,
C09F674319DAE77D009CE501 /* text_styles.txt */,
C09F674B19DBE3F5009CE501 /* plaintext_utf8.txt */,
C09F674F19DBE6F9009CE501 /* paragraph_1.txt */,
Expand Down Expand Up @@ -295,6 +299,7 @@
buildActionMask = 2147483647;
files = (
C09F674719DAE98E009CE501 /* links.txt in Resources */,
E515B8D91C6126090038B622 /* links_ex.txt in Resources */,
C09F675719DBF78D009CE501 /* plaintext_utf8.txt in Resources */,
C0E302D11AE7A37B00F66915 /* single_header.txt in Resources */,
C0CF276F19CB2300005EF111 /* InfoPlist.strings in Resources */,
Expand All @@ -311,6 +316,7 @@
buildActionMask = 2147483647;
files = (
C09F675519DBE882009CE501 /* all_together_short.txt in Resources */,
E515B8D81C61240B0038B622 /* links_ex.txt in Resources */,
C0E302D01AE7A37600F66915 /* single_header.txt in Resources */,
E515B8D61C600F580038B622 /* lists.txt in Resources */,
C0CF278819CB2300005EF111 /* InfoPlist.strings in Resources */,
Expand Down
13 changes: 13 additions & 0 deletions Example/ExampleTests/Fixtures/links_ex.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Domain in email
===============

https://www.xing.com/root/path
xing.com/root/path
@xing.com/root/path
[email protected]
link inside parenthesis -> [Text] (http://google.com "alt text") urls

Acronym vs. Link
==================

Acronym like U.S.A. should not be parsed as link.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions Example/ExampleTests/SnapshotTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ - (void)testLinks {
FBSnapshotVerifyView([self labelForMarkdownStringWithDefaultAttributesFromFile:@"links.txt"], nil);
}

- (void)testLinksEx {
FBSnapshotVerifyView([self labelForMarkdownStringWithDefaultAttributesFromFile:@"links_ex.txt"], nil);
}

- (void)testTextStyles {
FBSnapshotVerifyView([self labelForMarkdownStringWithDefaultAttributesFromFile:@"text_styles.txt"], nil);
}
Expand Down
Binary file modified Example/ObjectiveC.gcda
Binary file not shown.
Binary file modified Example/ObjectiveC.gcno
Binary file not shown.
4 changes: 2 additions & 2 deletions grammar/markdown.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ bulletstart ^[\*+-]+[ ]
codeline [ ]

protocol (http|ftp)s?\:\/\/
subdomain {nmchar}+\.
subdomain [\@]?{nmchar}{2,}\.
urlpath [\/]|{nmchar}+
protourl {protocol}[^ \n]+
optprotourl {protocol}?{subdomain}*{nmchar}+\.{nmchar}+{urlpath}*?
optprotourl {subdomain}+{urlpath}*?
href \[(\\\[|[^\[])+\]\(([^\)]+)\)

em {em1}|{em2}
Expand Down
5 changes: 5 additions & 0 deletions src/XNGMarkdownParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ - (void)consumeToken:(XNGMarkdownParserCode)token text:(char *)text {
break;
}
case MARKDOWN_URL: {

if ([textAsString hasPrefix:@"@"]) {
break;
}

XNGMarkdownLink *link = [[XNGMarkdownLink alloc] init];
link.url = textAsString;
link.range = NSMakeRange(_accum.length, textAsString.length);
Expand Down
23,323 changes: 12,903 additions & 10,420 deletions src/XNGMarkdownTokenizer.m

Large diffs are not rendered by default.

0 comments on commit 8bafc9b

Please sign in to comment.