mirror of
https://github.com/xoofx/markdig.git
synced 2026-11-16 09:20:40 +00:00
cleanup RoundtripRenderer
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -44,68 +44,6 @@ namespace Markdig.Renderers.Roundtrip
|
||||
ObjectRenderers.Add(new LiteralInlineRenderer());
|
||||
}
|
||||
|
||||
public bool CompactParagraph { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// Writes the attached <see cref="HtmlAttributes"/> on the specified <see cref="MarkdownObject"/>.
|
||||
///// </summary>
|
||||
///// <param name="obj">The object.</param>
|
||||
///// <returns></returns>
|
||||
//public NormalizeRenderer WriteAttributes(MarkdownObject obj)
|
||||
//{
|
||||
// if (obj == null) throw new ArgumentNullException(nameof(obj));
|
||||
// return WriteAttributes(obj.TryGetAttributes());
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Writes the specified <see cref="HtmlAttributes"/>.
|
||||
///// </summary>
|
||||
///// <param name="attributes">The attributes to render.</param>
|
||||
///// <returns>This instance</returns>
|
||||
//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;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the lines of a <see cref="LeafBlock"/>
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user