Skip to content

Commit

Permalink
Merge pull request #13 from ZonerZoner/master
Browse files Browse the repository at this point in the history
Allow font-size with unit rem
  • Loading branch information
sergey-tihon committed May 2, 2020
2 parents d764a02 + 926982e commit 50a0731
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 2 deletions.
2 changes: 2 additions & 0 deletions OpenXmlPowerTools.Tests/HtmlToWmlConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ public class HwTests
[InlineData("T1830.html")]
[InlineData("T1840.html")]
[InlineData("T1850.html")]
[InlineData("T1860.html")]
[InlineData("T1870.html")]

public void HW001(string name)
{
Expand Down
4 changes: 2 additions & 2 deletions OpenXmlPowerTools/HtmlToWmlConverterCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2829,9 +2829,9 @@ private static XElement[] GetSpacingProperties(XElement paragraph, HtmlToWmlConv
// todo should check based on display property
bool numItem = paragraph.Name == XhtmlNoNamespace.li;

if (numItem && marginTopProperty.IsAuto)
if (numItem && marginTopProperty != null && marginTopProperty.IsAuto)
beforeAutospacing = "1";
if (numItem && marginBottomProperty.IsAuto)
if (numItem && marginBottomProperty != null && marginBottomProperty.IsAuto)
afterAutospacing = "1";
if (marginTopProperty != null && marginTopProperty.IsNotAuto)
{
Expand Down
8 changes: 8 additions & 0 deletions OpenXmlPowerTools/HtmlToWmlCssApplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,10 @@ public static CssExpression GetInheritedOrInitializedValue(Dictionary<string, Cs
throw new OpenXmlPowerToolsException("Internal error");
newPtSize = (unit == CssUnit.EM) ? decFontSize * decValue : decFontSize * decValue / 2;
}
else if (unit == CssUnit.REM)
{
newPtSize = settings.DefaultFontSize * decValue;
}
else
{
if (unit == null && decValue == 0d)
Expand Down Expand Up @@ -1516,6 +1520,10 @@ private static CssExpression ComputeAbsoluteFontSize(XElement element, CssExpres
if (unit == CssUnit.Percent)
newPtSize = ptSize * decValue / 100d;
}
else if (unit == CssUnit.REM)
{
newPtSize = settings.DefaultFontSize * decValue;
}
else
{
if (unit == CssUnit.IN)
Expand Down
30 changes: 30 additions & 0 deletions TestFiles/T1860.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<meta charset="UTF-8"/>

<style>
ol {
list-style-type: none;
margin: 0;
padding: 0;
}

ol > li {
display: table;
counter-increment: item;
margin-bottom: 0.6em;
}

</style>

<body>

<section >
<ol>
<li>
<span >Description</span>
</li>
</ol>
</section>
</body>
</html>
16 changes: 16 additions & 0 deletions TestFiles/T1870.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<meta charset="UTF-8"/>
<style>

h2 {
margin-top: 2rem;
}

</style>

<body>
<h1>Test1</h1>
<h2>Test2</h2>
</body>
</html>

0 comments on commit 50a0731

Please sign in to comment.