-function htmlTail() {
- return ` </body>
-</html>`;
-}
-
-
-/**
- * Render a navigation link for the header section.
- * @param {Object} nav
- * @param {String} nav.href
- * @param {String} nav.class
- * @param {String} nav.text
- * @returns {String}
- */
-function renderNavLink(nav) {
- return `<li>
- <a href="${nav.href}"${nav.class ? (' class="' + nav.class + '"') : ''}>${nav.text}</a>
-</li>`;
-}
-
-
-/**
- * Render the navigation header, and open the main section.
- * @param {String} pageTitle
- * @param {Object[]} navLinks
- * @returns {String}
- */
-function htmlHeader(pageTitle, navLinks = []) {
- return ` <header>
- <h1>${pageTitle}</h1>
- <nav>` +
- (navLinks.length ? `
- <ol>
- ${navLinks.map((l) => renderNavLink(l)).join('\n')}
- </ol>`
- : '') + `
- </nav>
- </header>
- <main>`;
-}
-
-
-/**
- * Close the main section and finish off with boilerplate.
- * @returns {String}
- */
-function htmlFooter() {
- return ` </main>
- <footer>
- <ol>
- <li>
- <a href="https://git.squeep.com/?p=websub-hub;a=tree">Development Repository</a>
- </li>
- <li>
- <a href="https://squeep.com/">A Squeep Infrastructure Component</a>
- </li>
- <li>
- ©<time datetime="2021">ⅯⅯⅩⅩⅠ</time>
- </li>
- </ol>
- </footer>`;
-}
-
-
-/**
- * Render all parts of an HTML page.
- * @param {Number} pagePathLevel
- * @param {String} pageTitle
- * @param {String[]} headElements
- * @param {Object[]} navLinks
- * @param {String[]} main
- * @returns {String}
- */
-function htmlTemplate(pagePathLevel, pageTitle, headElements = [], navLinks = [], main = []) {
- return [
- htmlHead(pagePathLevel, pageTitle, headElements),
- htmlHeader(pageTitle, navLinks),
- ...main,
- htmlFooter(),
- htmlTail(),
- ].join('\n');
+function xmlEscape(string) {
+ if (typeof string === 'number') {
+ return string;
+ }
+ if (typeof string !== 'string') {
+ return undefined;
+ }
+ // eslint-disable-next-line security/detect-object-injection
+ return string.replace(/[<>&'"]/, (c) => ({
+ '<': '<',
+ '>': '>',
+ '&': '&',
+ '\'': ''',
+ '"': '"',
+ }[c]));