Skip to content
Snippets Groups Projects
Commit f2039960 authored by Igor Markin's avatar Igor Markin
Browse files

Use proper spacing normalisation function for HTML

parent 1f3ce1b5
No related branches found
No related tags found
1 merge request!18Optimisations
......@@ -11,7 +11,7 @@ import {
pruneOutlookElement,
} from "./strategies/outlook";
import { EMAIL_VENDORS } from "../constants";
import { normalizeTextSpacings, removeSpacesAndLinebreaks } from "../utils";
import { normalizeTextSpacings } from "../utils";
import {
amendGmailNodes,
cleanupGMailElementAttributes,
......@@ -125,7 +125,7 @@ export const printHtmlNode = (node: Node, depth: number): string => {
switch (node.nodeType) {
case TEXT_NODE: {
const text = removeSpacesAndLinebreaks(node.textContent);
const text = normalizeTextSpacings(node.textContent).trim();
if (text.length) {
result += "<TEXT>";
result += text;
......
export const removeSpacesAndLinebreaks = (s: string): string => {
const removeSymbols = new RegExp(/[\r\n\v\s\u200B]+/g);
return s.replace(removeSymbols, "").trim();
};
export const normalizeTextSpacings = (s: string): string => {
return s.replace(/[\r\n\v\s\u00A0]+/g, " ");
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment