UNPKG

omniscript-cli

Version:

OmniScript Format (OSF) CLI tools - Command-line interface for parsing, validating, and converting OSF documents

36 lines 1.34 kB
"use strict"; // File: omniscript-core/cli/src/utils/text-renderer.ts // What: Utilities for rendering text runs to HTML // Why: Shared text rendering logic for HTML format // Related: renderers/html.ts, html-escape.ts Object.defineProperty(exports, "__esModule", { value: true }); exports.renderTextRun = renderTextRun; const html_escape_1 = require("./html-escape"); function renderTextRun(run) { if (typeof run === 'string') { return (0, html_escape_1.escapeHtml)(run); } if ('type' in run) { if (run.type === 'link') { return `<a href="${(0, html_escape_1.escapeHtml)(run.url)}">${(0, html_escape_1.escapeHtml)(run.text)}</a>`; } if (run.type === 'image') { return `<img src="${(0, html_escape_1.escapeHtml)(run.url)}" alt="${(0, html_escape_1.escapeHtml)(run.alt)}" />`; } } if ('text' in run) { let text = (0, html_escape_1.escapeHtml)(run.text); const styledRun = run; if (styledRun.bold) text = `<strong>${text}</strong>`; if (styledRun.italic) text = `<em>${text}</em>`; if (styledRun.underline) text = `<u>${text}</u>`; if (styledRun.strike) text = `<s>${text}</s>`; return text; } return ''; } //# sourceMappingURL=text-renderer.js.map