Skip to content

Commit

Permalink
Fixed counter issue #58
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Jun 11, 2020
1 parent 1acc2a5 commit fa615f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/AngleSharp.Css.Tests/Declarations/CssContentProperty.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AngleSharp.Css.Tests.Declarations
namespace AngleSharp.Css.Tests.Declarations
{
using AngleSharp.Css.Dom;
using NUnit.Framework;
Expand Down Expand Up @@ -38,5 +38,13 @@ public void CssContentParseStringWithSingleQuoteMultipleEscapes()
var parsed = ParseStyle(source);
Assert.AreEqual("\"abc''d'ef\"", parsed.Style.GetContent());
}

[Test]
public void CssContentWithCounter_Issue58()
{
var source = "a{content: counter(h1) \".\\00A0\"}";
var parsed = ParseStyle(source);
Assert.AreEqual("counter(h1) \"\"", parsed.Style.GetContent());
}
}
}
10 changes: 9 additions & 1 deletion src/AngleSharp.Css/Values/Primitives/CounterDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public CounterDefinition(String identifier, String listStyle, String separator)
/// <summary>
/// Gets the CSS text representation.
/// </summary>
public String CssText => String.Concat(_identifier, " ", _listStyle, " ", _separator);
public String CssText => _separator == null ?
FunctionNames.Counter.CssFunction(Combine(_identifier)) :
FunctionNames.Counters.CssFunction(Combine(String.Concat(_identifier, " ", _separator)));

/// <summary>
/// Gets the identifier of the counter.
Expand Down Expand Up @@ -86,5 +88,11 @@ public override Boolean Equals(Object obj) =>
public override Int32 GetHashCode() => CssText.GetHashCode();

#endregion

#region Helpers

private String Combine(String head) => _listStyle != CssKeywords.Decimal ? String.Concat(head, ", ", _listStyle) : head;

#endregion
}
}

0 comments on commit fa615f4

Please sign in to comment.