Skip to content

Commit

Permalink
Fix inline.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Sep 20, 2024
1 parent 16490ec commit 4938429
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
<RepositoryUrl>https://github.com/SebastianStehle/mjml-net.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>4.1.0</Version>
<Version>4.2.0</Version>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions Mjml.Net.PostProcessors/AngleSharpPostProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public sealed class AngleSharpPostProcessor : IPostProcessor, INestingPostProces
private static readonly IConfiguration HtmlConfiguration =
Configuration.Default
.WithCss()
.WithRenderDevice(new DefaultRenderDevice { FontSize = -1 })
.Without<ICssDefaultStyleSheetProvider>();

public static readonly IPostProcessor Default = new AngleSharpPostProcessor(new InlineCssPostProcessor(), new AttributesPostProcessor());
Expand Down
3 changes: 2 additions & 1 deletion Mjml.Net.PostProcessors/InlineCssPostProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AngleSharp;
using AngleSharp.Css;
using AngleSharp.Dom;

namespace Mjml.Net;
Expand Down Expand Up @@ -33,7 +34,7 @@ private static void Traverse(INode node, Action<IElement> action)

private static void InlineStyle(IElement element)
{
var currentStyle = element.ComputeCurrentStyle();
var currentStyle = element.Owner!.DefaultView.GetStyleCollection().GetDeclarations(element);

if (currentStyle.Any())
{
Expand Down
4 changes: 2 additions & 2 deletions Mjml.Net.PostProcessors/Mjml.Net.PostProcessors.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

<ItemGroup>
<PackageReference Include="AngleSharp" Version="1.1.2" />
<PackageReference Include="AngleSharp.Css" Version="1.0.0-beta.139" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.145">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -23,7 +22,8 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Mjml.Net.AngleSharp.Css" Version="1.0.1" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507" PrivateAssets="all" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions Mjml.Net/MjmlRenderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private void ReadElement(string name, IHtmlReader reader, IComponent? parent, st
Read(reader, component, file);
}

ValidatingClosingState(name, reader, file);
ValidatingClosingState(name, reader);

// If there is no parent, we handle the root and we can render everything top to bottom.
if (parent == null)
Expand Down Expand Up @@ -186,7 +186,7 @@ private void BindAndRender(IComponent component)
Cleanup();
}

private void ValidatingClosingState(string name, IHtmlReader reader, string? file)
private void ValidatingClosingState(string name, IHtmlReader reader)
{
// Only show one closing error, otherwise we could get one for every item in the hierarchy.
if (hasAddedClosingError)
Expand Down
2 changes: 1 addition & 1 deletion Tests/Components/Outputs/StyleInline.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<body>
<div>
<div class="red-text">
<div style="color: rgba(255, 0, 0, 1) !important; font-weight: bold;"></div>
<div style="color: rgba(255, 0, 0, 1) !important; font-weight: bold; font-size: 1.5rem"></div>
</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions Tests/Components/StyleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public async Task Should_render_inline()
<mj-style inline=""inline"">
.red-text div {
color: red !important;
font-size: 1.5rem;
}
</mj-style>
</mj-head>
Expand Down

0 comments on commit 4938429

Please sign in to comment.