Skip to content

Commit 7e963ff

Browse files
authored
Merge pull request #186 from galyni/check-empty-text
fix: PhrasingElementExpression.cs - check empty string in text element
2 parents 5c6bfe2 + b5d3935 commit 7e963ff

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Html2OpenXml/Expressions/PhrasingElementExpression.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) Olivier Nizet https://github.com/onizet/html2openxml - All Rights Reserved
1+
/* Copyright (C) Olivier Nizet https://github.com/onizet/html2openxml - All Rights Reserved
22
*
33
* This source is subject to the Microsoft Permissive License.
44
* Please see the License.txt file for more information.
@@ -208,7 +208,7 @@ protected static IEnumerable<OpenXmlElement> CombineRuns(IEnumerable<OpenXmlElem
208208
// run can be also a hyperlink
209209
textElement ??= run.GetFirstChild<Run>()?.GetFirstChild<Text>();
210210

211-
if (textElement != null) // could be null when <br/>
211+
if (textElement != null && !string.IsNullOrEmpty(textElement.Text)) // could be null when <br/>
212212
{
213213
var text = textElement.Text;
214214
// we know that the text cannot be empty because we skip them in TextExpression
@@ -225,4 +225,4 @@ protected static IEnumerable<OpenXmlElement> CombineRuns(IEnumerable<OpenXmlElem
225225
yield return run;
226226
}
227227
}
228-
}
228+
}

0 commit comments

Comments
 (0)