diff --git a/src/Markdig.Tests/RoundtripSpecs/Roundtrip.md b/src/Markdig.Tests/RoundtripSpecs/Roundtrip.md index 8305b0eb..9398a858 100644 --- a/src/Markdig.Tests/RoundtripSpecs/Roundtrip.md +++ b/src/Markdig.Tests/RoundtripSpecs/Roundtrip.md @@ -38,8 +38,8 @@ In order: - ~~check char.IsNewline() calls~~ - ~~introduce feature flag~~ - ~~extract MarkdownRenderer~~ -- cleanup NormalizeRenderer (MarkdownRenderer) -- deduplicate MarkdownRenderer and NormalizeRenderer code +- ~~cleanup NormalizeRenderer (MarkdownRenderer)~~ +- ~~deduplicate MarkdownRenderer and NormalizeRenderer code~~ - do pull request feedback - split HeadingBlock into AtxHeadingBlock and SetextHeadingBlock? - fix broken pre-existing tests diff --git a/src/Markdig/Renderers/Normalize/CodeBlockRenderer.cs b/src/Markdig/Renderers/Normalize/CodeBlockRenderer.cs index c9cb2613..811b440d 100644 --- a/src/Markdig/Renderers/Normalize/CodeBlockRenderer.cs +++ b/src/Markdig/Renderers/Normalize/CodeBlockRenderer.cs @@ -3,6 +3,7 @@ // See the license.txt file in the project root for more information. using Markdig.Syntax; +using System; namespace Markdig.Renderers.Normalize { @@ -18,7 +19,8 @@ namespace Markdig.Renderers.Normalize { if (obj is FencedCodeBlock fencedCodeBlock) { - var opening = new string(fencedCodeBlock.FencedChar, fencedCodeBlock.FencedCharCount); + var fencedCharCount = Math.Min(fencedCodeBlock.OpeningFencedCharCount, fencedCodeBlock.ClosingFencedCharCount); + var opening = new string(fencedCodeBlock.FencedChar, fencedCharCount); renderer.Write(opening); if (fencedCodeBlock.Info != null) { diff --git a/src/Markdig/Renderers/Roundtrip/ListRenderer.cs b/src/Markdig/Renderers/Roundtrip/ListRenderer.cs index 70f87d38..360866a7 100644 --- a/src/Markdig/Renderers/Roundtrip/ListRenderer.cs +++ b/src/Markdig/Renderers/Roundtrip/ListRenderer.cs @@ -17,8 +17,6 @@ namespace Markdig.Renderers.Roundtrip protected override void Write(RoundtripRenderer renderer, ListBlock listBlock) { renderer.RenderLinesBefore(listBlock); - var compact = renderer.CompactParagraph; - renderer.CompactParagraph = !listBlock.IsLoose; if (listBlock.IsOrdered) { int index = 0; @@ -89,8 +87,6 @@ namespace Markdig.Renderers.Roundtrip renderer.RenderLinesAfter(listItem); } } - renderer.CompactParagraph = compact; - renderer.RenderLinesAfter(listBlock); } diff --git a/src/Markdig/Renderers/Roundtrip/RoundtripRenderer.cs b/src/Markdig/Renderers/Roundtrip/RoundtripRenderer.cs index 952a882d..12b73296 100644 --- a/src/Markdig/Renderers/Roundtrip/RoundtripRenderer.cs +++ b/src/Markdig/Renderers/Roundtrip/RoundtripRenderer.cs @@ -44,68 +44,6 @@ namespace Markdig.Renderers.Roundtrip ObjectRenderers.Add(new LiteralInlineRenderer()); } - public bool CompactParagraph { get; set; } - - ///// - ///// Writes the attached on the specified . - ///// - ///// The object. - ///// - //public NormalizeRenderer WriteAttributes(MarkdownObject obj) - //{ - // if (obj == null) throw new ArgumentNullException(nameof(obj)); - // return WriteAttributes(obj.TryGetAttributes()); - //} - - ///// - ///// Writes the specified . - ///// - ///// The attributes to render. - ///// This instance - //public NormalizeRenderer WriteAttributes(HtmlAttributes attributes) - //{ - // if (attributes == null) - // { - // return this; - // } - - // if (attributes.Id != null) - // { - // Write(" id=\"").WriteEscape(attributes.Id).Write("\""); - // } - - // if (attributes.Classes != null && attributes.Classes.Count > 0) - // { - // Write(" class=\""); - // for (int i = 0; i < attributes.Classes.Count; i++) - // { - // var cssClass = attributes.Classes[i]; - // if (i > 0) - // { - // Write(" "); - // } - // WriteEscape(cssClass); - // } - // Write("\""); - // } - - // if (attributes.Properties != null && attributes.Properties.Count > 0) - // { - // foreach (var property in attributes.Properties) - // { - // Write(" ").Write(property.Key); - // if (property.Value != null) - // { - // Write("=").Write("\""); - // WriteEscape(property.Value); - // Write("\""); - // } - // } - // } - - // return this; - //} - /// /// Writes the lines of a ///