226
226
... 'debug #52\n')
227
227
>>> print test_tales('foo/fmt:text-to-html', foo=text)
228
<p><a href="/bugs/123">bug 123</a><br />
229
<a href="/bugs/123">bug 123</a><br />
230
<a href="/bugs/123">bug #123</a><br />
231
<a href="/bugs/123">bug number 123</a><br />
228
<p><a href="/bugs/123" class="bug-link">bug 123</a><br />
229
<a href="/bugs/123" class="bug-link">bug 123</a><br />
230
<a href="/bugs/123" class="bug-link">bug #123</a><br />
231
<a href="/bugs/123" class="bug-link">bug number 123</a><br />
232
232
bug number. 123<br />
233
<a href="/bugs/123">bug num 123</a><br />
234
<a href="/bugs/123">bug num. 123</a><br />
235
<a href="/bugs/123">bug no 123</a><br />
236
<a href="/bugs/123">bug report 123</a><br />
237
<a href="/bugs/123">bug no. 123</a><br />
233
<a href="/bugs/123" class="bug-link">bug num 123</a><br />
234
<a href="/bugs/123" class="bug-link">bug num. 123</a><br />
235
<a href="/bugs/123" class="bug-link">bug no 123</a><br />
236
<a href="/bugs/123" class="bug-link">bug report 123</a><br />
237
<a href="/bugs/123" class="bug-link">bug no. 123</a><br />
239
<a href="/bugs/123">bug-123</a><br />
240
<a href="/bugs/123">bug-report-123</a><br />
241
<a href="/bugs/123">bug=123</a><br />
242
<a href="/bugs/123">bug<br /> #123</a><br />
239
<a href="/bugs/123" class="bug-link">bug-123</a><br />
240
<a href="/bugs/123" class="bug-link">bug-report-123</a><br />
241
<a href="/bugs/123" class="bug-link">bug=123</a><br />
242
<a href="/bugs/123" class="bug-link">bug<br /> #123</a><br />
248
248
>>> print test_tales('foo/fmt:text-to-html', foo=text)
249
<p><a href="/bugs/123">bug 123</a><br />
250
<a href="/bugs/123">bug 123</a></p>
249
<p><a href="/bugs/123" class="bug-link">bug 123</a><br />
250
<a href="/bugs/123" class="bug-link">bug 123</a></p>
255
255
>>> print test_tales('foo/fmt:text-to-html', foo=text)
256
<p><a href="/bugs/1234">bug 1234</a><br />
257
<a href="/bugs/123">bug 123</a></p>
256
<p><a href="/bugs/1234" class="bug-link">bug 1234</a><br />
257
<a href="/bugs/123" class="bug-link">bug 123</a></p>
259
259
>>> text = 'bug 0123\n'
260
260
>>> print test_tales('foo/fmt:text-to-html', foo=text)
261
<p><a href="/bugs/123">bug 0123</a></p>
261
<p><a href="/bugs/123" class="bug-link">bug 0123</a></p>
264
264
We linkify bugs that are in the Ubuntu convention for referring to bugs in
267
267
>>> text = 'LP: #123.\n'
268
268
>>> print test_tales('foo/fmt:text-to-html', foo=text)
269
<p>LP: <a href="/bugs/123">#123</a>.</p>
269
<p>LP: <a href="/bugs/123" class="bug-link">#123</a>.</p>
271
271
Works with multiple bugs:
273
273
>>> text = 'LP: #123, #2.\n'
274
274
>>> print test_tales('foo/fmt:text-to-html', foo=text)
275
<p>LP: <a href="/bugs/123">#123</a>, <a href="/bugs/2">#2</a>.</p>
275
<p>LP: <a href="/bugs/123" class="bug-link">#123</a>, <a href="/bugs/2" class="bug-link">#2</a>.</p>
277
277
And with lower case 'lp' too:
279
279
>>> text = 'lp: #123, #2.\n'
280
280
>>> print test_tales('foo/fmt:text-to-html', foo=text)
281
<p>lp: <a href="/bugs/123">#123</a>, <a href="/bugs/2">#2</a>.</p>
281
<p>lp: <a href="/bugs/123" class="bug-link">#123</a>, <a href="/bugs/2" class="bug-link">#2</a>.</p>
283
283
Even line breaks cannot stop the power of bug linking:
285
285
>>> text = 'LP: #123,\n#2.\n'
286
286
>>> print test_tales('foo/fmt:text-to-html', foo=text)
287
<p>LP: <a href="/bugs/123">#123</a>,<br />
288
<a href="/bugs/2">#2</a>.</p>
287
<p>LP: <a href="/bugs/123" class="bug-link">#123</a>,<br />
288
<a href="/bugs/2" class="bug-link">#2</a>.</p>
290
290
To check a private bug, we need to log in and set a bug to be private.
375
375
>>> text = 'lp:1234'
376
376
>>> print test_tales('foo/fmt:text-to-html', foo=text)
377
<p><a href="/bugs/1234">lp:1234</a></p>
377
<p><a href="/bugs/1234" class="bug-link">lp:1234</a></p>
379
379
We are even smart enough to notice the trailing punctuation gunk and separate
380
380
that from the link.
382
382
>>> text = 'lp:1234,'
383
383
>>> print test_tales('foo/fmt:text-to-html', foo=text)
384
<p><a href="/bugs/1234">lp:1234</a>,</p>
384
<p><a href="/bugs/1234" class="bug-link">lp:1234</a>,</p>
387
387
== OOPS references ==
524
524
>>> sorted(matchobj.groupdict().items())
525
525
[('bug', 'xxxx'), ('bugnum', '2'), ('url', None)]
526
526
>>> FormattersAPI._linkify_substitution(matchobj)
527
'<a href="/bugs/2">xxxx</a>'
527
'<a href="/bugs/2" class="bug-link">xxxx</a>'
529
529
When the bugnum doesn't match any bug, we still get a link, but get a message
530
530
in the link's title.
534
534
>>> sorted(matchobj.groupdict().items())
535
535
[('bug', 'xxxx'), ('bugnum', '2000'), ('url', None)]
536
536
>>> FormattersAPI._linkify_substitution(matchobj)
537
'<a href="/bugs/2000">xxxx</a>'
537
'<a href="/bugs/2000" class="bug-link">xxxx</a>'