Skip to content

Commit

Permalink
improve markdown text formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidVollmers committed May 23, 2024
1 parent 347a7be commit 82b45cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Doki.Output.Markdown/Elements/Text.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ protected string GetText()
{
if (IsEmpty) return string.Empty;
var escaped = _builder.ToString().Replace("<", "&lt;").Replace(">", "&gt;");
return IsBold ? $"**{escaped}**" : escaped;
return IsBold ? $"**{escaped.Trim()}**" : escaped;
}
}
10 changes: 6 additions & 4 deletions src/Doki.Output.Markdown/InternalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,27 @@ public static Text BuildText(this MarkdownBuilder builder, DocumentationObject o
switch (content)
{
case TextContent textContent:
if (textContent.Text != "." && textContent.Text != "?" && textContent.Text != "!" &&
textContent.Text != "," && textContent.Text != ":" && textContent.Text != ";")
text.Space();
text.Append(textContent.Text);
text.Space();
break;
case Link link:
text.Append(new Elements.Link(link.Text, link.Url));
text.Space();
text.Append(new Elements.Link(link.Text, link.Url));
break;
case CodeBlock codeBlock:
text.NewLine();
text.Append(new Code(codeBlock.Code, Lang: codeBlock.Language));
text.NewLine();
break;
case TypeDocumentationReference typeDocumentationReference:
text.Append(builder.BuildLinkTo(typeDocumentationReference));
text.Space();
text.Append(builder.BuildLinkTo(typeDocumentationReference));
break;
case MemberDocumentation memberDocumentation:
text.Append(builder.BuildLinkTo(memberDocumentation));
text.Space();
text.Append(builder.BuildLinkTo(memberDocumentation));
break;
default:
throw new NotSupportedException(
Expand Down

0 comments on commit 82b45cb

Please sign in to comment.