Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class HtmlFormatterTests : FormatterTestBase
{
public class Objects : FormatterTestBase
{


[Fact]
public void Formatters_are_generated_on_the_fly_when_HTML_mime_type_is_requested()
{
Expand Down Expand Up @@ -71,7 +73,7 @@ public void Formatter_puts_div_with_class_around_string()

s.Should().Be($"{PlainTextBegin}hello{PlainTextEnd}");
}

[Fact]
public void Formatter_expands_properties_of_ExpandoObjects()
{
Expand Down Expand Up @@ -318,6 +320,7 @@ public void TimeSpan_is_not_destructured()

writer.ToString().Should().Contain(timespan.ToString());
}

}

public class PreformatPlainText : FormatterTestBase
Expand All @@ -342,6 +345,17 @@ is a
$"{PlainTextBegin}{instance.HtmlEncode()}{PlainTextEnd}");
}

[Fact]
public void HtmlFormatter_returns_plain_for_decimal()
{
var formatter = HtmlFormatter.GetPreferredFormatterFor<decimal>();

var d = 10.123m.ToDisplayString(formatter).RemoveStyleElement();

d.Should().Be($"{PlainTextBegin}10.123{PlainTextEnd}");
}


[Fact]
public void HtmlFormatter_returns_plain_for_BigInteger()
{
Expand Down
12 changes: 6 additions & 6 deletions src/Microsoft.DotNet.Interactive.Formatting/HtmlFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ type.Namespace is not null &&
return true;
}),

// // decimal should be displayed as plain text
// new HtmlFormatter<decimal>((value, context) =>
// {
// FormatAndStyleAsPlainText(value, context);
// return true;
// }),
// decimal should be displayed as plain text
new HtmlFormatter<decimal>((value, context) =>
{
FormatAndStyleAsPlainText(value, context);
return true;
}),

// Try to display object results as tables. This will return false for nested tables.
new HtmlFormatter<object>((value, context) =>
Expand Down