@bartificer/linkify 2.3.5 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/README.md +135 -35
  2. package/dist/index.js +1 -1
  3. package/docs/LinkData.class.mjs.html +119 -56
  4. package/docs/LinkTemplate.class.mjs.html +120 -36
  5. package/docs/Linkifier.class.mjs.html +141 -66
  6. package/docs/PageData.class.mjs.html +145 -72
  7. package/docs/defaults.mjs.html +136 -12
  8. package/docs/docdash-overrides.css +11 -0
  9. package/docs/externals.jsdoc.html +95 -4
  10. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  11. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  12. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  13. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  14. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  15. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  16. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  17. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  18. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  19. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  20. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  21. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  22. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  23. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  24. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  25. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  26. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  27. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  28. package/docs/global.html +1276 -0
  29. package/docs/index.html +1018 -26
  30. package/docs/index.js.html +143 -17
  31. package/docs/mermaid-init.js +21 -0
  32. package/docs/module-cheerio.html +193 -3
  33. package/docs/module-defaults.html +680 -3
  34. package/docs/module-link-data.LinkData.html +813 -0
  35. package/docs/module-link-data.html +226 -0
  36. package/docs/module-link-template.LinkTemplate.html +792 -0
  37. package/docs/module-link-template.html +226 -0
  38. package/docs/module-linkifier.Linkifier.html +2050 -0
  39. package/docs/module-linkifier.html +236 -0
  40. package/docs/module-linkify.html +810 -3
  41. package/docs/module-mustache.html +193 -3
  42. package/docs/module-node-fetch.html +193 -3
  43. package/docs/module-page-data.PageData.html +1810 -0
  44. package/docs/module-page-data.html +226 -0
  45. package/docs/module-title-case.html +193 -3
  46. package/docs/module-urijs.html +193 -3
  47. package/docs/module-url-slug.html +193 -3
  48. package/docs/module-utilities.html +1518 -3
  49. package/docs/scripts/collapse.js +39 -0
  50. package/docs/scripts/commonNav.js +28 -0
  51. package/docs/scripts/linenumber.js +25 -0
  52. package/docs/scripts/nav.js +12 -0
  53. package/docs/scripts/polyfill.js +4 -0
  54. package/docs/scripts/{third-party → prettify}/Apache-License-2.0.txt +202 -202
  55. package/docs/scripts/prettify/lang-css.js +2 -0
  56. package/docs/scripts/prettify/prettify.js +28 -0
  57. package/docs/scripts/search.js +99 -265
  58. package/docs/styles/jsdoc.css +776 -0
  59. package/docs/styles/prettify.css +80 -0
  60. package/docs/typedefs.jsdoc.html +145 -0
  61. package/docs/utilities.mjs.html +154 -22
  62. package/examples/clipboardURLToMarkdown.mjs +80 -1
  63. package/package.json +5 -3
  64. package/src/LinkData.class.mjs +24 -52
  65. package/src/LinkTemplate.class.mjs +25 -32
  66. package/src/Linkifier.class.mjs +46 -62
  67. package/src/PageData.class.mjs +50 -68
  68. package/src/defaults.mjs +42 -8
  69. package/src/index.js +48 -13
  70. package/src/typedefs.jsdoc +52 -0
  71. package/src/utilities.mjs +59 -18
  72. package/docs/data/search.json +0 -1
  73. package/docs/fonts/Inconsolata-Regular.ttf +0 -0
  74. package/docs/fonts/OpenSans-Regular.ttf +0 -0
  75. package/docs/fonts/WorkSans-Bold.ttf +0 -0
  76. package/docs/module-LinkData.LinkData.html +0 -13
  77. package/docs/module-LinkData.html +0 -3
  78. package/docs/module-LinkTemplate.LinkTemplate.html +0 -3
  79. package/docs/module-LinkTemplate.html +0 -3
  80. package/docs/module-Linkifier.Linkifier.html +0 -3
  81. package/docs/module-Linkifier.html +0 -3
  82. package/docs/module-PageData.PageData.html +0 -15
  83. package/docs/module-PageData.html +0 -3
  84. package/docs/scripts/core.js +0 -726
  85. package/docs/scripts/core.min.js +0 -23
  86. package/docs/scripts/resize.js +0 -90
  87. package/docs/scripts/search.min.js +0 -6
  88. package/docs/scripts/third-party/fuse.js +0 -9
  89. package/docs/scripts/third-party/hljs-line-num-original.js +0 -369
  90. package/docs/scripts/third-party/hljs-line-num.js +0 -1
  91. package/docs/scripts/third-party/hljs-original.js +0 -5171
  92. package/docs/scripts/third-party/hljs.js +0 -1
  93. package/docs/scripts/third-party/popper.js +0 -5
  94. package/docs/scripts/third-party/tippy.js +0 -1
  95. package/docs/scripts/third-party/tocbot.js +0 -672
  96. package/docs/scripts/third-party/tocbot.min.js +0 -1
  97. package/docs/styles/clean-jsdoc-theme-base.css +0 -1159
  98. package/docs/styles/clean-jsdoc-theme-dark.css +0 -412
  99. package/docs/styles/clean-jsdoc-theme-light.css +0 -482
  100. package/docs/styles/clean-jsdoc-theme-scrollbar.css +0 -30
  101. package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +0 -1
  102. package/docs/styles/clean-jsdoc-theme.min.css +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bartificer/linkify",
3
- "version": "2.3.5",
4
- "description": "An module for converting URLs into pretty links in any format.",
3
+ "version": "2.4.1",
4
+ "description": "A module for converting URLs into pretty links in any format.",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "scripts": {
19
19
  "build": "webpack",
20
- "docs": "rm -rf ./docs/* && npx jsdoc -c ./jsdoc.conf.json --destination ./docs",
20
+ "docs": "rm -rf ./docs/* && npx jsdoc -c ./jsdoc.conf.json",
21
21
  "release": "npm run build && npm run docs && npm login && npm publish"
22
22
  },
23
23
  "repository": {
@@ -41,7 +41,9 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "clean-jsdoc-theme": "^4.3.0",
44
+ "docdash": "^2.0.2",
44
45
  "jsdoc": "^4.0.5",
46
+ "marked": "^18.0.0",
45
47
  "webpack": "^5.105.4",
46
48
  "webpack-cli": "^7.0.2"
47
49
  }
@@ -1,28 +1,28 @@
1
1
  /**
2
- * @file The definition of the class representing a link.
2
+ * @file Data model for link information.
3
3
  * @author Bart Busschots <opensource@bartificer.ie>
4
+ * @license MIT
4
5
  */
5
6
 
6
7
  /**
7
- * This module provides as class for representing the information that can be used when rendering a link.
8
- * @module LinkData
8
+ * This module provides the class for representing the information that can be used to render a link.
9
+ * @module link-data
9
10
  * @requires module:urijs
10
11
  */
11
12
  import {default as URI} from 'urijs';
12
13
 
13
14
  /**
14
- * A class for representing the information about a link, in the abstract.
15
+ * The information that can be used to render a link.
16
+ *
17
+ * Instances of this class are created from the information extracted from web pages by data transformers.
18
+ * @see {@link dataTransformer} for details of how instances of this class are created.
15
19
  */
16
20
  export class LinkData {
17
21
  /**
18
- * This constructor throws a {@link ValidationError} unless a valid URL is passed.
19
- *
20
- * @param {URL} url - The link's URL.
22
+ * @param {string} url - The link's URL.
21
23
  * @param {string} [text] - The link's text, defaults to the URL.
22
- * @param {string} [description] - A description for the link, defaults to
23
- * the link text.
24
- * @throws {ValidationError} A validation error is thrown if an invalid URL
25
- * is passed.
24
+ * @param {string} [description] - A description for the link, defaults to the link text.
25
+ * @throws {TypeError} A TypeError is thrown if an invalid URL is passed.
26
26
  */
27
27
  constructor(url, text, description){
28
28
  // TO DO - add validation
@@ -31,9 +31,9 @@ export class LinkData {
31
31
  * The link's URL as a URI.js object.
32
32
  *
33
33
  * @private
34
- * @type {URIObject}
34
+ * @type {module:urijs}
35
35
  */
36
- this._uri = URI();
36
+ this._uri = URI(); // throws a TypeError if the URL is invalid
37
37
 
38
38
  /**
39
39
  * The link text.
@@ -62,78 +62,50 @@ export class LinkData {
62
62
  }
63
63
 
64
64
  /**
65
- * @returns {string} a URL string
65
+ * The URL the link points to as a string.
66
+ * @type {string}
66
67
  */
67
68
  get url(){
68
69
  return this._uri.toString();
69
70
  }
70
-
71
- /**
72
- * Get or set the URL.
73
- *
74
- * @param {string} url - A new URL as a string.
75
- */
76
71
  set url(url){
77
72
  this._uri = URI(String(url)).normalize();
78
73
  }
79
74
 
80
75
  /**
81
- * Get the URL as a URI.js object.
82
- *
83
- * @returns {Object}
76
+ * The URL the link points to as a URI.js object representing the URL.
77
+ * @type {module:urijs}
78
+ * @readonly
84
79
  */
85
80
  get uri(){
86
81
  return this._uri.clone();
87
82
  }
88
83
 
89
84
  /**
90
- * @returns {string}
85
+ * The link text.
86
+ * @type {string}
91
87
  */
92
88
  get text(){
93
89
  return this._text;
94
90
  }
95
-
96
- /**
97
- * @param {string} [text] - New link text. The value will be coerced to a string and trimmed.
98
- */
99
91
  set text(text){
100
92
  this._text = String(text).trim();
101
93
  }
102
94
 
103
95
  /**
104
- * @returns {string}
96
+ * The link description.
97
+ * @type {string}
105
98
  */
106
99
  get description(){
107
100
  return this._description;
108
101
  }
109
-
110
- /**
111
- * @param {string} description
112
- */
113
102
  set description(description){
114
103
  this._description = String(description);
115
104
  }
116
105
 
117
106
  /**
118
- * Get the link data as a plain object of the form:
119
- * ```
120
- * {
121
- * url: 'http://www.bartificer.net/',
122
- * text: 'the link text',
123
- * description: 'the link description',
124
- * uri: {
125
- * hostname: 'www.bartificer.net',
126
- * path: '/',
127
- * hasPath: false
128
- * }
129
- * }
130
- * ```
131
- *
132
- * Note that the `uri` could contain more fields - it's initialised with
133
- * output from the `URI.parse()` function from the `URI` module.
134
- *
135
- * @returns {plainObject}
136
- * @see {@link https://medialize.github.io/URI.js/docs.html#static-parse}
107
+ * The link data as a plain object for use in Mustache templates and the like.
108
+ * @returns {plainLinkInformationObject} A plain object containing the link data.
137
109
  */
138
110
  asPlainObject(){
139
111
  let ans = {
@@ -1,27 +1,31 @@
1
1
  /**
2
- * @file The definition of the class representing a link generation template.
2
+ * @file Link generation templates.
3
3
  * @author Bart Busschots <opensource@bartificer.ie>
4
+ * @license MIT
4
5
  */
5
6
 
6
7
  /**
7
- * This module provides as class for representing a template used for generating links.
8
- * @module LinkTemplate
8
+ * This module provides as class for representing the templates used to generate links from link data objects.
9
+ * @module link-template
9
10
  * @requires module:urijs
10
11
  */
11
12
 
12
13
  /**
13
- * A class representing the a template that can be used to render links.
14
+ * A class representing the templates used to render link data objects as actual links.
15
+ * @see {@link module:link-data.LinkData} for the data objects that are rendered with these templates.
14
16
  */
15
17
  export class LinkTemplate{
16
18
  /**
17
19
  * @param {string} templateString - A Moustache template string.
18
- * @param {Array} [filters=[]] - An optional array of filter functions.
19
- * Each element in the array should itself be an array where the first
20
- * element is a string specifying which fields the filter should be applied
21
- * to (one of `'all'`, `'url'`, `'text'`, or `'description'`), and the
22
- * second the filter function itself which should be a function that takes
23
- * a single string as an argument and returns a filtered version of that
24
- * string.
20
+ * @param {templateFieldFilterTuple[]} [filters=[]] - an optional set of filter functions to apply to some or all template fields.
21
+ * @example <caption>Example of defining a template with filters</caption>
22
+ * let template = new LinkTemplate(
23
+ * '<a href="{{{url}}}">{{{text}}}</a>',
24
+ * [
25
+ * ['url', linkify.util.stripUTMParameters],
26
+ * ['text', linkify.util.regulariseWhitespace]
27
+ * ]
28
+ * );
25
29
  */
26
30
  constructor(templateString, filters){
27
31
  // TO DO - add validation
@@ -44,7 +48,7 @@ export class LinkTemplate{
44
48
  * * `description` - filters to be applied just the link description.
45
49
  *
46
50
  * @private
47
- * @type {Object.<string, filterFunction>}
51
+ * @type {Object.<"all"|"url"|"text"|"description", templateFieldFilterFunction>}
48
52
  */
49
53
  this._filters = {
50
54
  all: [],
@@ -62,20 +66,12 @@ export class LinkTemplate{
62
66
  }
63
67
 
64
68
  /**
65
- * Get the template string.
66
- *
67
- * @returns {string}
69
+ * The Mustache template string. Will be coerced to a string with `String(templateString)`.
70
+ * @type {string}
68
71
  */
69
72
  get templateString(){
70
73
  return this._templateString;
71
74
  }
72
-
73
- /**
74
- * Set the template string. Should be in Mustache format. All values passed
75
- * will be coerced to strings.
76
- *
77
- * @param {string} templateString
78
- */
79
75
  set templateString(templateString){
80
76
  this._templateString = String(templateString);
81
77
  }
@@ -86,10 +82,9 @@ export class LinkTemplate{
86
82
  * If an invalid args are passed, the function does not save the filter or
87
83
  * throw an error, but it does log a warning.
88
84
  *
89
- * @param {string} fieldName - One of `'all'`, `'url'`, `'text'`, or
90
- * `'description'`.
91
- * @param {function} filterFn - the filter function.
92
- * @returns {LinkTemplate} Returns a reference to self to facilitate function chaining.
85
+ * @param {"all"|"url"|"text"|"description"} fieldName
86
+ * @param {templateFieldFilterFunction} filterFn - the filter function.
87
+ * @returns {module:link-template.LinkTemplate} Returns a reference to self to facilitate function chaining.
93
88
  */
94
89
  addFilter(fieldName, filterFn){
95
90
  // make sure that args are at least plausibly valid
@@ -112,13 +107,11 @@ export class LinkTemplate{
112
107
  }
113
108
 
114
109
  /**
115
- * A function get the filter functions that should be applied to any given
116
- * field.
110
+ * Get the filter functions that should be applied to any given field.
117
111
  *
118
- * @param {string} fieldName - one of `'url'`, `'text'`, or
119
- * `'description'`.
120
- * @returns {function[]} returns an array of callbacks, which may be
121
- * empty. An empty array is returned if an invalid field name is passed.
112
+ * @param {"all"|"url"|"text"|"description"} fieldName
113
+ * @returns {templateFieldFilterFunction[]} returns an array of callbacks, which may be
114
+ * empty. An empty array is also returned if an invalid field name is passed.
122
115
  */
123
116
  filtersFor(fieldName){
124
117
  fieldName = String(fieldName);
@@ -1,14 +1,15 @@
1
1
  /**
2
2
  * @file The definition of the main Linkifier class which provides the link rendering functionality with the help of the other classes and modules.
3
3
  * @author Bart Busschots <opensource@bartificer.ie>
4
+ * @license MIT
4
5
  */
5
6
 
6
7
  /**
7
8
  * Linkifier's core link rendering functionality.
8
- * @module Linkifier
9
- * @requires LinkData
10
- * @requires LinkTemplate
11
- * @requires PageData
9
+ * @module linkifier
10
+ * @requires link-data
11
+ * @requires link-template
12
+ * @requires page-data
12
13
  * @requires module:node-fetch
13
14
  * @requires module:cheerio
14
15
  * @requires module:mustache
@@ -27,28 +28,26 @@ import Mustache from 'mustache';
27
28
  * The class providing the link rendering functionality. Instances of this class capture the settings for generating links, and, generate links using these settings.
28
29
  */
29
30
  export class Linkifier {
31
+ /**
32
+ * Builds a Linkifier instance ready for use rendering links using the default configration.
33
+ * @see {@link module:defaults} for the default configuration settings.
34
+ */
30
35
  constructor(){
31
36
  /**
32
- * A mapping of domain names to data transformation functions.
37
+ * A mapping of fully qualified domain names to data transformation functions.
33
38
  *
34
39
  * @private
35
- * @type {Object.<FQDN, dataTransformer>}
40
+ * @type {Object.<string, dataTransformer>}
36
41
  */
37
42
  this._pageDataToLinkDataTransmformers = {
38
- '.' : function(pData){
39
- let text = pData.title;
40
- if(pData.h1s.length === 1){
41
- text = pData.mainHeading;
42
- }
43
- return new LinkData(pData.url, text);
44
- }
43
+ '.' : defaults.dataTransformer
45
44
  };
46
45
 
47
46
  /**
48
- * A mapping of domains names to default template names.
47
+ * A mapping of fully qualified domain names to default template names.
49
48
  *
50
49
  * @private
51
- * @type {Object.<FQDN, templateName>}
50
+ * @type {Object.<string, string>}
52
51
  */
53
52
  this._pageDataToLinkTemplateName = {
54
53
  '.' : 'html' // default to the 'html' template for all domains unless otherwise specified
@@ -58,7 +57,7 @@ export class Linkifier {
58
57
  * The registered link templates.
59
58
  *
60
59
  * @private
61
- * @type {Object.<templateName, module:@bartificer/linkify.LinkTemplate>}
60
+ * @type {Object.<string, module:link-template.LinkTemplate>}
62
61
  */
63
62
  this._linkTemplates = {};
64
63
 
@@ -89,30 +88,30 @@ export class Linkifier {
89
88
 
90
89
  /**
91
90
  * @type {Object.<string, Function>}
91
+ * @readonly
92
+ * @see {@link module:utilities} for the utility functions available in this collection.
92
93
  */
93
94
  get utilities() {
94
95
  return this._utilities;
95
96
  }
96
97
 
97
98
  /**
98
- * @see Linfifier.utilities
99
+ * Shorthand property for `.utilities`.
100
+ * @see {@link module:linkifier.Linkifier#utilities}
99
101
  */
100
102
  get util(){
101
103
  return this._utilities;
102
104
  }
103
105
 
104
106
  /**
105
- * @returns {string[]} The current list of known words with special capitalisations.
107
+ * The list of known words with special capitalisations. The words should be capitalised in the descired manner.
108
+ * @type {string[]}
106
109
  */
107
110
  get speciallyCapitalisedWords(){
108
111
  const ans = [];
109
112
  this._speciallyCapitalisedWords.map(word => ans.push(word));
110
113
  return ans;
111
114
  }
112
-
113
- /**
114
- * @param {string[]} words - a list of words with special capitalisations
115
- */
116
115
  set speciallyCapitalisedWords(words){
117
116
  // TO DO - add validation
118
117
 
@@ -120,13 +119,11 @@ export class Linkifier {
120
119
  }
121
120
 
122
121
  /**
123
- * Register a data transformer function for a given domain.
122
+ * Register a data transformer function to a domain name.
124
123
  *
125
- * @param {domainName} domain - The domain for which this transformer should be
124
+ * @param {string} domain - The fully qualified domain for which this transformer should be
126
125
  * used.
127
126
  * @param {dataTransformer} transformerFn - The data transformer callback.
128
- * @throws {ValidationError} A validation error is thrown if either parameter
129
- * is missing or invalid.
130
127
  */
131
128
  registerTransformer(domain, transformerFn){
132
129
  // TO DO - add validation
@@ -142,16 +139,14 @@ export class Linkifier {
142
139
  * Get the data transformer function for a given domain.
143
140
  *
144
141
  * Note that domains are searched from the subdomain up. For example, if passed
145
- * the domain `www.bartificer.net` the function will first look for a
146
- * transformer for the domain `www.bartificer.net`, if there's no transformer
142
+ * the domain `www.bartificer.ie` the function will first look for a
143
+ * transformer for the domain `www.bartificer.ie`, if there's no transformer
147
144
  * registered for that domain it will look for a transformer for the domain
148
- * `bartificer.net`, if there's no transformer for that domain either it will
145
+ * `bartificer.ie`, if there's no transformer for that domain either it will
149
146
  * return the default transformer.
150
147
  *
151
- * @param {domainName} domain - The domain to get the data transformer for.
148
+ * @param {string} domain - The fully qualified domain for which to get the data transformer.
152
149
  * @returns {dataTransformer}
153
- * @throws {ValidationError} A validation error is thrown unless a valid domain
154
- * name is passed.
155
150
  */
156
151
  getTransformerForDomain(domain){
157
152
  // TO DO - add validation
@@ -177,22 +172,20 @@ export class Linkifier {
177
172
  /**
178
173
  * A list of the names of the registered link templates.
179
174
  * @type {string[]}
175
+ * @readonly
180
176
  */
181
177
  get templateNames() {
182
178
  return Object.keys(this._linkTemplates);
183
179
  }
184
180
 
185
181
  /**
186
- * @returns {string} The name of the default template.
182
+ * The name of the default template used when rendering links.
183
+ * @type {string}
184
+ * @throws {ValidationError} A validation error is thrown if the template name is missing, invalid, or doesn't correspond to a registered template.
187
185
  */
188
186
  get defaultTemplateName(){
189
187
  return this._pageDataToLinkTemplateName['.'];
190
188
  }
191
-
192
- /**
193
- * @param {string} templateName - The name of the default template to use.
194
- * @throws {ValidationError} A validation error is thrown if the template name is missing, invalid, or doesn't correspond to a registered template.
195
- */
196
189
  set defaultTemplateName(templateName){
197
190
  const tplName = String(templateName);
198
191
  if(!this._linkTemplates[tplName]){
@@ -203,7 +196,8 @@ export class Linkifier {
203
196
 
204
197
  /**
205
198
  * The default link template.
206
- * @type {LinkTemplate}
199
+ * @type {module:link-template.LinkTemplate}
200
+ * @readonly
207
201
  */
208
202
  get defaultTemplate(){
209
203
  return this._linkTemplates[this._pageDataToLinkTemplateName['.']];
@@ -212,10 +206,8 @@ export class Linkifier {
212
206
  /**
213
207
  * Register a link template.
214
208
  *
215
- * @param {templateName} name
216
- * @param {module:@bartificer/linkify.LinkTemplate} template
217
- * @throws {ValidationError} A validation error is thrown unless both a valid
218
- * name and template object are passed.
209
+ * @param {string} name
210
+ * @param {module:link-template.LinkTemplate} template
219
211
  */
220
212
  registerTemplate(name, template){
221
213
  // TO DO - add validation
@@ -228,7 +220,7 @@ export class Linkifier {
228
220
  * Get a registered link template by name.
229
221
  *
230
222
  * @param {string} templateName
231
- * @returns {LinkTemplate}
223
+ * @returns {module:link-template.LinkTemplate}
232
224
  * @throws {ValidationError} A validation error is thrown unless a valid name is passed and corresponds to a registered template.
233
225
  */
234
226
  getTemplate(templateName){
@@ -244,10 +236,8 @@ export class Linkifier {
244
236
  * Register a default template for use with a given domain. This template will
245
237
  * override the overall default for this domain and all its subdomains.
246
238
  *
247
- * @param {domainName} domain - The domain for which this template should be used by default.
248
- * @param {templateName} templateName - The name of the template to use.
249
- * @throws {ValidationError} A validation error is thrown if either parameter
250
- * is missing or invalid.
239
+ * @param {string} domain - The fully qualified domain name for which this template should be used by default.
240
+ * @param {string} templateName - The name of the template to use.
251
241
  */
252
242
  registerDefaultTemplateMapping(domain, templateName){
253
243
  // TO DO - add validation
@@ -263,16 +253,14 @@ export class Linkifier {
263
253
  * Get the data transformer function for a given domain.
264
254
  *
265
255
  * Note that domains are searched from the subdomain up. For example, if passed
266
- * the domain `www.bartificer.net` the function will first look for a
267
- * transformer for the domain `www.bartificer.net`, if there's no transformer
256
+ * the domain `www.bartificer.ie` the function will first look for a
257
+ * transformer for the domain `www.bartificer.ie`, if there's no transformer
268
258
  * registered for that domain it will look for a transformer for the domain
269
- * `bartificer.net`, if there's no transformer for that domain either it will
259
+ * `bartificer.ie`, if there's no transformer for that domain either it will
270
260
  * return the default transformer.
271
261
  *
272
- * @param {domainName} domain - The domain to get the data transformer for.
262
+ * @param {string} domain - The fully qualified domain name to get the data transformer for.
273
263
  * @returns {dataTransformer}
274
- * @throws {ValidationError} A validation error is thrown unless a valid domain
275
- * name is passed.
276
264
  */
277
265
  getTemplateNameForDomain(domain){
278
266
  // TO DO - add validation
@@ -307,10 +295,8 @@ export class Linkifier {
307
295
  * Fetch the page data for a given URL.
308
296
  *
309
297
  * @async
310
- * @param {URL} url
311
- * @returns {PageData}
312
- * @throws {ValidationError} A validation error is thrown unless a valid URL is
313
- * passed.
298
+ * @param {string} url
299
+ * @returns {module:page-data.PageData}
314
300
  */
315
301
  async fetchPageData(url){
316
302
  // TO DO - add validation
@@ -350,11 +336,9 @@ export class Linkifier {
350
336
  * default will be used (`html`).
351
337
  *
352
338
  * @async
353
- * @param {URL} url
354
- * @param {templateName} [templateName='html']
339
+ * @param {string} url
340
+ * @param {string} [templateName='html']
355
341
  * @returns {string}
356
- * @throws {ValidationError} A validation error is thrown unless a valid URL is
357
- * passed.
358
342
  */
359
343
  async generateLink(url, templateName){
360
344
  // TO DO - add validation