mirror of
https://github.com/iOfficeAI/OfficeCLI
synced 2026-04-21 13:37:23 +00:00
fix(preview): deduplicate heading numbers when text already contains them
Some documents include heading numbers directly in the paragraph text (e.g., '1.2.1 Title'). Skip prepending the auto-resolved number when the paragraph text already starts with the computed number string. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
3ed36c930f
commit
568286936f
1 changed files with 4 additions and 1 deletions
|
|
@ -1081,7 +1081,10 @@ public partial class WordHandler
|
|||
for (int lk = 0; lk <= hIlvl; lk++)
|
||||
numStr = numStr.Replace($"%{lk + 1}",
|
||||
headingCounters.GetValueOrDefault(lk, 0).ToString());
|
||||
sb.Append($"<span class=\"heading-num\" style=\"margin-right:0.5em\">{HtmlEncode(numStr)}</span>");
|
||||
// Skip if paragraph text already starts with the number (avoid duplication)
|
||||
var paraText = GetParagraphText(para).TrimStart();
|
||||
if (!paraText.StartsWith(numStr, StringComparison.Ordinal))
|
||||
sb.Append($"<span class=\"heading-num\" style=\"margin-right:0.5em\">{HtmlEncode(numStr)}</span>");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue