Skip to content

[WIP] [Bug] List in remark is not rendered correctly #10676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
20 changes: 15 additions & 5 deletions src/Docfx.Dotnet/Parsers/XmlComment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -586,13 +586,23 @@ private static string TrimEachLine(string text, string indent = "")

private static string GetInnerXmlAsMarkdown(string xml)
{
if (!xml.Contains('&'))
return xml;

xml = HandleBlockQuote(xml);
var pipeline = new MarkdownPipelineBuilder().UseMathematics().EnableTrackTrivia().Build();

// Configure the Markdown pipeline to properly handle lists
var pipeline = new MarkdownPipelineBuilder()
.UseMathematics()
.EnableTrackTrivia()
.Configure(extensions: "advanced-tasklists-noindentcodeblock") // Disable indented code blocks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought, It should not disable indented code blocks feature here.

Th root cause of problem is <list> tag contents are handled as Markdown document.
Markdown specification require Empty Line when mixing markdown/HTML tags.

So, It need to add logics to insert empty line before/after <list> tags.

.Build();

var markdown = Markdown.Parse(xml, pipeline);
MarkdownXmlDecode(markdown);

// Only process XML entities if they exist in the content
if (xml.Contains('&'))
{
MarkdownXmlDecode(markdown);
}

var sw = new StringWriter();
var rr = new RoundtripRenderer(sw);
rr.ObjectRenderers.Add(new MathInlineRenderer());
Expand Down
36 changes: 36 additions & 0 deletions test/Docfx.Dotnet.Tests/XmlCommentUnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,42 @@ public sealed class Issue10385
""", comment.Remarks, ignoreLineEndingDifferences: true);
}

[Fact]
public void Issue10559()
{
var comment = XmlComment.Parse(
"""
<remarks>
<para>Test para</para>

Test start list
<list type="bullet">
<item>
<description>Item 1.</description>
</item>
<item>
<description>Item 2.</description>
</item>
</list>
Test end list

</remarks>
""");
Assert.Equal(
"""
<p>Test para</p>

Test start list
<ul><li>
Item 1.
</li><li>
Item 2.
</li></ul>
Test end list

""", comment.Remarks, ignoreLineEndingDifferences: true);
}



}