OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// Unit tests for markdown. | 5 /// Unit tests for markdown. |
6 library markdownTests; | 6 library markdownTests; |
7 | 7 |
8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
9 import 'package:markdown/markdown.dart'; | 9 import 'package:markdown/markdown.dart'; |
10 | 10 |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 ''', ''' | 855 ''', ''' |
856 <p>links <a href="http://foo.com">are</a> awesome</p> | 856 <p>links <a href="http://foo.com">are</a> awesome</p> |
857 '''); | 857 '''); |
858 validate('can style link contents', ''' | 858 validate('can style link contents', ''' |
859 links [*are*](http://foo.com) awesome | 859 links [*are*](http://foo.com) awesome |
860 ''', ''' | 860 ''', ''' |
861 <p>links <a href="http://foo.com"><em>are</em></a> awesome</p> | 861 <p>links <a href="http://foo.com"><em>are</em></a> awesome</p> |
862 '''); | 862 '''); |
863 }); | 863 }); |
864 | 864 |
| 865 group('Inline Images', () { |
| 866 validate('image',''' |
| 867 ![](http://foo.com/foo.png) |
| 868 ''',''' |
| 869 <p> |
| 870 <a href="http://foo.com/foo.png"> |
| 871 <img src="http://foo.com/foo.png"></img> |
| 872 </a> |
| 873 </p> |
| 874 '''); |
| 875 |
| 876 validate('alternate text',''' |
| 877 ![alternate text](http://foo.com/foo.png) |
| 878 ''',''' |
| 879 <p> |
| 880 <a href="http://foo.com/foo.png"> |
| 881 <img alt="alternate text" src="http://foo.com/foo.png"></img> |
| 882 </a> |
| 883 </p> |
| 884 '''); |
| 885 |
| 886 validate('title',''' |
| 887 ![](http://foo.com/foo.png "optional title") |
| 888 ''',''' |
| 889 <p> |
| 890 <a href="http://foo.com/foo.png" title="optional title"> |
| 891 <img src="http://foo.com/foo.png" title="optional title"></img> |
| 892 </a> |
| 893 </p> |
| 894 '''); |
| 895 validate('invalid alt text',''' |
| 896 ![`alt`](http://foo.com/foo.png) |
| 897 ''',''' |
| 898 <p> |
| 899 <a href="http://foo.com/foo.png"> |
| 900 <img src="http://foo.com/foo.png"></img> |
| 901 </a> |
| 902 </p> |
| 903 '''); |
| 904 }); |
| 905 |
| 906 group('Reference Images', () { |
| 907 validate('image',''' |
| 908 ![][foo] |
| 909 [foo]: http://foo.com/foo.png |
| 910 ''',''' |
| 911 <p> |
| 912 <a href="http://foo.com/foo.png"> |
| 913 <img src="http://foo.com/foo.png"></img> |
| 914 </a> |
| 915 </p> |
| 916 '''); |
| 917 |
| 918 validate('alternate text',''' |
| 919 ![alternate text][foo] |
| 920 [foo]: http://foo.com/foo.png |
| 921 ''',''' |
| 922 <p> |
| 923 <a href="http://foo.com/foo.png"> |
| 924 <img alt="alternate text" src="http://foo.com/foo.png"></img> |
| 925 </a> |
| 926 </p> |
| 927 '''); |
| 928 |
| 929 validate('title',''' |
| 930 ![][foo] |
| 931 [foo]: http://foo.com/foo.png "optional title" |
| 932 ''',''' |
| 933 <p> |
| 934 <a href="http://foo.com/foo.png" title="optional title"> |
| 935 <img src="http://foo.com/foo.png" title="optional title"></img> |
| 936 </a> |
| 937 </p> |
| 938 '''); |
| 939 |
| 940 validate('invalid alt text',''' |
| 941 ![`alt`][foo] |
| 942 [foo]: http://foo.com/foo.png "optional title" |
| 943 ''',''' |
| 944 <p> |
| 945 <a href="http://foo.com/foo.png" title="optional title"> |
| 946 <img src="http://foo.com/foo.png" title="optional title"></img> |
| 947 </a> |
| 948 </p> |
| 949 '''); |
| 950 |
| 951 }); |
| 952 |
865 group('Resolver', () { | 953 group('Resolver', () { |
866 var nyanResolver = (text) => new Text('~=[,,_${text}_,,]:3'); | 954 var nyanResolver = (text) => new Text('~=[,,_${text}_,,]:3'); |
867 validate('simple resolver', ''' | 955 validate('simple resolver', ''' |
868 resolve [this] thing | 956 resolve [this] thing |
869 ''', ''' | 957 ''', ''' |
870 <p>resolve ~=[,,_this_,,]:3 thing</p> | 958 <p>resolve ~=[,,_this_,,]:3 thing</p> |
871 ''', linkResolver: nyanResolver); | 959 ''', linkResolver: nyanResolver); |
872 }); | 960 }); |
873 | 961 |
874 group('Custom inline syntax', () { | 962 group('Custom inline syntax', () { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 | 1094 |
1007 // If one string runs out of non-ignored strings, the other must too. | 1095 // If one string runs out of non-ignored strings, the other must too. |
1008 if (i == a.length) return j == b.length; | 1096 if (i == a.length) return j == b.length; |
1009 if (j == b.length) return i == a.length; | 1097 if (j == b.length) return i == a.length; |
1010 | 1098 |
1011 if (a[i] != b[j]) return false; | 1099 if (a[i] != b[j]) return false; |
1012 i++; | 1100 i++; |
1013 j++; | 1101 j++; |
1014 } | 1102 } |
1015 } | 1103 } |
OLD | NEW |