Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
softlion committed Jan 18, 2024
1 parent 3faf094 commit ce5da7d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions NotionSharp.ApiClient/Lib/HtmlRendering/HtmlRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,16 @@ protected virtual void TransformCode(Block block, StringBuilder sb)

sb.Append("""<div class="notion-code-block" />""");

sb.Append("""<div class="notion-code-caption" />""");
Append(code.Caption, sb);
sb.Append("""</div>""");

sb.Append($"""<div class="notion-code language-{code.Language}" />""");
sb.Append($"""<code class="language-{code.Language}" />""");
Append(code.RichText, sb);
sb.AppendLine("</div>");
sb.AppendLine("</code>");

if (code.Caption?.Count > 0)
{
sb.Append("""<div class="notion-code-caption" />""");
Append(code.Caption, sb);
sb.Append("""</div>""");
}

sb.AppendLine("</div>");
}
Expand Down
2 changes: 1 addition & 1 deletion NotionSharp.ApiClient/Lib/PublicApi/Model/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public record BlockTextAndChildrenAndColor(List<Block> Children, List<RichText>
{
public NotionColor Color { get; init; }
}
public record BlockCode(string Language, List<RichText> Caption, List<RichText> RichText) : BlockText(RichText);
public record BlockCode(string Language, List<RichText>? Caption, List<RichText> RichText) : BlockText(RichText);


public record BlockChildPage(string Title);
Expand Down
2 changes: 1 addition & 1 deletion NotionSharp.ApiClient/NotionSharp.ApiClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PropertyGroup>
<!-- nuget configurable properties -->
<Version>2.0.1</Version>
<VersionSuffix>-pre1</VersionSuffix>
<VersionSuffix>-pre2</VersionSuffix>
<DefineConstants>$(DefineConstants);</DefineConstants>
</PropertyGroup>

Expand Down

0 comments on commit ce5da7d

Please sign in to comment.