Skip to content

Commit

Permalink
Merge pull request #2 from marknn3/add-target-netstandard20
Browse files Browse the repository at this point in the history
Add Target Framework netstandard2.0
  • Loading branch information
morincer authored Nov 23, 2023
2 parents 9e4b708 + aa6ec06 commit bfbb902
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="2.15.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.18.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/Markdig.Renderers.Docx/DocxDocumentRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void ForceCloseParagraph()
}
}

public override DocxDocumentRenderer Render(MarkdownObject markdownObject)
public override object Render(MarkdownObject markdownObject)
{
if (markdownObject is MarkdownDocument)
{
Expand Down
9 changes: 5 additions & 4 deletions src/Markdig.Renderers.Docx/Markdig.Renderers.Docx.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<LangVersion>Latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand All @@ -20,8 +21,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="2.15.0" />
<PackageReference Include="Markdig" Version="0.27.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.18.0" />
<PackageReference Include="Markdig" Version="0.33.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
</ItemGroup>

Expand Down
34 changes: 34 additions & 0 deletions src/Markdig.Renderers.Docx/Polyfills/NetStandard20Polyfills.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace Markdig.Renderers.Docx;

internal static class NetStandard20Polyfills
{
public static TValue GetValueOrDefault<TKey, TValue>(
this IReadOnlyDictionary<TKey, TValue> target,
TKey key,
TValue defaultValue = default!)
{
if (target.TryGetValue(key, out var result))
{
return result!;
}

return defaultValue;
}

public static bool TryPeek<T>(this Stack<T> stack, out T result)
{
if (stack.Count == 0)
{
result = default!;
return false;
}

result = stack.Peek();
return true;
}

public static string[] Split(this string str, string separator, StringSplitOptions options = StringSplitOptions.None)
{
return str.Split(separator.ToCharArray(), options);
}
}

0 comments on commit bfbb902

Please sign in to comment.