@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.
- package/README.md +135 -35
- package/dist/index.js +1 -1
- package/docs/LinkData.class.mjs.html +119 -56
- package/docs/LinkTemplate.class.mjs.html +120 -36
- package/docs/Linkifier.class.mjs.html +141 -66
- package/docs/PageData.class.mjs.html +145 -72
- package/docs/defaults.mjs.html +136 -12
- package/docs/docdash-overrides.css +11 -0
- package/docs/externals.jsdoc.html +95 -4
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/global.html +1276 -0
- package/docs/index.html +1018 -26
- package/docs/index.js.html +143 -17
- package/docs/mermaid-init.js +21 -0
- package/docs/module-cheerio.html +193 -3
- package/docs/module-defaults.html +680 -3
- package/docs/module-link-data.LinkData.html +813 -0
- package/docs/module-link-data.html +226 -0
- package/docs/module-link-template.LinkTemplate.html +792 -0
- package/docs/module-link-template.html +226 -0
- package/docs/module-linkifier.Linkifier.html +2050 -0
- package/docs/module-linkifier.html +236 -0
- package/docs/module-linkify.html +810 -3
- package/docs/module-mustache.html +193 -3
- package/docs/module-node-fetch.html +193 -3
- package/docs/module-page-data.PageData.html +1810 -0
- package/docs/module-page-data.html +226 -0
- package/docs/module-title-case.html +193 -3
- package/docs/module-urijs.html +193 -3
- package/docs/module-url-slug.html +193 -3
- package/docs/module-utilities.html +1518 -3
- package/docs/scripts/collapse.js +39 -0
- package/docs/scripts/commonNav.js +28 -0
- package/docs/scripts/linenumber.js +25 -0
- package/docs/scripts/nav.js +12 -0
- package/docs/scripts/polyfill.js +4 -0
- package/docs/scripts/{third-party → prettify}/Apache-License-2.0.txt +202 -202
- package/docs/scripts/prettify/lang-css.js +2 -0
- package/docs/scripts/prettify/prettify.js +28 -0
- package/docs/scripts/search.js +99 -265
- package/docs/styles/jsdoc.css +776 -0
- package/docs/styles/prettify.css +80 -0
- package/docs/typedefs.jsdoc.html +145 -0
- package/docs/utilities.mjs.html +154 -22
- package/examples/clipboardURLToMarkdown.mjs +80 -1
- package/package.json +5 -3
- package/src/LinkData.class.mjs +24 -52
- package/src/LinkTemplate.class.mjs +25 -32
- package/src/Linkifier.class.mjs +46 -62
- package/src/PageData.class.mjs +50 -68
- package/src/defaults.mjs +42 -8
- package/src/index.js +48 -13
- package/src/typedefs.jsdoc +52 -0
- package/src/utilities.mjs +59 -18
- package/docs/data/search.json +0 -1
- package/docs/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/module-LinkData.LinkData.html +0 -13
- package/docs/module-LinkData.html +0 -3
- package/docs/module-LinkTemplate.LinkTemplate.html +0 -3
- package/docs/module-LinkTemplate.html +0 -3
- package/docs/module-Linkifier.Linkifier.html +0 -3
- package/docs/module-Linkifier.html +0 -3
- package/docs/module-PageData.PageData.html +0 -15
- package/docs/module-PageData.html +0 -3
- package/docs/scripts/core.js +0 -726
- package/docs/scripts/core.min.js +0 -23
- package/docs/scripts/resize.js +0 -90
- package/docs/scripts/search.min.js +0 -6
- package/docs/scripts/third-party/fuse.js +0 -9
- package/docs/scripts/third-party/hljs-line-num-original.js +0 -369
- package/docs/scripts/third-party/hljs-line-num.js +0 -1
- package/docs/scripts/third-party/hljs-original.js +0 -5171
- package/docs/scripts/third-party/hljs.js +0 -1
- package/docs/scripts/third-party/popper.js +0 -5
- package/docs/scripts/third-party/tippy.js +0 -1
- package/docs/scripts/third-party/tocbot.js +0 -672
- package/docs/scripts/third-party/tocbot.min.js +0 -1
- package/docs/styles/clean-jsdoc-theme-base.css +0 -1159
- package/docs/styles/clean-jsdoc-theme-dark.css +0 -412
- package/docs/styles/clean-jsdoc-theme-light.css +0 -482
- package/docs/styles/clean-jsdoc-theme-scrollbar.css +0 -30
- package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +0 -1
- package/docs/styles/clean-jsdoc-theme.min.css +0 -1
|
@@ -1,16 +1,76 @@
|
|
|
1
|
-
<!DOCTYPE html
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<title>Linkifier.class.mjs - @bartificer/linkify Documentation</title>
|
|
7
|
+
|
|
8
|
+
<meta name="description" content="Documentation for the @bartificer/linkify package" />
|
|
9
|
+
|
|
10
|
+
<meta name="keywords" content="documentation, linkify, link, template, javascript, generator, npm, module, package" />
|
|
11
|
+
<meta name="keyword" content="documentation, linkify, link, template, javascript, generator, npm, module, package" />
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
<meta property="og:title" content="@bartificer/linkify"/>
|
|
16
|
+
<meta property="og:type" content="website"/>
|
|
17
|
+
<meta property="og:image" content=""/>
|
|
18
|
+
<meta property="og:site_name" content="@bartificer/linkify Documentation"/>
|
|
19
|
+
<meta property="og:url" content="https://bartificer.github.io/linkify/"/>
|
|
20
|
+
|
|
21
|
+
<script src="scripts/prettify/prettify.js"></script>
|
|
22
|
+
<script src="scripts/prettify/lang-css.js"></script>
|
|
23
|
+
<!--[if lt IE 9]>
|
|
24
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
25
|
+
<![endif]-->
|
|
26
|
+
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
|
27
|
+
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
|
28
|
+
<script src="scripts/nav.js" defer></script>
|
|
29
|
+
|
|
30
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
|
|
34
|
+
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
|
35
|
+
<label for="nav-trigger" class="navicon-button x">
|
|
36
|
+
<div class="navicon"></div>
|
|
37
|
+
</label>
|
|
38
|
+
|
|
39
|
+
<label for="nav-trigger" class="overlay"></label>
|
|
40
|
+
|
|
41
|
+
<nav class="wrap">
|
|
42
|
+
|
|
43
|
+
<input type="text" id="nav-search" placeholder="Search" />
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
<h2><a href="index.html">Home</a></h2><h2><a href="https://github.com/bartificer/linkify" target="_blank" >On GitHub</a></h2><h2><a href="https://bartificer.net/" target="_blank" >Bartificer Creations</a></h2><h3>Modules</h3><ul><li><a href="module-defaults.html">defaults</a><ul class='members'><li data-type='member'><a href="module-defaults.html#.linkTemplates">linkTemplates</a></li><li data-type='member'><a href="module-defaults.html#.smallWords">smallWords</a></li><li data-type='member'><a href="module-defaults.html#.speciallyCapitalisedWords">speciallyCapitalisedWords</a></li></ul><ul class='methods'><li data-type='method'><a href="module-defaults.html#.dataTransformer">dataTransformer</a></li></ul></li><li><a href="module-link-data.html">link-data</a></li><li><a href="module-link-template.html">link-template</a></li><li><a href="module-linkifier.html">linkifier</a></li><li><a href="module-linkify.html">linkify</a><ul class='members'><li data-type='member'><a href="module-linkify.html#.LinkData">LinkData</a></li><li data-type='member'><a href="module-linkify.html#.LinkTemplate">LinkTemplate</a></li><li data-type='member'><a href="module-linkify.html#.Linkifier">Linkifier</a></li><li data-type='member'><a href="module-linkify.html#.PageData">PageData</a></li><li data-type='member'><a href="module-linkify.html#.VERSION">VERSION</a></li><li data-type='member'><a href="module-linkify.html#.default">default</a></li><li data-type='member'><a href="module-linkify.html#.linkify">linkify</a></li></ul></li><li><a href="module-page-data.html">page-data</a></li><li><a href="module-utilities.html">utilities</a><ul class='methods'><li data-type='method'><a href="module-utilities.html#.batchFixCustomWordCases">batchFixCustomWordCases</a></li><li data-type='method'><a href="module-utilities.html#.escapeRegex">escapeRegex</a></li><li data-type='method'><a href="module-utilities.html#.extractSlug">extractSlug</a></li><li data-type='method'><a href="module-utilities.html#.regulariseWhitespace">regulariseWhitespace</a></li><li data-type='method'><a href="module-utilities.html#.stripQueryString">stripQueryString</a></li><li data-type='method'><a href="module-utilities.html#.stripUTMParameters">stripUTMParameters</a></li><li data-type='method'><a href="module-utilities.html#.toTitleCase">toTitleCase</a></li></ul></li></ul><h3>Classes</h3><ul><li><a href="module-link-data.LinkData.html">LinkData</a><ul class='methods'><li data-type='method'><a href="module-link-data.LinkData.html#asPlainObject">asPlainObject</a></li></ul></li><li><a href="module-link-template.LinkTemplate.html">LinkTemplate</a><ul class='methods'><li data-type='method'><a href="module-link-template.LinkTemplate.html#addFilter">addFilter</a></li><li data-type='method'><a href="module-link-template.LinkTemplate.html#filtersFor">filtersFor</a></li></ul></li><li><a href="module-linkifier.Linkifier.html">Linkifier</a><ul class='methods'><li data-type='method'><a href="module-linkifier.Linkifier.html#fetchPageData">fetchPageData</a></li><li data-type='method'><a href="module-linkifier.Linkifier.html#generateLink">generateLink</a></li><li data-type='method'><a href="module-linkifier.Linkifier.html#getTemplate">getTemplate</a></li><li data-type='method'><a href="module-linkifier.Linkifier.html#getTemplateNameForDomain">getTemplateNameForDomain</a></li><li data-type='method'><a href="module-linkifier.Linkifier.html#getTransformerForDomain">getTransformerForDomain</a></li><li data-type='method'><a href="module-linkifier.Linkifier.html#registerDefaultTemplateMapping">registerDefaultTemplateMapping</a></li><li data-type='method'><a href="module-linkifier.Linkifier.html#registerTemplate">registerTemplate</a></li><li data-type='method'><a href="module-linkifier.Linkifier.html#registerTransformer">registerTransformer</a></li></ul></li><li><a href="module-page-data.PageData.html">PageData</a><ul class='methods'><li data-type='method'><a href="module-page-data.PageData.html#addSecondaryHeading">addSecondaryHeading</a></li><li data-type='method'><a href="module-page-data.PageData.html#addTopLevelHeading">addTopLevelHeading</a></li><li data-type='method'><a href="module-page-data.PageData.html#asPlainObject">asPlainObject</a></li><li data-type='method'><a href="module-page-data.PageData.html#h1">h1</a></li><li data-type='method'><a href="module-page-data.PageData.html#h2">h2</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#dataTransformer">dataTransformer</a></li><li><a href="global.html#plainLinkInformationObject">plainLinkInformationObject</a></li><li><a href="global.html#plainPageInformationObject">plainPageInformationObject</a></li><li><a href="global.html#templateFieldFilterFunction">templateFieldFilterFunction</a></li><li><a href="global.html#templateFieldFilterTuple">templateFieldFilterTuple</a></li></ul><h3>Externals</h3><ul><li><a href="module-cheerio.html">cheerio</a></li><li><a href="module-mustache.html">mustache</a></li><li><a href="module-node-fetch.html">node-fetch</a></li><li><a href="module-title-case.html">title-case</a></li><li><a href="module-urijs.html">urijs</a></li><li><a href="module-url-slug.html">url-slug</a></li></ul>
|
|
47
|
+
|
|
48
|
+
</nav>
|
|
49
|
+
|
|
50
|
+
<div id="main">
|
|
51
|
+
|
|
52
|
+
<h1 class="page-title">Linkifier.class.mjs</h1>
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
<section>
|
|
61
|
+
<article>
|
|
62
|
+
<pre class="prettyprint source linenums"><code>/**
|
|
4
63
|
* @file The definition of the main Linkifier class which provides the link rendering functionality with the help of the other classes and modules.
|
|
5
64
|
* @author Bart Busschots <opensource@bartificer.ie>
|
|
65
|
+
* @license MIT
|
|
6
66
|
*/
|
|
7
67
|
|
|
8
68
|
/**
|
|
9
69
|
* Linkifier's core link rendering functionality.
|
|
10
|
-
* @module
|
|
11
|
-
* @requires
|
|
12
|
-
* @requires
|
|
13
|
-
* @requires
|
|
70
|
+
* @module linkifier
|
|
71
|
+
* @requires link-data
|
|
72
|
+
* @requires link-template
|
|
73
|
+
* @requires page-data
|
|
14
74
|
* @requires module:node-fetch
|
|
15
75
|
* @requires module:cheerio
|
|
16
76
|
* @requires module:mustache
|
|
@@ -29,28 +89,26 @@ import Mustache from 'mustache';
|
|
|
29
89
|
* The class providing the link rendering functionality. Instances of this class capture the settings for generating links, and, generate links using these settings.
|
|
30
90
|
*/
|
|
31
91
|
export class Linkifier {
|
|
92
|
+
/**
|
|
93
|
+
* Builds a Linkifier instance ready for use rendering links using the default configration.
|
|
94
|
+
* @see {@link module:defaults} for the default configuration settings.
|
|
95
|
+
*/
|
|
32
96
|
constructor(){
|
|
33
97
|
/**
|
|
34
|
-
* A mapping of domain names to data transformation functions.
|
|
98
|
+
* A mapping of fully qualified domain names to data transformation functions.
|
|
35
99
|
*
|
|
36
100
|
* @private
|
|
37
|
-
* @type {Object.<
|
|
101
|
+
* @type {Object.<string, dataTransformer>}
|
|
38
102
|
*/
|
|
39
103
|
this._pageDataToLinkDataTransmformers = {
|
|
40
|
-
'.' :
|
|
41
|
-
let text = pData.title;
|
|
42
|
-
if(pData.h1s.length === 1){
|
|
43
|
-
text = pData.mainHeading;
|
|
44
|
-
}
|
|
45
|
-
return new LinkData(pData.url, text);
|
|
46
|
-
}
|
|
104
|
+
'.' : defaults.dataTransformer
|
|
47
105
|
};
|
|
48
106
|
|
|
49
107
|
/**
|
|
50
|
-
* A mapping of
|
|
108
|
+
* A mapping of fully qualified domain names to default template names.
|
|
51
109
|
*
|
|
52
110
|
* @private
|
|
53
|
-
* @type {Object.<
|
|
111
|
+
* @type {Object.<string, string>}
|
|
54
112
|
*/
|
|
55
113
|
this._pageDataToLinkTemplateName = {
|
|
56
114
|
'.' : 'html' // default to the 'html' template for all domains unless otherwise specified
|
|
@@ -60,7 +118,7 @@ export class Linkifier {
|
|
|
60
118
|
* The registered link templates.
|
|
61
119
|
*
|
|
62
120
|
* @private
|
|
63
|
-
* @type {Object.<
|
|
121
|
+
* @type {Object.<string, module:link-template.LinkTemplate>}
|
|
64
122
|
*/
|
|
65
123
|
this._linkTemplates = {};
|
|
66
124
|
|
|
@@ -91,30 +149,30 @@ export class Linkifier {
|
|
|
91
149
|
|
|
92
150
|
/**
|
|
93
151
|
* @type {Object.<string, Function>}
|
|
152
|
+
* @readonly
|
|
153
|
+
* @see {@link module:utilities} for the utility functions available in this collection.
|
|
94
154
|
*/
|
|
95
155
|
get utilities() {
|
|
96
156
|
return this._utilities;
|
|
97
157
|
}
|
|
98
158
|
|
|
99
159
|
/**
|
|
100
|
-
*
|
|
160
|
+
* Shorthand property for `.utilities`.
|
|
161
|
+
* @see {@link module:linkifier.Linkifier#utilities}
|
|
101
162
|
*/
|
|
102
163
|
get util(){
|
|
103
164
|
return this._utilities;
|
|
104
165
|
}
|
|
105
166
|
|
|
106
167
|
/**
|
|
107
|
-
*
|
|
168
|
+
* The list of known words with special capitalisations. The words should be capitalised in the descired manner.
|
|
169
|
+
* @type {string[]}
|
|
108
170
|
*/
|
|
109
171
|
get speciallyCapitalisedWords(){
|
|
110
172
|
const ans = [];
|
|
111
173
|
this._speciallyCapitalisedWords.map(word => ans.push(word));
|
|
112
174
|
return ans;
|
|
113
175
|
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* @param {string[]} words - a list of words with special capitalisations
|
|
117
|
-
*/
|
|
118
176
|
set speciallyCapitalisedWords(words){
|
|
119
177
|
// TO DO - add validation
|
|
120
178
|
|
|
@@ -122,13 +180,11 @@ export class Linkifier {
|
|
|
122
180
|
}
|
|
123
181
|
|
|
124
182
|
/**
|
|
125
|
-
* Register a data transformer function
|
|
183
|
+
* Register a data transformer function to a domain name.
|
|
126
184
|
*
|
|
127
|
-
* @param {
|
|
185
|
+
* @param {string} domain - The fully qualified domain for which this transformer should be
|
|
128
186
|
* used.
|
|
129
187
|
* @param {dataTransformer} transformerFn - The data transformer callback.
|
|
130
|
-
* @throws {ValidationError} A validation error is thrown if either parameter
|
|
131
|
-
* is missing or invalid.
|
|
132
188
|
*/
|
|
133
189
|
registerTransformer(domain, transformerFn){
|
|
134
190
|
// TO DO - add validation
|
|
@@ -144,16 +200,14 @@ export class Linkifier {
|
|
|
144
200
|
* Get the data transformer function for a given domain.
|
|
145
201
|
*
|
|
146
202
|
* Note that domains are searched from the subdomain up. For example, if passed
|
|
147
|
-
* the domain `www.bartificer.
|
|
148
|
-
* transformer for the domain `www.bartificer.
|
|
203
|
+
* the domain `www.bartificer.ie` the function will first look for a
|
|
204
|
+
* transformer for the domain `www.bartificer.ie`, if there's no transformer
|
|
149
205
|
* registered for that domain it will look for a transformer for the domain
|
|
150
|
-
* `bartificer.
|
|
206
|
+
* `bartificer.ie`, if there's no transformer for that domain either it will
|
|
151
207
|
* return the default transformer.
|
|
152
208
|
*
|
|
153
|
-
* @param {
|
|
209
|
+
* @param {string} domain - The fully qualified domain for which to get the data transformer.
|
|
154
210
|
* @returns {dataTransformer}
|
|
155
|
-
* @throws {ValidationError} A validation error is thrown unless a valid domain
|
|
156
|
-
* name is passed.
|
|
157
211
|
*/
|
|
158
212
|
getTransformerForDomain(domain){
|
|
159
213
|
// TO DO - add validation
|
|
@@ -179,22 +233,20 @@ export class Linkifier {
|
|
|
179
233
|
/**
|
|
180
234
|
* A list of the names of the registered link templates.
|
|
181
235
|
* @type {string[]}
|
|
236
|
+
* @readonly
|
|
182
237
|
*/
|
|
183
238
|
get templateNames() {
|
|
184
239
|
return Object.keys(this._linkTemplates);
|
|
185
240
|
}
|
|
186
241
|
|
|
187
242
|
/**
|
|
188
|
-
*
|
|
243
|
+
* The name of the default template used when rendering links.
|
|
244
|
+
* @type {string}
|
|
245
|
+
* @throws {ValidationError} A validation error is thrown if the template name is missing, invalid, or doesn't correspond to a registered template.
|
|
189
246
|
*/
|
|
190
247
|
get defaultTemplateName(){
|
|
191
248
|
return this._pageDataToLinkTemplateName['.'];
|
|
192
249
|
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* @param {string} templateName - The name of the default template to use.
|
|
196
|
-
* @throws {ValidationError} A validation error is thrown if the template name is missing, invalid, or doesn't correspond to a registered template.
|
|
197
|
-
*/
|
|
198
250
|
set defaultTemplateName(templateName){
|
|
199
251
|
const tplName = String(templateName);
|
|
200
252
|
if(!this._linkTemplates[tplName]){
|
|
@@ -205,7 +257,8 @@ export class Linkifier {
|
|
|
205
257
|
|
|
206
258
|
/**
|
|
207
259
|
* The default link template.
|
|
208
|
-
* @type {LinkTemplate}
|
|
260
|
+
* @type {module:link-template.LinkTemplate}
|
|
261
|
+
* @readonly
|
|
209
262
|
*/
|
|
210
263
|
get defaultTemplate(){
|
|
211
264
|
return this._linkTemplates[this._pageDataToLinkTemplateName['.']];
|
|
@@ -214,10 +267,8 @@ export class Linkifier {
|
|
|
214
267
|
/**
|
|
215
268
|
* Register a link template.
|
|
216
269
|
*
|
|
217
|
-
* @param {
|
|
218
|
-
* @param {module
|
|
219
|
-
* @throws {ValidationError} A validation error is thrown unless both a valid
|
|
220
|
-
* name and template object are passed.
|
|
270
|
+
* @param {string} name
|
|
271
|
+
* @param {module:link-template.LinkTemplate} template
|
|
221
272
|
*/
|
|
222
273
|
registerTemplate(name, template){
|
|
223
274
|
// TO DO - add validation
|
|
@@ -230,7 +281,7 @@ export class Linkifier {
|
|
|
230
281
|
* Get a registered link template by name.
|
|
231
282
|
*
|
|
232
283
|
* @param {string} templateName
|
|
233
|
-
* @returns {LinkTemplate}
|
|
284
|
+
* @returns {module:link-template.LinkTemplate}
|
|
234
285
|
* @throws {ValidationError} A validation error is thrown unless a valid name is passed and corresponds to a registered template.
|
|
235
286
|
*/
|
|
236
287
|
getTemplate(templateName){
|
|
@@ -246,10 +297,8 @@ export class Linkifier {
|
|
|
246
297
|
* Register a default template for use with a given domain. This template will
|
|
247
298
|
* override the overall default for this domain and all its subdomains.
|
|
248
299
|
*
|
|
249
|
-
* @param {
|
|
250
|
-
* @param {
|
|
251
|
-
* @throws {ValidationError} A validation error is thrown if either parameter
|
|
252
|
-
* is missing or invalid.
|
|
300
|
+
* @param {string} domain - The fully qualified domain name for which this template should be used by default.
|
|
301
|
+
* @param {string} templateName - The name of the template to use.
|
|
253
302
|
*/
|
|
254
303
|
registerDefaultTemplateMapping(domain, templateName){
|
|
255
304
|
// TO DO - add validation
|
|
@@ -265,16 +314,14 @@ export class Linkifier {
|
|
|
265
314
|
* Get the data transformer function for a given domain.
|
|
266
315
|
*
|
|
267
316
|
* Note that domains are searched from the subdomain up. For example, if passed
|
|
268
|
-
* the domain `www.bartificer.
|
|
269
|
-
* transformer for the domain `www.bartificer.
|
|
317
|
+
* the domain `www.bartificer.ie` the function will first look for a
|
|
318
|
+
* transformer for the domain `www.bartificer.ie`, if there's no transformer
|
|
270
319
|
* registered for that domain it will look for a transformer for the domain
|
|
271
|
-
* `bartificer.
|
|
320
|
+
* `bartificer.ie`, if there's no transformer for that domain either it will
|
|
272
321
|
* return the default transformer.
|
|
273
322
|
*
|
|
274
|
-
* @param {
|
|
323
|
+
* @param {string} domain - The fully qualified domain name to get the data transformer for.
|
|
275
324
|
* @returns {dataTransformer}
|
|
276
|
-
* @throws {ValidationError} A validation error is thrown unless a valid domain
|
|
277
|
-
* name is passed.
|
|
278
325
|
*/
|
|
279
326
|
getTemplateNameForDomain(domain){
|
|
280
327
|
// TO DO - add validation
|
|
@@ -309,10 +356,8 @@ export class Linkifier {
|
|
|
309
356
|
* Fetch the page data for a given URL.
|
|
310
357
|
*
|
|
311
358
|
* @async
|
|
312
|
-
* @param {
|
|
313
|
-
* @returns {PageData}
|
|
314
|
-
* @throws {ValidationError} A validation error is thrown unless a valid URL is
|
|
315
|
-
* passed.
|
|
359
|
+
* @param {string} url
|
|
360
|
+
* @returns {module:page-data.PageData}
|
|
316
361
|
*/
|
|
317
362
|
async fetchPageData(url){
|
|
318
363
|
// TO DO - add validation
|
|
@@ -352,11 +397,9 @@ export class Linkifier {
|
|
|
352
397
|
* default will be used (`html`).
|
|
353
398
|
*
|
|
354
399
|
* @async
|
|
355
|
-
* @param {
|
|
356
|
-
* @param {
|
|
400
|
+
* @param {string} url
|
|
401
|
+
* @param {string} [templateName='html']
|
|
357
402
|
* @returns {string}
|
|
358
|
-
* @throws {ValidationError} A validation error is thrown unless a valid URL is
|
|
359
|
-
* passed.
|
|
360
403
|
*/
|
|
361
404
|
async generateLink(url, templateName){
|
|
362
405
|
// TO DO - add validation
|
|
@@ -408,4 +451,36 @@ export class Linkifier {
|
|
|
408
451
|
// render the link
|
|
409
452
|
return Mustache.render(this._linkTemplates[tplName].templateString, templateData);
|
|
410
453
|
}
|
|
411
|
-
};</code></pre
|
|
454
|
+
};</code></pre>
|
|
455
|
+
</article>
|
|
456
|
+
</section>
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
</div>
|
|
464
|
+
|
|
465
|
+
<br class="clear">
|
|
466
|
+
|
|
467
|
+
<footer>
|
|
468
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Apr 15 2026 17:49:51 GMT+0100 (Irish Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
469
|
+
</footer>
|
|
470
|
+
|
|
471
|
+
<script>prettyPrint();</script>
|
|
472
|
+
<script src="scripts/polyfill.js"></script>
|
|
473
|
+
<script src="scripts/linenumber.js"></script>
|
|
474
|
+
|
|
475
|
+
<script src="scripts/search.js" defer></script>
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
<link type="text/css" rel="stylesheet" href="./docdash-overrides.css">
|
|
480
|
+
|
|
481
|
+
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
|
|
482
|
+
|
|
483
|
+
<script src="./mermaid-init.js"></script>
|
|
484
|
+
|
|
485
|
+
</body>
|
|
486
|
+
</html>
|