Skip to content

Commit fa615f4

Browse files
committed
Fixed counter issue #58
1 parent 1acc2a5 commit fa615f4

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/AngleSharp.Css.Tests/Declarations/CssContentProperty.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace AngleSharp.Css.Tests.Declarations
1+
namespace AngleSharp.Css.Tests.Declarations
22
{
33
using AngleSharp.Css.Dom;
44
using NUnit.Framework;
@@ -38,5 +38,13 @@ public void CssContentParseStringWithSingleQuoteMultipleEscapes()
3838
var parsed = ParseStyle(source);
3939
Assert.AreEqual("\"abc''d'ef\"", parsed.Style.GetContent());
4040
}
41+
42+
[Test]
43+
public void CssContentWithCounter_Issue58()
44+
{
45+
var source = "a{content: counter(h1) \".\\00A0\"}";
46+
var parsed = ParseStyle(source);
47+
Assert.AreEqual("counter(h1) \"\"", parsed.Style.GetContent());
48+
}
4149
}
4250
}

src/AngleSharp.Css/Values/Primitives/CounterDefinition.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ public CounterDefinition(String identifier, String listStyle, String separator)
3838
/// <summary>
3939
/// Gets the CSS text representation.
4040
/// </summary>
41-
public String CssText => String.Concat(_identifier, " ", _listStyle, " ", _separator);
41+
public String CssText => _separator == null ?
42+
FunctionNames.Counter.CssFunction(Combine(_identifier)) :
43+
FunctionNames.Counters.CssFunction(Combine(String.Concat(_identifier, " ", _separator)));
4244

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

8890
#endregion
91+
92+
#region Helpers
93+
94+
private String Combine(String head) => _listStyle != CssKeywords.Decimal ? String.Concat(head, ", ", _listStyle) : head;
95+
96+
#endregion
8997
}
9098
}

0 commit comments

Comments
 (0)