From 8157ca5f0280dbcbf99eda210cd83130ec77c0b1 Mon Sep 17 00:00:00 2001 From: Fringg Date: Wed, 4 Mar 2026 04:49:40 +0300 Subject: [PATCH] fix: ordered list numbering in Info page shows correct sequence Each numbered rule (1, 2, 3...) was rendered as separate
    elements all starting from 1. Added start attribute to preserve original numbering and allowed it through DOMPurify sanitization. --- src/pages/Info.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/Info.tsx b/src/pages/Info.tsx index b6717fd..24b73b5 100644 --- a/src/pages/Info.tsx +++ b/src/pages/Info.tsx @@ -100,7 +100,7 @@ const sanitizeHtml = (html: string): string => { 'div', 'tg-spoiler', ], - ALLOWED_ATTR: ['href', 'target', 'rel', 'class'], + ALLOWED_ATTR: ['href', 'target', 'rel', 'class', 'start'], ALLOW_DATA_ATTR: false, }); }; @@ -135,12 +135,13 @@ const formatContent = (content: string): string => { if (/^[-•]\s/.test(trimmed) || /^\d+[.)]\s/.test(trimmed)) { const lines = trimmed.split('\n'); const isOrdered = /^\d+[.)]\s/.test(lines[0]); + const startNum = isOrdered ? parseInt(lines[0].match(/^(\d+)/)?.[1] || '1', 10) : 1; const listItems = lines .map((line) => line.replace(/^[-•]\s*/, '').replace(/^\d+[.)]\s*/, '')) .filter((line) => line.trim()) .map((line) => `
  1. ${line}
  2. `) .join(''); - return isOrdered ? `
      ${listItems}
    ` : ``; + return isOrdered ? `
      ${listItems}
    ` : ``; } // Regular paragraph — single newlines become