From ca1a516fd008abc9eed1a858b64924e684455459 Mon Sep 17 00:00:00 2001 From: Juli Ovechkina Date: Thu, 21 Sep 2023 19:44:40 +0100 Subject: [PATCH] fix: remove strict typograpph rules --- src/text-transform/utils.ts | 38 +++++++------------------------------ 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/src/text-transform/utils.ts b/src/text-transform/utils.ts index 1925a1ef6..e75e872b6 100644 --- a/src/text-transform/utils.ts +++ b/src/text-transform/utils.ts @@ -4,6 +4,8 @@ import Typograf from 'typograf'; import {Lang} from '../utils/configure'; +import AddRuleOptions = typograf.AddRuleOptions; + export enum TransformType { Text = 'text', Html = 'html', @@ -40,37 +42,11 @@ export const sanitizeStripOptions: sanitize.IOptions = { allowedAttributes: {}, }; -Typograf.addRule({ - name: 'common/html/sup', - queue: 'end', - /* TODO mange with it: in typograf types AddRuleOptions.handler takes only one param: text. - But in cloud-www was used this notation with 3 params */ - //@ts-ignore - handler: function (text, settings, context) { - const {prefs: {htmlEntity: {type = ''} = {}} = {}} = context; - - let symbols; - switch (type) { - case 'digit': - symbols = '®|©|™'; - break; - case 'name': - symbols = '®|©|™'; - break; - default: - symbols = '®|©|™'; - break; - } - - const symbolsRegex = new RegExp( - `(?\\s*)(${symbols})|(${symbols})(?!\\s*<\\/sup>)`, - 'gi', - ); - - return text.replace(symbolsRegex, '$1'); - }, - htmlAttrs: false, -}); +export function addTypografRules(options: AddRuleOptions[]) { + options.forEach((option) => { + Typograf.addRule(option); + }); +} function enableRules(tp: typograf.Typograf) { const {disabled, enabled} = typografConfig;