Skip to content

Commit

Permalink
fix:修复@if标签移除的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
wangx036 committed Oct 30, 2024
1 parent a27b211 commit b37b543
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/MiniWord/MiniWord.Implment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -779,15 +779,17 @@ private static void ReplaceIfStatements(OpenXmlElement rootXmlElement, List<Open

for (int i = paragraphIfIndex + 1; i <= paragraphEndIfIndex - 1; i++)
{
if(rootXmlElement.ChildElements.Any(c=>c == elementList[i])) rootXmlElement.RemoveChild(elementList[i]);
elementList[i].Remove();
}
}
if(rootXmlElement.ChildElements.Any(c => c == ifP))
rootXmlElement.RemoveChild(ifP);
if (rootXmlElement.ChildElements.Any(c => c == endIfP))
rootXmlElement.RemoveChild(endIfP);
// 从paragraphs中移除,防止死循环
paragraphs.Remove(ifP);
paragraphs.Remove(endIfP);
// 从doc元素移除
if (ifP.Parent != null)
ifP.Remove();
if (endIfP.Parent != null)
endIfP.Remove();
}
}

Expand Down

0 comments on commit b37b543

Please sign in to comment.