Skip to content

Commit

Permalink
Fixed missing semicolon separator AngleSharp#135
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Jun 14, 2023
1 parent b9aef4c commit 6905fa5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Released on tbd.
- Updated to use AngleSharp 1.0
- Fixed issue when updating shorthands with invalid values (#129)
- Fixed issue with appended EOF character in `CssText` (#123)
- Fixed missing semicolon in `@page` rule (#135)

# 0.17.0

Expand Down
32 changes: 32 additions & 0 deletions src/AngleSharp.Css.Tests/Rules/CssPageRule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace AngleSharp.Css.Tests.Rules
{
using AngleSharp.Css.Dom;
using NUnit.Framework;
using System.Linq;

[TestFixture]
public class CssPageRuleTests
{
[Test]
public void SemiColonsShouldNotMissInPageRule_Issue135()
{
var html = "<html><body><style>@page { margin-top: 25mm; margin-right: 25mm }</style></body></html>";
var document = html.ToHtmlDocument(Configuration.Default.WithCss());
var styleSheet = document.StyleSheets.OfType<ICssStyleSheet>().First();
var css = styleSheet.ToCss();

Assert.AreEqual("@page { margin-top: 25mm; margin-right: 25mm }", css);
}

[Test]
public void PageRuleShouldRecombineShorthandDeclaration_Issue135()
{
var html = "<html><body><style>@page { margin: 25mm }</style></body></html>";
var document = html.ToHtmlDocument(Configuration.Default.WithCss());
var styleSheet = document.StyleSheets.OfType<ICssStyleSheet>().First();
var css = styleSheet.ToCss();

Assert.AreEqual("@page { margin: 25mm }", css);
}
}
}
2 changes: 1 addition & 1 deletion src/AngleSharp.Css/Dom/Internal/Rules/CssPageRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected override void ReplaceWith(ICssRule rule)

public override void ToCss(TextWriter writer, IStyleFormatter formatter)
{
var rules = formatter.BlockRules(_style);
var rules = _style.ToCssBlock(formatter);
writer.Write(formatter.Rule(RuleNames.Page, SelectorText, rules));
}

Expand Down

0 comments on commit 6905fa5

Please sign in to comment.