Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 40c974a

Browse files
committed
docs(linky): mention sanitization, improve formatting
1 parent 06f002b commit 40c974a

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/ngSanitize/filter/linky.js

+19-18
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
* @kind function
99
*
1010
* @description
11-
* Finds links in text input and turns them into html links. Supports http/https/ftp/mailto and
11+
* Finds links in text input and turns them into html links. Supports `http/https/ftp/mailto` and
1212
* plain email address links.
1313
*
1414
* Requires the {@link ngSanitize `ngSanitize`} module to be installed.
1515
*
1616
* @param {string} text Input text.
17-
* @param {string} target Window (_blank|_self|_parent|_top) or named frame to open links in.
17+
* @param {string} target Window (`_blank|_self|_parent|_top`) or named frame to open links in.
1818
* @param {object|function(url)} [attributes] Add custom attributes to the link element.
1919
*
2020
* Can be one of:
@@ -25,33 +25,22 @@
2525
* If the map of attributes contains a value for `target`, it overrides the value of
2626
* the target parameter.
2727
*
28-
* @returns {string} Html-linkified text.
28+
*
29+
* @returns {string} Html-linkified and {@link $sanitize sanitized} text.
2930
*
3031
* @usage
3132
<span ng-bind-html="linky_expression | linky"></span>
3233
*
3334
* @example
3435
<example module="linkyExample" deps="angular-sanitize.js">
3536
<file name="index.html">
36-
<script>
37-
angular.module('linkyExample', ['ngSanitize'])
38-
.controller('ExampleController', ['$scope', function($scope) {
39-
$scope.snippet =
40-
'Pretty text with some links:\n'+
41-
'http://angularjs.org/,\n'+
42-
'mailto:us@somewhere.org,\n'+
43-
44-
'and one more: ftp://127.0.0.1/.';
45-
$scope.snippetWithSingleURL = 'http://angularjs.org/';
46-
}]);
47-
</script>
4837
<div ng-controller="ExampleController">
4938
Snippet: <textarea ng-model="snippet" cols="60" rows="3"></textarea>
5039
<table>
5140
<tr>
52-
<td>Filter</td>
53-
<td>Source</td>
54-
<td>Rendered</td>
41+
<th>Filter</th>
42+
<th>Source</th>
43+
<th>Rendered</th>
5544
</tr>
5645
<tr id="linky-filter">
5746
<td>linky filter</td>
@@ -87,6 +76,18 @@
8776
</tr>
8877
</table>
8978
</file>
79+
<file name="script.js">
80+
angular.module('linkyExample', ['ngSanitize'])
81+
.controller('ExampleController', ['$scope', function($scope) {
82+
$scope.snippet =
83+
'Pretty text with some links:\n'+
84+
'http://angularjs.org/,\n'+
85+
'mailto:us@somewhere.org,\n'+
86+
87+
'and one more: ftp://127.0.0.1/.';
88+
$scope.snippetWithSingleURL = 'http://angularjs.org/';
89+
}]);
90+
</file>
9091
<file name="protractor.js" type="protractor">
9192
it('should linkify the snippet with urls', function() {
9293
expect(element(by.id('linky-filter')).element(by.binding('snippet | linky')).getText()).

0 commit comments

Comments
 (0)