Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Unified Diff: third_party/pkg/markdown/test/markdown_test.dart

Issue 189333002: pkg/docgen: update markdown to 0.5.1 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updates Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/pkg/markdown/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pkg/markdown/test/markdown_test.dart
diff --git a/third_party/pkg/markdown/test/markdown_test.dart b/third_party/pkg/markdown/test/markdown_test.dart
index 6a3a0d0679b99fee20cbb128c8cfa0ea8c8e1419..3c4564b13f5e7cc948b17d8a5fa72c4b734ab485 100644
--- a/third_party/pkg/markdown/test/markdown_test.dart
+++ b/third_party/pkg/markdown/test/markdown_test.dart
@@ -6,9 +6,7 @@
library markdownTests;
import 'package:unittest/unittest.dart';
-
-// TODO(rnystrom): Use "package:" URL (#4968).
-import '../lib/markdown.dart';
+import 'package:markdown/markdown.dart';
/// Most of these tests are based on observing how showdown behaves:
/// http://softwaremaniacs.org/playground/showdown-highlight/
@@ -439,7 +437,7 @@ void main() {
code
```
''', '''
- <pre><code>code
+ <pre class="dart"><code>code
</code></pre>
''');
@@ -451,6 +449,37 @@ void main() {
<pre><code>&lt;&amp;&gt;
</code></pre>
''');
+
+ validate('Pandoc style without language identifier', '''
+ ~~~~~
+ code
+ ~~~~~
+ ''', '''
+ <pre><code>code
+ </code></pre>
+ ''');
+
+ validate('Pandoc style with language identifier', '''
+ ~~~~~dart
+ code
+ ~~~~~
+ ''', '''
+ <pre class="dart"><code>code
+ </code></pre>
+ ''');
+
+ validate('Pandoc style with inner tildes row', '''
+ ~~~~~
+ ~~~
+ code
+ ~~~
+ ~~~~~
+ ''', '''
+ <pre><code>~~~
+ code
+ ~~~
+ </code></pre>
+ ''');
});
group('Horizontal rules', () {
@@ -860,6 +889,46 @@ void main() {
// things are not quite working properly. The regexps are sometime a little
// too greedy, I think.
});
+
+ group('Inline only', () {
+ validate('simple line', '''
+ This would normally create a paragraph.
+ ''', '''
+ This would normally create a paragraph.
+ ''', inlineOnly: true);
+ validate('strong and em', '''
+ This would _normally_ create a **paragraph**.
+ ''', '''
+ This would <em>normally</em> create a <strong>paragraph</strong>.
+ ''', inlineOnly: true);
+ validate('link', '''
+ This [link](http://www.example.com/) will work normally.
+ ''', '''
+ This <a href="http://www.example.com/">link</a> will work normally.
+ ''', inlineOnly: true);
+ validate('references do not work', '''
+ [This][] shouldn't work, though.
+ ''', '''
+ [This][] shouldn't work, though.
+ ''', inlineOnly: true);
+ validate('less than and ampersand are escaped', '''
+ < &
+ ''', '''
+ &lt; &amp;
+ ''', inlineOnly: true);
+ validate('keeps newlines', '''
+ This paragraph
+ continues after a newline.
+ ''', '''
+ This paragraph
+ continues after a newline.
+ ''', inlineOnly: true);
+ validate('ignores block-level markdown syntax', '''
+ 1. This will not be an <ol>.
+ ''', '''
+ 1. This will not be an &lt;ol>.
+ ''', inlineOnly: true);
+ });
}
/**
@@ -890,33 +959,33 @@ String cleanUpLiteral(String text) {
return lines.join('\n');
}
-validate(String description, String markdown, String html,
- {bool verbose: false, inlineSyntaxes, linkResolver}) {
+void validate(String description, String markdown, String html,
+ {bool verbose: false, inlineSyntaxes, linkResolver,
+ bool inlineOnly: false}) {
test(description, () {
markdown = cleanUpLiteral(markdown);
html = cleanUpLiteral(html);
var result = markdownToHtml(markdown, inlineSyntaxes: inlineSyntaxes,
- linkResolver: linkResolver);
+ linkResolver: linkResolver, inlineOnly: inlineOnly);
var passed = compareOutput(html, result);
if (!passed) {
// Remove trailing newline.
html = html.substring(0, html.length - 1);
- print('FAIL: $description');
- print(' expect: ${html.replaceAll("\n", "\n ")}');
- print(' actual: ${result.replaceAll("\n", "\n ")}');
- print('');
- }
+ var sb = new StringBuffer();
+ sb.writeln('Expected: ${html.replaceAll("\n", "\n ")}');
+ sb.writeln(' Actual: ${result.replaceAll("\n", "\n ")}');
- expect(passed, isTrue, verbose: verbose);
+ fail(sb.toString());
+ }
});
}
/// Does a loose comparison of the two strings of HTML. Ignores differences in
/// newlines and indentation.
-compareOutput(String a, String b) {
+bool compareOutput(String a, String b) {
int i = 0;
int j = 0;
« no previous file with comments | « third_party/pkg/markdown/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698