diff --git a/dist/PlainNormalizer/PlainNormalizer.d.ts b/dist/PlainNormalizer/PlainNormalizer.d.ts index 478c821ab21be102c420f6c70cfcab9799a30183..2e78fc4cec4196608228b38a69b3f36f2598a444 100644 --- a/dist/PlainNormalizer/PlainNormalizer.d.ts +++ b/dist/PlainNormalizer/PlainNormalizer.d.ts @@ -1,5 +1,7 @@ -export interface SealRemovalOptions { - sealUrl: string; +export interface Options { + sealUrl?: string; + normalizeImagePlain?: boolean; } -export declare const normalizePlainPart: (text: string, sealRemovalOptions?: SealRemovalOptions) => string; +export declare const normalizePlainPart: (text: string, options?: Options) => string; +export declare const cleanupImageText: (plain: string) => string; export declare const cleanupHiddenCharacters: (s: string) => string; diff --git a/dist/PlainNormalizer/PlainNormalizer.js b/dist/PlainNormalizer/PlainNormalizer.js index 6a76f108a8debd3e3f62ec95ebbe12814c613a94..dedea3fe27eaab78192b545289e6aa5d4b8708b8 100644 --- a/dist/PlainNormalizer/PlainNormalizer.js +++ b/dist/PlainNormalizer/PlainNormalizer.js @@ -1,16 +1,24 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.cleanupHiddenCharacters = exports.normalizePlainPart = void 0; +exports.cleanupHiddenCharacters = exports.cleanupImageText = exports.normalizePlainPart = void 0; // this is a Node module. require is a must to work across different envs const URL = require("url-parse"); const utils_1 = require("../utils"); -const normalizePlainPart = (text, sealRemovalOptions) => { +const defaultOptions = { + normalizeImagePlain: true, +}; +const normalizePlainPart = (text, options) => { + options = options + ? Object.assign(defaultOptions, Object.assign({}, options)) + : defaultOptions; text = exports.cleanupHiddenCharacters(text); text = patchOutlookSafelinksWrappers(text); - if (sealRemovalOptions) { - text = removeSeal(text, sealRemovalOptions.sealUrl); + if (options === null || options === void 0 ? void 0 : options.sealUrl) { + text = removeSeal(text, options.sealUrl); + } + if (options === null || options === void 0 ? void 0 : options.normalizeImagePlain) { + text = exports.cleanupImageText(text); } - text = cleanupImageText(text); text = utils_1.normalizeTextSpacings(text); return text.trim(); }; @@ -45,6 +53,7 @@ const cleanupImageText = (plain) => { const sealRegex = `\\[(image:\\s)(.*)\\]`; return plain.replace(new RegExp(sealRegex), "[$2]"); }; +exports.cleanupImageText = cleanupImageText; const cleanupHiddenCharacters = (s) => { const removeSymbols = new RegExp(/[\u200B]+/g); return s.replace(removeSymbols, ""); diff --git a/dist/PlainNormalizer/index.d.ts b/dist/PlainNormalizer/index.d.ts index 7fb02c437920fe2b32e76a694adef7edde2677b9..b6c35607403148f951f828819f0d5887fc237365 100644 --- a/dist/PlainNormalizer/index.d.ts +++ b/dist/PlainNormalizer/index.d.ts @@ -1,4 +1,5 @@ declare const _default: { - normalizePlain: (text: string, sealRemovalOptions?: import("./PlainNormalizer").SealRemovalOptions) => string; + normalizePlain: (text: string, options?: import("./PlainNormalizer").Options) => string; + cleanupImageText: (plain: string) => string; }; export default _default; diff --git a/dist/PlainNormalizer/index.js b/dist/PlainNormalizer/index.js index 2a16ea5ff2a36b0db5e4165f4ce70720652d9764..9d5f0b076664b32757ef5e8f3f1851467c4fa481 100644 --- a/dist/PlainNormalizer/index.js +++ b/dist/PlainNormalizer/index.js @@ -3,4 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); const PlainNormalizer_1 = require("./PlainNormalizer"); exports.default = { normalizePlain: PlainNormalizer_1.normalizePlainPart, + cleanupImageText: PlainNormalizer_1.cleanupImageText, };