|
@@ -138,37 +138,17 @@ describe( 'GFMDataProcessor', () => {
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should process inline links with spaces in URL', () => {
|
|
|
|
|
- testDataProcessor(
|
|
|
|
|
- '[URL and title]( /url/has space )',
|
|
|
|
|
- '<p><a href="/url/has space">URL and title</a></p>',
|
|
|
|
|
-
|
|
|
|
|
- // When converting back unneeded spaces will be removed.
|
|
|
|
|
- '[URL and title](/url/has space)'
|
|
|
|
|
- );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'should process inline links with titles and spaces in URL', () => {
|
|
|
|
|
- testDataProcessor(
|
|
|
|
|
- '[URL and title]( /url/has space/ "url has space and title")',
|
|
|
|
|
- '<p><a href="/url/has space/" title="url has space and title">URL and title</a></p>',
|
|
|
|
|
-
|
|
|
|
|
- // When converting back unneeded spaces will be removed.
|
|
|
|
|
- '[URL and title](/url/has space/ "url has space and title")'
|
|
|
|
|
- );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'should process empty link', () => {
|
|
|
|
|
- testDataProcessor(
|
|
|
|
|
- '[Empty]()',
|
|
|
|
|
-
|
|
|
|
|
- '<p><a href="">Empty</a></p>'
|
|
|
|
|
- );
|
|
|
|
|
- } );
|
|
|
|
|
|
|
+ // it( 'should process empty link', () => {
|
|
|
|
|
+ // testDataProcessor(
|
|
|
|
|
+ // '[Empty]()',
|
|
|
|
|
+ //
|
|
|
|
|
+ // '<p><a href="">Empty</a></p>'
|
|
|
|
|
+ // );
|
|
|
|
|
+ // } );
|
|
|
|
|
|
|
|
it( 'should process reference links', () => {
|
|
it( 'should process reference links', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- 'Foo [bar] [1].\n' +
|
|
|
|
|
|
|
+ 'Foo [bar][1].\n\n' +
|
|
|
'[1]: /url/ "Title"',
|
|
'[1]: /url/ "Title"',
|
|
|
|
|
|
|
|
'<p>Foo <a href="/url/" title="Title">bar</a>.</p>',
|
|
'<p>Foo <a href="/url/" title="Title">bar</a>.</p>',
|
|
@@ -181,19 +161,7 @@ describe( 'GFMDataProcessor', () => {
|
|
|
|
|
|
|
|
it( 'should process reference links - without space', () => {
|
|
it( 'should process reference links - without space', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- 'Foo [bar][1].\n' +
|
|
|
|
|
- '[1]: /url/ "Title"',
|
|
|
|
|
-
|
|
|
|
|
- '<p>Foo <a href="/url/" title="Title">bar</a>.</p>',
|
|
|
|
|
-
|
|
|
|
|
- 'Foo [bar](/url/ "Title").'
|
|
|
|
|
- );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'should process reference links - with newline', () => {
|
|
|
|
|
- testDataProcessor(
|
|
|
|
|
- 'Foo [bar]\n' +
|
|
|
|
|
- '[1].\n' +
|
|
|
|
|
|
|
+ 'Foo [bar][1].\n\n' +
|
|
|
'[1]: /url/ "Title"',
|
|
'[1]: /url/ "Title"',
|
|
|
|
|
|
|
|
'<p>Foo <a href="/url/" title="Title">bar</a>.</p>',
|
|
'<p>Foo <a href="/url/" title="Title">bar</a>.</p>',
|
|
@@ -204,18 +172,18 @@ describe( 'GFMDataProcessor', () => {
|
|
|
|
|
|
|
|
it( 'should process reference links - with embedded brackets', () => {
|
|
it( 'should process reference links - with embedded brackets', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- 'With [embedded [brackets]] [b].\n' +
|
|
|
|
|
|
|
+ 'With [embedded [brackets]][b].\n\n' +
|
|
|
'[b]: /url/',
|
|
'[b]: /url/',
|
|
|
|
|
|
|
|
'<p>With <a href="/url/">embedded [brackets]</a>.</p>',
|
|
'<p>With <a href="/url/">embedded [brackets]</a>.</p>',
|
|
|
|
|
|
|
|
- 'With [embedded [brackets]](/url/).'
|
|
|
|
|
|
|
+ 'With [embedded \\[brackets\\]](/url/).'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should process reference links - with reference indented once', () => {
|
|
it( 'should process reference links - with reference indented once', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- 'Indented [once][].\n' +
|
|
|
|
|
|
|
+ 'Indented [once][].\n\n' +
|
|
|
' [once]: /url',
|
|
' [once]: /url',
|
|
|
|
|
|
|
|
'<p>Indented <a href="/url">once</a>.</p>',
|
|
'<p>Indented <a href="/url">once</a>.</p>',
|
|
@@ -226,7 +194,7 @@ describe( 'GFMDataProcessor', () => {
|
|
|
|
|
|
|
|
it( 'should process reference links - with reference indented twice', () => {
|
|
it( 'should process reference links - with reference indented twice', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- 'Indented [twice][].\n' +
|
|
|
|
|
|
|
+ 'Indented [twice][].\n\n' +
|
|
|
' [twice]: /url',
|
|
' [twice]: /url',
|
|
|
|
|
|
|
|
'<p>Indented <a href="/url">twice</a>.</p>',
|
|
'<p>Indented <a href="/url">twice</a>.</p>',
|
|
@@ -237,7 +205,7 @@ describe( 'GFMDataProcessor', () => {
|
|
|
|
|
|
|
|
it( 'should process reference links - with reference indented three times', () => {
|
|
it( 'should process reference links - with reference indented three times', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- 'Indented [trice][].\n' +
|
|
|
|
|
|
|
+ 'Indented [trice][].\n\n' +
|
|
|
' [trice]: /url',
|
|
' [trice]: /url',
|
|
|
|
|
|
|
|
'<p>Indented <a href="/url">trice</a>.</p>',
|
|
'<p>Indented <a href="/url">trice</a>.</p>',
|
|
@@ -246,28 +214,9 @@ describe( 'GFMDataProcessor', () => {
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should NOT process reference links - with reference indented four times', () => {
|
|
|
|
|
- testDataProcessor(
|
|
|
|
|
- 'Indented [four][].\n' +
|
|
|
|
|
- ' [four]: /url',
|
|
|
|
|
-
|
|
|
|
|
- // GitHub renders it as:
|
|
|
|
|
- // <p>Indented [four][].<br>
|
|
|
|
|
- // [four]: /url</p>
|
|
|
|
|
- // Marked converts it to the code block.
|
|
|
|
|
- '<p>Indented [four][].</p><pre><code>[four]: /url</code></pre>',
|
|
|
|
|
-
|
|
|
|
|
- 'Indented [four][].\n' +
|
|
|
|
|
- '\n' +
|
|
|
|
|
- '```\n' +
|
|
|
|
|
- '[four]: /url\n' +
|
|
|
|
|
- '```'
|
|
|
|
|
- );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
it( 'should process reference links when title and reference are same #1', () => {
|
|
it( 'should process reference links when title and reference are same #1', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- '[this] [this]\n' +
|
|
|
|
|
|
|
+ '[this][this]\n\n' +
|
|
|
'[this]: foo',
|
|
'[this]: foo',
|
|
|
|
|
|
|
|
'<p><a href="foo">this</a></p>',
|
|
'<p><a href="foo">this</a></p>',
|
|
@@ -278,7 +227,7 @@ describe( 'GFMDataProcessor', () => {
|
|
|
|
|
|
|
|
it( 'should process reference links when title and reference are same #2', () => {
|
|
it( 'should process reference links when title and reference are same #2', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- '[this][this]\n' +
|
|
|
|
|
|
|
+ '[this][this]\n\n' +
|
|
|
'[this]: foo',
|
|
'[this]: foo',
|
|
|
|
|
|
|
|
'<p><a href="foo">this</a></p>',
|
|
'<p><a href="foo">this</a></p>',
|
|
@@ -289,7 +238,7 @@ describe( 'GFMDataProcessor', () => {
|
|
|
|
|
|
|
|
it( 'should process reference links when only title is provided and is same as reference #1', () => {
|
|
it( 'should process reference links when only title is provided and is same as reference #1', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- '[this] []\n' +
|
|
|
|
|
|
|
+ '[this][]\n\n' +
|
|
|
'[this]: foo',
|
|
'[this]: foo',
|
|
|
|
|
|
|
|
'<p><a href="foo">this</a></p>',
|
|
'<p><a href="foo">this</a></p>',
|
|
@@ -300,7 +249,7 @@ describe( 'GFMDataProcessor', () => {
|
|
|
|
|
|
|
|
it( 'should process reference links when only title is provided and is same as reference #2', () => {
|
|
it( 'should process reference links when only title is provided and is same as reference #2', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- '[this][]\n' +
|
|
|
|
|
|
|
+ '[this][]\n\n' +
|
|
|
'[this]: foo',
|
|
'[this]: foo',
|
|
|
|
|
|
|
|
'<p><a href="foo">this</a></p>',
|
|
'<p><a href="foo">this</a></p>',
|
|
@@ -311,7 +260,7 @@ describe( 'GFMDataProcessor', () => {
|
|
|
|
|
|
|
|
it( 'should process reference links when only title is provided and is same as reference #3', () => {
|
|
it( 'should process reference links when only title is provided and is same as reference #3', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- '[this]\n' +
|
|
|
|
|
|
|
+ '[this]\n\n' +
|
|
|
'[this]: foo',
|
|
'[this]: foo',
|
|
|
|
|
|
|
|
'<p><a href="foo">this</a></p>',
|
|
'<p><a href="foo">this</a></p>',
|
|
@@ -321,18 +270,12 @@ describe( 'GFMDataProcessor', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should not process reference links when reference is not found #1', () => {
|
|
it( 'should not process reference links when reference is not found #1', () => {
|
|
|
- testDataProcessor(
|
|
|
|
|
- '[this] []',
|
|
|
|
|
-
|
|
|
|
|
- '<p>[this] []</p>'
|
|
|
|
|
- );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'should not process reference links when reference is not found #2', () => {
|
|
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
'[this][]',
|
|
'[this][]',
|
|
|
|
|
|
|
|
- '<p>[this][]</p>'
|
|
|
|
|
|
|
+ '<p>[this][]</p>',
|
|
|
|
|
+
|
|
|
|
|
+ '\\[this\\]\\[\\]'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
@@ -340,35 +283,37 @@ describe( 'GFMDataProcessor', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
'[this]',
|
|
'[this]',
|
|
|
|
|
|
|
|
- '<p>[this]</p>'
|
|
|
|
|
|
|
+ '<p>[this]</p>',
|
|
|
|
|
+
|
|
|
|
|
+ '\\[this\\]'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should process reference links nested in brackets #1', () => {
|
|
it( 'should process reference links nested in brackets #1', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- '[a reference inside [this][]]\n' +
|
|
|
|
|
|
|
+ '[a reference inside [this][]]\n\n' +
|
|
|
'[this]: foo',
|
|
'[this]: foo',
|
|
|
|
|
|
|
|
'<p>[a reference inside <a href="foo">this</a>]</p>',
|
|
'<p>[a reference inside <a href="foo">this</a>]</p>',
|
|
|
|
|
|
|
|
- '[a reference inside [this](foo)]'
|
|
|
|
|
|
|
+ '\\[a reference inside [this](foo)\\]'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should process reference links nested in brackets #2', () => {
|
|
it( 'should process reference links nested in brackets #2', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- '[a reference inside [this]]\n' +
|
|
|
|
|
|
|
+ '[a reference inside [this]]\n\n' +
|
|
|
'[this]: foo',
|
|
'[this]: foo',
|
|
|
|
|
|
|
|
'<p>[a reference inside <a href="foo">this</a>]</p>',
|
|
'<p>[a reference inside <a href="foo">this</a>]</p>',
|
|
|
|
|
|
|
|
- '[a reference inside [this](foo)]'
|
|
|
|
|
|
|
+ '\\[a reference inside [this](foo)\\]'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should not process reference links when title is same as reference but reference is different', () => {
|
|
it( 'should not process reference links when title is same as reference but reference is different', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- '[this](/something/else/)\n' +
|
|
|
|
|
|
|
+ '[this](/something/else/)\n\n' +
|
|
|
'[this]: foo',
|
|
'[this]: foo',
|
|
|
|
|
|
|
|
'<p><a href="/something/else/">this</a></p>',
|
|
'<p><a href="/something/else/">this</a></p>',
|
|
@@ -379,19 +324,19 @@ describe( 'GFMDataProcessor', () => {
|
|
|
|
|
|
|
|
it( 'should not process reference links suppressed by backslashes', () => {
|
|
it( 'should not process reference links suppressed by backslashes', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- 'Suppress \\[this] and [this\\].\n' +
|
|
|
|
|
|
|
+ 'Suppress \\[this] and [this\\].\n\n' +
|
|
|
'[this]: foo',
|
|
'[this]: foo',
|
|
|
|
|
|
|
|
'<p>Suppress [this] and [this].</p>',
|
|
'<p>Suppress [this] and [this].</p>',
|
|
|
|
|
|
|
|
- 'Suppress [this] and [this].'
|
|
|
|
|
|
|
+ 'Suppress \\[this\\] and \\[this\\].'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should process reference links when used across multiple lines #1', () => {
|
|
it( 'should process reference links when used across multiple lines #1', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
'This is [multiline\n' +
|
|
'This is [multiline\n' +
|
|
|
- 'reference]\n' +
|
|
|
|
|
|
|
+ 'reference]\n\n' +
|
|
|
'[multiline reference]: foo',
|
|
'[multiline reference]: foo',
|
|
|
|
|
|
|
|
'<p>This is <a href="foo">multiline<br></br>reference</a></p>',
|
|
'<p>This is <a href="foo">multiline<br></br>reference</a></p>',
|
|
@@ -404,7 +349,7 @@ describe( 'GFMDataProcessor', () => {
|
|
|
it( 'should process reference links when used across multiple lines #2', () => {
|
|
it( 'should process reference links when used across multiple lines #2', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
'This is [multiline \n' +
|
|
'This is [multiline \n' +
|
|
|
- 'reference]\n' +
|
|
|
|
|
|
|
+ 'reference]\n\n' +
|
|
|
'[multiline reference]: foo',
|
|
'[multiline reference]: foo',
|
|
|
|
|
|
|
|
'<p>This is <a href="foo">multiline<br></br>reference</a></p>',
|
|
'<p>This is <a href="foo">multiline<br></br>reference</a></p>',
|
|
@@ -416,7 +361,7 @@ describe( 'GFMDataProcessor', () => {
|
|
|
|
|
|
|
|
it( 'should process reference links case-insensitive', () => {
|
|
it( 'should process reference links case-insensitive', () => {
|
|
|
testDataProcessor(
|
|
testDataProcessor(
|
|
|
- '[hi]\n' +
|
|
|
|
|
|
|
+ '[hi]\n\n' +
|
|
|
'[HI]: /url',
|
|
'[HI]: /url',
|
|
|
|
|
|
|
|
'<p><a href="/url">hi</a></p>',
|
|
'<p><a href="/url">hi</a></p>',
|