-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for custom link resolver (issue #2).
- Loading branch information
Showing
8 changed files
with
165 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
library referenceResolverTest; | ||
|
||
import 'package:test/test.dart' as t; | ||
|
||
import 'package:md_proc/md_proc.dart'; | ||
|
||
Target linkResolver(String normalizedReference, String reference) { | ||
if (reference == "reference") { | ||
return new Target(reference, null); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
|
||
String md1Test = r''' | ||
This is a [reference]. | ||
[reference]: reference2 | ||
'''; | ||
|
||
String md1Pattern = r''' | ||
This is a [reference]. | ||
[reference]: reference2 | ||
'''; | ||
|
||
String md2Test = r''' | ||
This is a [reference]. | ||
'''; | ||
|
||
String md2Pattern = r''' | ||
This is a [reference]. | ||
[reference]: reference | ||
'''; | ||
|
||
String md3Test = r''' | ||
This is a [link]. | ||
'''; | ||
|
||
String md3Pattern = r''' | ||
This is a [link]. | ||
'''; | ||
|
||
void referenceResolverTests() { | ||
CommonMarkParser parser = new CommonMarkParser(new Options(linkResolver: linkResolver)); | ||
CommonMarkParser defaultParser = CommonMarkParser.DEFAULT; | ||
|
||
t.group("Custom reference resolver test", () { | ||
t.test("Should leave defined links as is", () { | ||
Document d1 = parser.parse(md1Test); | ||
Document d2 = defaultParser.parse(md1Pattern); | ||
t.expect(d1, t.equals(d2)); | ||
}); | ||
t.test("May resolve undefined links", () { | ||
Document d1 = parser.parse(md2Test); | ||
Document d2 = defaultParser.parse(md2Pattern); | ||
t.expect(d1, t.equals(d2)); | ||
}); | ||
t.test("May not resolve undefined links", () { | ||
Document d1 = parser.parse(md3Test); | ||
Document d2 = defaultParser.parse(md3Pattern); | ||
t.expect(d1, t.equals(d2)); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters