Warning, /education/cantor/thirdparty/discount-2.2.6-patched/tests/linkylinky.t is written in an unsupported language. File is not indexed.

0001 . tests/functions.sh
0002 
0003 title "embedded links"
0004 
0005 rc=0
0006 MARKDOWN_FLAGS=
0007 
0008 try 'url contains &' '[hehehe](u&rl)' '<p><a href="u&amp;rl">hehehe</a></p>'
0009 try 'url contains +' '[hehehe](u+rl)' '<p><a href="u+rl">hehehe</a></p>'
0010 try 'url contains "' '[hehehe](u"rl)' '<p><a href="u%22rl">hehehe</a></p>'
0011 try 'url contains <' '[hehehe](u<rl)' '<p><a href="u&lt;rl">hehehe</a></p>'
0012 try 'url contains whitespace' '[ha](r u)' '<p><a href="r%20u">ha</a></p>'
0013 
0014 # latex collides with this test
0015 if ./markdown -V | grep LATEX >/dev/null; then
0016     RESULT='<p><a href="d">a\[b\]c</a></p>'
0017 else
0018     RESULT='<p><a href="d">a[b]c</a></p>'
0019 fi
0020 try 'label contains escaped []s' '[a\[b\]c](d)' "$RESULT"
0021 
0022 try '<label> w/o title' '[hello](<sailor>)' '<p><a href="sailor">hello</a></p>'
0023 try '<label> with title' '[hello](<sailor> "boy")' '<p><a href="sailor" title="boy">hello</a></p>'
0024 try '<label> with whitespace' '[hello](  <sailor> )' '<p><a href="sailor">hello</a></p>'
0025 
0026 try 'url contains whitespace & title' \
0027     '[hehehe](r u "there")' \
0028     '<p><a href="r%20u" title="there">hehehe</a></p>'
0029 
0030 try 'url contains escaped )' \
0031     '[hehehe](u\))' \
0032     '<p><a href="u)">hehehe</a></p>'
0033 
0034 try 'image label contains <' \
0035     '![he<he<he](url)' \
0036     '<p><img src="url" alt="he&lt;he&lt;he" /></p>'
0037 
0038 try 'image label contains >' \
0039     '![he>he>he](url)' \
0040     '<p><img src="url" alt="he&gt;he&gt;he" /></p>'
0041 
0042 try 'sloppy context link' \
0043     '[heh]( url "how about it?" )' \
0044     '<p><a href="url" title="how about it?">heh</a></p>'
0045 
0046 try 'footnote urls formed properly' \
0047     '[hehehe]: hohoho "ha ha"
0048 
0049 [hehehe][]' \
0050     '<p><a href="hohoho" title="ha ha">hehehe</a></p>'
0051 
0052 try 'linky-like []s work' \
0053     '[foo]' \
0054     '<p>[foo]</p>'
0055 
0056 try 'pseudo-protocol "id:"'\
0057     '[foo](id:bar)' \
0058     '<p><span id="bar">foo</span></p>'
0059 
0060 try 'pseudo-protocol "class:"' \
0061     '[foo](class:bar)' \
0062     '<p><span class="bar">foo</span></p>'
0063 
0064 try 'pseudo-protocol "abbr:"'\
0065     '[foo](abbr:bar)' \
0066     '<p><abbr title="bar">foo</abbr></p>'
0067 
0068 try 'nested [][]s' \
0069     '[[z](y)](x)' \
0070     '<p><a href="x">[z](y)</a></p>'
0071 
0072 try 'empty [][] tags' \
0073     '[![][1]][2]
0074 
0075 [1]: image1
0076 [2]: image2' \
0077     '<p><a href="image2"><img src="image1" alt="" /></a></p>'
0078 
0079 try 'footnote cuddled up to text' \
0080 'foo
0081 [bar]:bar' \
0082     '<p>foo</p>'
0083 
0084 try 'mid-paragraph footnote' \
0085 'talk talk talk talk
0086 [bar]: bar
0087 talk talk talk talk' \
0088 '<p>talk talk talk talk
0089 talk talk talk talk</p>'
0090 
0091 try 'mid-blockquote footnote' \
0092 '>blockquote!
0093 [footnote]: here!
0094 >blockquote!' \
0095 '<blockquote><p>blockquote!
0096 blockquote!</p></blockquote>'
0097 
0098 try 'end-blockquote footnote' \
0099 '>blockquote!
0100 >blockquote!
0101 [footnote]: here!' \
0102 '<blockquote><p>blockquote!
0103 blockquote!</p></blockquote>'
0104 
0105 try 'start-blockquote footnote' \
0106 '[footnote]: here!
0107 >blockquote!
0108 >blockquote!' \
0109 '<blockquote><p>blockquote!
0110 blockquote!</p></blockquote>'
0111 
0112 try '[text] (text) not a link' \
0113 '[test] (me)' \
0114 '<p>[test] (me)</p>'
0115 
0116 try '[test] [this] w/ one space between' \
0117 '[test] [this]
0118 [test]: yay!
0119 [this]: nay!' \
0120 '<p><a href="nay!">test</a></p>'
0121 
0122 try '[test] [this] w/ two spaces between' \
0123 '[test]  [this]
0124 [test]: yay!
0125 [this]: nay!' \
0126 '<p><a href="yay!">test</a>  <a href="nay!">this</a></p>'
0127 
0128 try -f1.0 'link with <> (-f1.0)' \
0129           '[this](<is a (test)>)' \
0130           '<p><a href="is%20a%20(test">this</a>>)</p>'
0131 
0132 try       'link with <>' \
0133           '[this](<is a (test)>)' \
0134           '<p><a href="is%20a%20(test)">this</a></p>'
0135 
0136 summary $0
0137 exit $rc