@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
@@ -1,30 +1,89 @@
1
- <!DOCTYPE html><html lang="en" style="font-size:16px"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Source: LinkData.class.mjs</title><!--[if lt IE 9]>
2
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
3
- <![endif]--><script src="scripts/third-party/hljs.js" defer="defer"></script><script src="scripts/third-party/hljs-line-num.js" defer="defer"></script><script src="scripts/third-party/popper.js" defer="defer"></script><script src="scripts/third-party/tippy.js" defer="defer"></script><script src="scripts/third-party/tocbot.min.js"></script><script>var baseURL="/",locationPathname="";baseURL=(locationPathname=document.location.pathname).substr(0,locationPathname.lastIndexOf("/")+1)</script><link rel="stylesheet" href="styles/clean-jsdoc-theme.min.css"><svg aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display:none"><defs><symbol id="copy-icon" viewbox="0 0 488.3 488.3"><g><path d="M314.25,85.4h-227c-21.3,0-38.6,17.3-38.6,38.6v325.7c0,21.3,17.3,38.6,38.6,38.6h227c21.3,0,38.6-17.3,38.6-38.6V124 C352.75,102.7,335.45,85.4,314.25,85.4z M325.75,449.6c0,6.4-5.2,11.6-11.6,11.6h-227c-6.4,0-11.6-5.2-11.6-11.6V124 c0-6.4,5.2-11.6,11.6-11.6h227c6.4,0,11.6,5.2,11.6,11.6V449.6z"/><path d="M401.05,0h-227c-21.3,0-38.6,17.3-38.6,38.6c0,7.5,6,13.5,13.5,13.5s13.5-6,13.5-13.5c0-6.4,5.2-11.6,11.6-11.6h227 c6.4,0,11.6,5.2,11.6,11.6v325.7c0,6.4-5.2,11.6-11.6,11.6c-7.5,0-13.5,6-13.5,13.5s6,13.5,13.5,13.5c21.3,0,38.6-17.3,38.6-38.6 V38.6C439.65,17.3,422.35,0,401.05,0z"/></g></symbol><symbol id="search-icon" viewBox="0 0 512 512"><g><g><path d="M225.474,0C101.151,0,0,101.151,0,225.474c0,124.33,101.151,225.474,225.474,225.474 c124.33,0,225.474-101.144,225.474-225.474C450.948,101.151,349.804,0,225.474,0z M225.474,409.323 c-101.373,0-183.848-82.475-183.848-183.848S124.101,41.626,225.474,41.626s183.848,82.475,183.848,183.848 S326.847,409.323,225.474,409.323z"/></g></g><g><g><path d="M505.902,476.472L386.574,357.144c-8.131-8.131-21.299-8.131-29.43,0c-8.131,8.124-8.131,21.306,0,29.43l119.328,119.328 c4.065,4.065,9.387,6.098,14.715,6.098c5.321,0,10.649-2.033,14.715-6.098C514.033,497.778,514.033,484.596,505.902,476.472z"/></g></g></symbol><symbol id="font-size-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.246 15H4.754l-2 5H.6L7 4h2l6.4 16h-2.154l-2-5zm-.8-2L8 6.885 5.554 13h4.892zM21 12.535V12h2v8h-2v-.535a4 4 0 1 1 0-6.93zM19 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/></symbol><symbol id="add-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11 11V5h2v6h6v2h-6v6h-2v-6H5v-2z"/></symbol><symbol id="minus-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M5 11h14v2H5z"/></symbol><symbol id="dark-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M10 7a7 7 0 0 0 12 4.9v.1c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2h.1A6.979 6.979 0 0 0 10 7zm-6 5a8 8 0 0 0 15.062 3.762A9 9 0 0 1 8.238 4.938 7.999 7.999 0 0 0 4 12z"/></symbol><symbol id="light-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85l1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></symbol><symbol id="reset-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M18.537 19.567A9.961 9.961 0 0 1 12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10c0 2.136-.67 4.116-1.81 5.74L17 12h3a8 8 0 1 0-2.46 5.772l.997 1.795z"/></symbol><symbol id="down-icon" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.7803 6.21967C13.0732 6.51256 13.0732 6.98744 12.7803 7.28033L8.53033 11.5303C8.23744 11.8232 7.76256 11.8232 7.46967 11.5303L3.21967 7.28033C2.92678 6.98744 2.92678 6.51256 3.21967 6.21967C3.51256 5.92678 3.98744 5.92678 4.28033 6.21967L8 9.93934L11.7197 6.21967C12.0126 5.92678 12.4874 5.92678 12.7803 6.21967Z"></path></symbol><symbol id="codepen-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M16.5 13.202L13 15.535v3.596L19.197 15 16.5 13.202zM14.697 12L12 10.202 9.303 12 12 13.798 14.697 12zM20 10.869L18.303 12 20 13.131V10.87zM19.197 9L13 4.869v3.596l3.5 2.333L19.197 9zM7.5 10.798L11 8.465V4.869L4.803 9 7.5 10.798zM4.803 15L11 19.131v-3.596l-3.5-2.333L4.803 15zM4 13.131L5.697 12 4 10.869v2.262zM2 9a1 1 0 0 1 .445-.832l9-6a1 1 0 0 1 1.11 0l9 6A1 1 0 0 1 22 9v6a1 1 0 0 1-.445.832l-9 6a1 1 0 0 1-1.11 0l-9-6A1 1 0 0 1 2 15V9z"/></symbol><symbol id="close-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z"/></symbol><symbol id="menu-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M3 4h18v2H3V4zm0 7h18v2H3v-2zm0 7h18v2H3v-2z"/></symbol></defs></svg></head><body data-theme="fallback-light"><div class="sidebar-container"><div class="sidebar" id="sidebar"><a href="/" class="sidebar-title sidebar-title-anchor">Bartificer Linkifier</a><div class="sidebar-items-container"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-modules"><div>Modules</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-LinkData.html">LinkData</a></div><div class="sidebar-section-children"><a href="module-LinkTemplate.html">LinkTemplate</a></div><div class="sidebar-section-children"><a href="module-Linkifier.html">Linkifier</a></div><div class="sidebar-section-children"><a href="module-PageData.html">PageData</a></div><div class="sidebar-section-children"><a href="module-defaults.html">defaults</a></div><div class="sidebar-section-children"><a href="module-linkify.html">linkify</a></div><div class="sidebar-section-children"><a href="module-utilities.html">utilities</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-LinkData.LinkData.html">LinkData</a></div><div class="sidebar-section-children"><a href="module-LinkTemplate.LinkTemplate.html">LinkTemplate</a></div><div class="sidebar-section-children"><a href="module-Linkifier.Linkifier.html">Linkifier</a></div><div class="sidebar-section-children"><a href="module-PageData.PageData.html">PageData</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-externals"><div>Externals</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-cheerio.html">cheerio</a></div><div class="sidebar-section-children"><a href="module-mustache.html">mustache</a></div><div class="sidebar-section-children"><a href="module-node-fetch.html">node-fetch</a></div><div class="sidebar-section-children"><a href="module-title-case.html">title-case</a></div><div class="sidebar-section-children"><a href="module-urijs.html">urijs</a></div><div class="sidebar-section-children"><a href="module-url-slug.html">url-slug</a></div></div></div></div></div><div class="navbar-container" id="VuAckcnZhf"><nav class="navbar"><div class="navbar-left-items"></div><div class="navbar-right-items"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#dark-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div><nav></nav></nav></div><div class="toc-container"><div class="toc-content"><span class="bold">On this page</span><div id="eed4d2a0bfd64539bb9df78095dec881"></div></div></div><div class="body-wrapper"><div class="main-content"><div class="main-wrapper"><section id="source-page" class="source-page"><header><h1 id="title" class="has-anchor">LinkData.class.mjs</h1></header><article><pre class="prettyprint source lang-js"><code>/**
4
- * @file The definition of the class representing a link.
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+
5
+ <meta charset="utf-8">
6
+ <title>LinkData.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">LinkData.class.mjs</h1>
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+ <section>
61
+ <article>
62
+ <pre class="prettyprint source linenums"><code>/**
63
+ * @file Data model for link information.
5
64
  * @author Bart Busschots &lt;opensource@bartificer.ie>
65
+ * @license MIT
6
66
  */
7
67
 
8
68
  /**
9
- * This module provides as class for representing the information that can be used when rendering a link.
10
- * @module LinkData
69
+ * This module provides the class for representing the information that can be used to render a link.
70
+ * @module link-data
11
71
  * @requires module:urijs
12
72
  */
13
73
  import {default as URI} from 'urijs';
14
74
 
15
75
  /**
16
- * A class for representing the information about a link, in the abstract.
76
+ * The information that can be used to render a link.
77
+ *
78
+ * Instances of this class are created from the information extracted from web pages by data transformers.
79
+ * @see {@link dataTransformer} for details of how instances of this class are created.
17
80
  */
18
81
  export class LinkData {
19
82
  /**
20
- * This constructor throws a {@link ValidationError} unless a valid URL is passed.
21
- *
22
- * @param {URL} url - The link's URL.
83
+ * @param {string} url - The link's URL.
23
84
  * @param {string} [text] - The link's text, defaults to the URL.
24
- * @param {string} [description] - A description for the link, defaults to
25
- * the link text.
26
- * @throws {ValidationError} A validation error is thrown if an invalid URL
27
- * is passed.
85
+ * @param {string} [description] - A description for the link, defaults to the link text.
86
+ * @throws {TypeError} A TypeError is thrown if an invalid URL is passed.
28
87
  */
29
88
  constructor(url, text, description){
30
89
  // TO DO - add validation
@@ -33,9 +92,9 @@ export class LinkData {
33
92
  * The link's URL as a URI.js object.
34
93
  *
35
94
  * @private
36
- * @type {URIObject}
95
+ * @type {module:urijs}
37
96
  */
38
- this._uri = URI();
97
+ this._uri = URI(); // throws a TypeError if the URL is invalid
39
98
 
40
99
  /**
41
100
  * The link text.
@@ -64,78 +123,50 @@ export class LinkData {
64
123
  }
65
124
 
66
125
  /**
67
- * @returns {string} a URL string
126
+ * The URL the link points to as a string.
127
+ * @type {string}
68
128
  */
69
129
  get url(){
70
130
  return this._uri.toString();
71
131
  }
72
-
73
- /**
74
- * Get or set the URL.
75
- *
76
- * @param {string} url - A new URL as a string.
77
- */
78
132
  set url(url){
79
133
  this._uri = URI(String(url)).normalize();
80
134
  }
81
135
 
82
136
  /**
83
- * Get the URL as a URI.js object.
84
- *
85
- * @returns {Object}
137
+ * The URL the link points to as a URI.js object representing the URL.
138
+ * @type {module:urijs}
139
+ * @readonly
86
140
  */
87
141
  get uri(){
88
142
  return this._uri.clone();
89
143
  }
90
144
 
91
145
  /**
92
- * @returns {string}
146
+ * The link text.
147
+ * @type {string}
93
148
  */
94
149
  get text(){
95
150
  return this._text;
96
151
  }
97
-
98
- /**
99
- * @param {string} [text] - New link text. The value will be coerced to a string and trimmed.
100
- */
101
152
  set text(text){
102
153
  this._text = String(text).trim();
103
154
  }
104
155
 
105
156
  /**
106
- * @returns {string}
157
+ * The link description.
158
+ * @type {string}
107
159
  */
108
160
  get description(){
109
161
  return this._description;
110
162
  }
111
-
112
- /**
113
- * @param {string} description
114
- */
115
163
  set description(description){
116
164
  this._description = String(description);
117
165
  }
118
166
 
119
167
  /**
120
- * Get the link data as a plain object of the form:
121
- * ```
122
- * {
123
- * url: 'http://www.bartificer.net/',
124
- * text: 'the link text',
125
- * description: 'the link description',
126
- * uri: {
127
- * hostname: 'www.bartificer.net',
128
- * path: '/',
129
- * hasPath: false
130
- * }
131
- * }
132
- * ```
133
- *
134
- * Note that the `uri` could contain more fields - it's initialised with
135
- * output from the `URI.parse()` function from the `URI` module.
136
- *
137
- * @returns {plainObject}
138
- * @see {@link https://medialize.github.io/URI.js/docs.html#static-parse}
168
+ * The link data as a plain object for use in Mustache templates and the like.
169
+ * @returns {plainLinkInformationObject} A plain object containing the link data.
139
170
  */
140
171
  asPlainObject(){
141
172
  let ans = {
@@ -147,4 +178,36 @@ export class LinkData {
147
178
  ans.uri.hasPath = ans.uri.path !== '/';
148
179
  return ans;
149
180
  }
150
- };</code></pre></article></section></div></div></div><div class="search-container" id="PkfLWpAbet" style="display:none"><div class="wrapper" id="iCxFxjkHbP"><button class="icon-button search-close-button" id="VjLlGakifb" aria-label="close search"><svg><use xlink:href="#close-icon"></use></svg></button><div class="search-box-c"><svg><use xlink:href="#search-icon"></use></svg> <input type="text" id="vpcKVYIppa" class="search-input" placeholder="Search..." autofocus></div><div class="search-result-c" id="fWwVHRuDuN"><span class="search-result-c-text">Type anything to view search result</span></div></div></div><div class="mobile-menu-icon-container"><button class="icon-button" id="mobile-menu" data-isopen="false" aria-label="menu"><svg><use xlink:href="#menu-icon"></use></svg></button></div><div id="mobile-sidebar" class="mobile-sidebar-container"><div class="mobile-sidebar-wrapper"><a href="/" class="sidebar-title sidebar-title-anchor">Bartificer Linkifier</a><div class="mobile-nav-links"></div><div class="mobile-sidebar-items-c"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-modules"><div>Modules</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-LinkData.html">LinkData</a></div><div class="sidebar-section-children"><a href="module-LinkTemplate.html">LinkTemplate</a></div><div class="sidebar-section-children"><a href="module-Linkifier.html">Linkifier</a></div><div class="sidebar-section-children"><a href="module-PageData.html">PageData</a></div><div class="sidebar-section-children"><a href="module-defaults.html">defaults</a></div><div class="sidebar-section-children"><a href="module-linkify.html">linkify</a></div><div class="sidebar-section-children"><a href="module-utilities.html">utilities</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-LinkData.LinkData.html">LinkData</a></div><div class="sidebar-section-children"><a href="module-LinkTemplate.LinkTemplate.html">LinkTemplate</a></div><div class="sidebar-section-children"><a href="module-Linkifier.Linkifier.html">Linkifier</a></div><div class="sidebar-section-children"><a href="module-PageData.PageData.html">PageData</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-externals"><div>Externals</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-cheerio.html">cheerio</a></div><div class="sidebar-section-children"><a href="module-mustache.html">mustache</a></div><div class="sidebar-section-children"><a href="module-node-fetch.html">node-fetch</a></div><div class="sidebar-section-children"><a href="module-title-case.html">title-case</a></div><div class="sidebar-section-children"><a href="module-urijs.html">urijs</a></div><div class="sidebar-section-children"><a href="module-url-slug.html">url-slug</a></div></div></div><div class="mobile-navbar-actions"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#dark-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div></div></div><script type="text/javascript" src="scripts/core.min.js"></script><script src="scripts/search.min.js" defer="defer"></script><script src="scripts/third-party/fuse.js" defer="defer"></script><script type="text/javascript">var tocbotInstance=tocbot.init({tocSelector:"#eed4d2a0bfd64539bb9df78095dec881",contentSelector:".main-content",headingSelector:"h1, h2, h3",hasInnerContainers:!0,scrollContainer:".main-content",headingsOffset:130,onClick:bringLinkToView})</script></body></html>
181
+ };</code></pre>
182
+ </article>
183
+ </section>
184
+
185
+
186
+
187
+
188
+
189
+
190
+ </div>
191
+
192
+ <br class="clear">
193
+
194
+ <footer>
195
+ 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.
196
+ </footer>
197
+
198
+ <script>prettyPrint();</script>
199
+ <script src="scripts/polyfill.js"></script>
200
+ <script src="scripts/linenumber.js"></script>
201
+
202
+ <script src="scripts/search.js" defer></script>
203
+
204
+
205
+
206
+ <link type="text/css" rel="stylesheet" href="./docdash-overrides.css">
207
+
208
+ <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
209
+
210
+ <script src="./mermaid-init.js"></script>
211
+
212
+ </body>
213
+ </html>
@@ -1,29 +1,92 @@
1
- <!DOCTYPE html><html lang="en" style="font-size:16px"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Source: LinkTemplate.class.mjs</title><!--[if lt IE 9]>
2
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
3
- <![endif]--><script src="scripts/third-party/hljs.js" defer="defer"></script><script src="scripts/third-party/hljs-line-num.js" defer="defer"></script><script src="scripts/third-party/popper.js" defer="defer"></script><script src="scripts/third-party/tippy.js" defer="defer"></script><script src="scripts/third-party/tocbot.min.js"></script><script>var baseURL="/",locationPathname="";baseURL=(locationPathname=document.location.pathname).substr(0,locationPathname.lastIndexOf("/")+1)</script><link rel="stylesheet" href="styles/clean-jsdoc-theme.min.css"><svg aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display:none"><defs><symbol id="copy-icon" viewbox="0 0 488.3 488.3"><g><path d="M314.25,85.4h-227c-21.3,0-38.6,17.3-38.6,38.6v325.7c0,21.3,17.3,38.6,38.6,38.6h227c21.3,0,38.6-17.3,38.6-38.6V124 C352.75,102.7,335.45,85.4,314.25,85.4z M325.75,449.6c0,6.4-5.2,11.6-11.6,11.6h-227c-6.4,0-11.6-5.2-11.6-11.6V124 c0-6.4,5.2-11.6,11.6-11.6h227c6.4,0,11.6,5.2,11.6,11.6V449.6z"/><path d="M401.05,0h-227c-21.3,0-38.6,17.3-38.6,38.6c0,7.5,6,13.5,13.5,13.5s13.5-6,13.5-13.5c0-6.4,5.2-11.6,11.6-11.6h227 c6.4,0,11.6,5.2,11.6,11.6v325.7c0,6.4-5.2,11.6-11.6,11.6c-7.5,0-13.5,6-13.5,13.5s6,13.5,13.5,13.5c21.3,0,38.6-17.3,38.6-38.6 V38.6C439.65,17.3,422.35,0,401.05,0z"/></g></symbol><symbol id="search-icon" viewBox="0 0 512 512"><g><g><path d="M225.474,0C101.151,0,0,101.151,0,225.474c0,124.33,101.151,225.474,225.474,225.474 c124.33,0,225.474-101.144,225.474-225.474C450.948,101.151,349.804,0,225.474,0z M225.474,409.323 c-101.373,0-183.848-82.475-183.848-183.848S124.101,41.626,225.474,41.626s183.848,82.475,183.848,183.848 S326.847,409.323,225.474,409.323z"/></g></g><g><g><path d="M505.902,476.472L386.574,357.144c-8.131-8.131-21.299-8.131-29.43,0c-8.131,8.124-8.131,21.306,0,29.43l119.328,119.328 c4.065,4.065,9.387,6.098,14.715,6.098c5.321,0,10.649-2.033,14.715-6.098C514.033,497.778,514.033,484.596,505.902,476.472z"/></g></g></symbol><symbol id="font-size-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.246 15H4.754l-2 5H.6L7 4h2l6.4 16h-2.154l-2-5zm-.8-2L8 6.885 5.554 13h4.892zM21 12.535V12h2v8h-2v-.535a4 4 0 1 1 0-6.93zM19 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/></symbol><symbol id="add-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11 11V5h2v6h6v2h-6v6h-2v-6H5v-2z"/></symbol><symbol id="minus-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M5 11h14v2H5z"/></symbol><symbol id="dark-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M10 7a7 7 0 0 0 12 4.9v.1c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2h.1A6.979 6.979 0 0 0 10 7zm-6 5a8 8 0 0 0 15.062 3.762A9 9 0 0 1 8.238 4.938 7.999 7.999 0 0 0 4 12z"/></symbol><symbol id="light-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85l1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></symbol><symbol id="reset-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M18.537 19.567A9.961 9.961 0 0 1 12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10c0 2.136-.67 4.116-1.81 5.74L17 12h3a8 8 0 1 0-2.46 5.772l.997 1.795z"/></symbol><symbol id="down-icon" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.7803 6.21967C13.0732 6.51256 13.0732 6.98744 12.7803 7.28033L8.53033 11.5303C8.23744 11.8232 7.76256 11.8232 7.46967 11.5303L3.21967 7.28033C2.92678 6.98744 2.92678 6.51256 3.21967 6.21967C3.51256 5.92678 3.98744 5.92678 4.28033 6.21967L8 9.93934L11.7197 6.21967C12.0126 5.92678 12.4874 5.92678 12.7803 6.21967Z"></path></symbol><symbol id="codepen-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M16.5 13.202L13 15.535v3.596L19.197 15 16.5 13.202zM14.697 12L12 10.202 9.303 12 12 13.798 14.697 12zM20 10.869L18.303 12 20 13.131V10.87zM19.197 9L13 4.869v3.596l3.5 2.333L19.197 9zM7.5 10.798L11 8.465V4.869L4.803 9 7.5 10.798zM4.803 15L11 19.131v-3.596l-3.5-2.333L4.803 15zM4 13.131L5.697 12 4 10.869v2.262zM2 9a1 1 0 0 1 .445-.832l9-6a1 1 0 0 1 1.11 0l9 6A1 1 0 0 1 22 9v6a1 1 0 0 1-.445.832l-9 6a1 1 0 0 1-1.11 0l-9-6A1 1 0 0 1 2 15V9z"/></symbol><symbol id="close-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z"/></symbol><symbol id="menu-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M3 4h18v2H3V4zm0 7h18v2H3v-2zm0 7h18v2H3v-2z"/></symbol></defs></svg></head><body data-theme="fallback-light"><div class="sidebar-container"><div class="sidebar" id="sidebar"><a href="/" class="sidebar-title sidebar-title-anchor">Bartificer Linkifier</a><div class="sidebar-items-container"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-modules"><div>Modules</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-LinkData.html">LinkData</a></div><div class="sidebar-section-children"><a href="module-LinkTemplate.html">LinkTemplate</a></div><div class="sidebar-section-children"><a href="module-Linkifier.html">Linkifier</a></div><div class="sidebar-section-children"><a href="module-PageData.html">PageData</a></div><div class="sidebar-section-children"><a href="module-defaults.html">defaults</a></div><div class="sidebar-section-children"><a href="module-linkify.html">linkify</a></div><div class="sidebar-section-children"><a href="module-utilities.html">utilities</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-LinkData.LinkData.html">LinkData</a></div><div class="sidebar-section-children"><a href="module-LinkTemplate.LinkTemplate.html">LinkTemplate</a></div><div class="sidebar-section-children"><a href="module-Linkifier.Linkifier.html">Linkifier</a></div><div class="sidebar-section-children"><a href="module-PageData.PageData.html">PageData</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-externals"><div>Externals</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-cheerio.html">cheerio</a></div><div class="sidebar-section-children"><a href="module-mustache.html">mustache</a></div><div class="sidebar-section-children"><a href="module-node-fetch.html">node-fetch</a></div><div class="sidebar-section-children"><a href="module-title-case.html">title-case</a></div><div class="sidebar-section-children"><a href="module-urijs.html">urijs</a></div><div class="sidebar-section-children"><a href="module-url-slug.html">url-slug</a></div></div></div></div></div><div class="navbar-container" id="VuAckcnZhf"><nav class="navbar"><div class="navbar-left-items"></div><div class="navbar-right-items"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#dark-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div><nav></nav></nav></div><div class="toc-container"><div class="toc-content"><span class="bold">On this page</span><div id="eed4d2a0bfd64539bb9df78095dec881"></div></div></div><div class="body-wrapper"><div class="main-content"><div class="main-wrapper"><section id="source-page" class="source-page"><header><h1 id="title" class="has-anchor">LinkTemplate.class.mjs</h1></header><article><pre class="prettyprint source lang-js"><code>/**
4
- * @file The definition of the class representing a link generation template.
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+
5
+ <meta charset="utf-8">
6
+ <title>LinkTemplate.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">LinkTemplate.class.mjs</h1>
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+ <section>
61
+ <article>
62
+ <pre class="prettyprint source linenums"><code>/**
63
+ * @file Link generation templates.
5
64
  * @author Bart Busschots &lt;opensource@bartificer.ie>
65
+ * @license MIT
6
66
  */
7
67
 
8
68
  /**
9
- * This module provides as class for representing a template used for generating links.
10
- * @module LinkTemplate
69
+ * This module provides as class for representing the templates used to generate links from link data objects.
70
+ * @module link-template
11
71
  * @requires module:urijs
12
72
  */
13
73
 
14
74
  /**
15
- * A class representing the a template that can be used to render links.
75
+ * A class representing the templates used to render link data objects as actual links.
76
+ * @see {@link module:link-data.LinkData} for the data objects that are rendered with these templates.
16
77
  */
17
78
  export class LinkTemplate{
18
79
  /**
19
80
  * @param {string} templateString - A Moustache template string.
20
- * @param {Array} [filters=[]] - An optional array of filter functions.
21
- * Each element in the array should itself be an array where the first
22
- * element is a string specifying which fields the filter should be applied
23
- * to (one of `'all'`, `'url'`, `'text'`, or `'description'`), and the
24
- * second the filter function itself which should be a function that takes
25
- * a single string as an argument and returns a filtered version of that
26
- * string.
81
+ * @param {templateFieldFilterTuple[]} [filters=[]] - an optional set of filter functions to apply to some or all template fields.
82
+ * @example &lt;caption>Example of defining a template with filters&lt;/caption>
83
+ * let template = new LinkTemplate(
84
+ * '&lt;a href="{{{url}}}">{{{text}}}&lt;/a>',
85
+ * [
86
+ * ['url', linkify.util.stripUTMParameters],
87
+ * ['text', linkify.util.regulariseWhitespace]
88
+ * ]
89
+ * );
27
90
  */
28
91
  constructor(templateString, filters){
29
92
  // TO DO - add validation
@@ -46,7 +109,7 @@ export class LinkTemplate{
46
109
  * * `description` - filters to be applied just the link description.
47
110
  *
48
111
  * @private
49
- * @type {Object.&lt;string, filterFunction>}
112
+ * @type {Object.&lt;"all"|"url"|"text"|"description", templateFieldFilterFunction>}
50
113
  */
51
114
  this._filters = {
52
115
  all: [],
@@ -64,20 +127,12 @@ export class LinkTemplate{
64
127
  }
65
128
 
66
129
  /**
67
- * Get the template string.
68
- *
69
- * @returns {string}
130
+ * The Mustache template string. Will be coerced to a string with `String(templateString)`.
131
+ * @type {string}
70
132
  */
71
133
  get templateString(){
72
134
  return this._templateString;
73
135
  }
74
-
75
- /**
76
- * Set the template string. Should be in Mustache format. All values passed
77
- * will be coerced to strings.
78
- *
79
- * @param {string} templateString
80
- */
81
136
  set templateString(templateString){
82
137
  this._templateString = String(templateString);
83
138
  }
@@ -88,10 +143,9 @@ export class LinkTemplate{
88
143
  * If an invalid args are passed, the function does not save the filter or
89
144
  * throw an error, but it does log a warning.
90
145
  *
91
- * @param {string} fieldName - One of `'all'`, `'url'`, `'text'`, or
92
- * `'description'`.
93
- * @param {function} filterFn - the filter function.
94
- * @returns {LinkTemplate} Returns a reference to self to facilitate function chaining.
146
+ * @param {"all"|"url"|"text"|"description"} fieldName
147
+ * @param {templateFieldFilterFunction} filterFn - the filter function.
148
+ * @returns {module:link-template.LinkTemplate} Returns a reference to self to facilitate function chaining.
95
149
  */
96
150
  addFilter(fieldName, filterFn){
97
151
  // make sure that args are at least plausibly valid
@@ -114,13 +168,11 @@ export class LinkTemplate{
114
168
  }
115
169
 
116
170
  /**
117
- * A function get the filter functions that should be applied to any given
118
- * field.
171
+ * Get the filter functions that should be applied to any given field.
119
172
  *
120
- * @param {string} fieldName - one of `'url'`, `'text'`, or
121
- * `'description'`.
122
- * @returns {function[]} returns an array of callbacks, which may be
123
- * empty. An empty array is returned if an invalid field name is passed.
173
+ * @param {"all"|"url"|"text"|"description"} fieldName
174
+ * @returns {templateFieldFilterFunction[]} returns an array of callbacks, which may be
175
+ * empty. An empty array is also returned if an invalid field name is passed.
124
176
  */
125
177
  filtersFor(fieldName){
126
178
  fieldName = String(fieldName);
@@ -138,4 +190,36 @@ export class LinkTemplate{
138
190
  }
139
191
  return ans;
140
192
  }
141
- };</code></pre></article></section></div></div></div><div class="search-container" id="PkfLWpAbet" style="display:none"><div class="wrapper" id="iCxFxjkHbP"><button class="icon-button search-close-button" id="VjLlGakifb" aria-label="close search"><svg><use xlink:href="#close-icon"></use></svg></button><div class="search-box-c"><svg><use xlink:href="#search-icon"></use></svg> <input type="text" id="vpcKVYIppa" class="search-input" placeholder="Search..." autofocus></div><div class="search-result-c" id="fWwVHRuDuN"><span class="search-result-c-text">Type anything to view search result</span></div></div></div><div class="mobile-menu-icon-container"><button class="icon-button" id="mobile-menu" data-isopen="false" aria-label="menu"><svg><use xlink:href="#menu-icon"></use></svg></button></div><div id="mobile-sidebar" class="mobile-sidebar-container"><div class="mobile-sidebar-wrapper"><a href="/" class="sidebar-title sidebar-title-anchor">Bartificer Linkifier</a><div class="mobile-nav-links"></div><div class="mobile-sidebar-items-c"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-modules"><div>Modules</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-LinkData.html">LinkData</a></div><div class="sidebar-section-children"><a href="module-LinkTemplate.html">LinkTemplate</a></div><div class="sidebar-section-children"><a href="module-Linkifier.html">Linkifier</a></div><div class="sidebar-section-children"><a href="module-PageData.html">PageData</a></div><div class="sidebar-section-children"><a href="module-defaults.html">defaults</a></div><div class="sidebar-section-children"><a href="module-linkify.html">linkify</a></div><div class="sidebar-section-children"><a href="module-utilities.html">utilities</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-LinkData.LinkData.html">LinkData</a></div><div class="sidebar-section-children"><a href="module-LinkTemplate.LinkTemplate.html">LinkTemplate</a></div><div class="sidebar-section-children"><a href="module-Linkifier.Linkifier.html">Linkifier</a></div><div class="sidebar-section-children"><a href="module-PageData.PageData.html">PageData</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-externals"><div>Externals</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-cheerio.html">cheerio</a></div><div class="sidebar-section-children"><a href="module-mustache.html">mustache</a></div><div class="sidebar-section-children"><a href="module-node-fetch.html">node-fetch</a></div><div class="sidebar-section-children"><a href="module-title-case.html">title-case</a></div><div class="sidebar-section-children"><a href="module-urijs.html">urijs</a></div><div class="sidebar-section-children"><a href="module-url-slug.html">url-slug</a></div></div></div><div class="mobile-navbar-actions"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#dark-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div></div></div><script type="text/javascript" src="scripts/core.min.js"></script><script src="scripts/search.min.js" defer="defer"></script><script src="scripts/third-party/fuse.js" defer="defer"></script><script type="text/javascript">var tocbotInstance=tocbot.init({tocSelector:"#eed4d2a0bfd64539bb9df78095dec881",contentSelector:".main-content",headingSelector:"h1, h2, h3",hasInnerContainers:!0,scrollContainer:".main-content",headingsOffset:130,onClick:bringLinkToView})</script></body></html>
193
+ };</code></pre>
194
+ </article>
195
+ </section>
196
+
197
+
198
+
199
+
200
+
201
+
202
+ </div>
203
+
204
+ <br class="clear">
205
+
206
+ <footer>
207
+ 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.
208
+ </footer>
209
+
210
+ <script>prettyPrint();</script>
211
+ <script src="scripts/polyfill.js"></script>
212
+ <script src="scripts/linenumber.js"></script>
213
+
214
+ <script src="scripts/search.js" defer></script>
215
+
216
+
217
+
218
+ <link type="text/css" rel="stylesheet" href="./docdash-overrides.css">
219
+
220
+ <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
221
+
222
+ <script src="./mermaid-init.js"></script>
223
+
224
+ </body>
225
+ </html>