dotnet / docfx

Static site generator for .NET API documentation.
https://dotnet.github.io/docfx/
MIT License
4.09k stars 867 forks source link

[Bug] Doc comment's `<code>` block is not correctly rendered when another tags exists before `<code`> tag #10385

Open filzrev opened 1 week ago

filzrev commented 1 week ago

Describe the bug

When <para></para> tag exists before <code> tag, Rendered HTML results is corrupted.

Example documentation comment

/// <remarks>
/// <para>
/// Dummy paragraph.
/// </para>
/// <code lang="cs">
/// public sealed class Sample
/// {
///     public int AAA {get;set;}
///
///     public int BBB {get;set;}
///
///     public int CCC {get;set;}
/// }
/// </code>
/// </remarks>
public class Sample
{
    public int Dummy { get; set; }
}

Rendered Image Image

To Reproduce

  1. Set documentation comment described above.
  2. Run docfx metadata command
  3. Run docfx build --serve command
  4. Confirm API page for Sample class

Expected behavior <code></code> blocks are rendered as expected.

Additional context To resolve this issue. It need to add extra new line before <pre> tag. That is required when embedding HTML tags on markdown text.

See https://github.com/xoofx/markdig/issues/472#issuecomment-683787240 for details