/* * Copyright (c) 2010, 2025 BSI Business Systems Integration AG * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 */ import {CachedElement, scout, strings} from '../index'; /** * Replaces character HTML entities (e.g.  , >, etc.). */ export class PlainTextEncoder { protected _cachedElement: CachedElement; constructor() { this._cachedElement = new CachedElement('textarea'); } encode(text: string, options?: PlainTextEncoderOptions): string { options = options || {}; if (!text) { return text; } text = strings.asString(text); // Regexp is used to replace the tags. // It is not possible to use jquery's text() function or to create a html element and use textContent/innerText, because it does not handle line breaks as desired. // Remove comments text = text.replace(/