diff --git a/src/Markdig/Renderers/TextRendererBase.cs b/src/Markdig/Renderers/TextRendererBase.cs index 4d428a77..cb2b0da1 100644 --- a/src/Markdig/Renderers/TextRendererBase.cs +++ b/src/Markdig/Renderers/TextRendererBase.cs @@ -1,5 +1,5 @@ // Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. +// This file is licensed under the BSD-Clause 2 license. // See the license.txt file in the project root for more information. using System.Diagnostics.CodeAnalysis; @@ -174,10 +174,14 @@ public abstract class TextRendererBase : TextRendererBase where T : TextRende public void PopIndent() { - // TODO: Check - indents.RemoveAt(indents.Count - 1); + if (this.indents.Count > 0) + indents.RemoveAt(indents.Count - 1); + else + throw new InvalidOperationException("No indent to pop"); } + public void ClearIndent() => indents.Clear(); + [MethodImpl(MethodImplOptions.AggressiveInlining)] private protected void WriteIndent() { @@ -220,12 +224,12 @@ public abstract class TextRendererBase : TextRendererBase where T : TextRende [MethodImpl(MethodImplOptions.AggressiveInlining)] internal T Write(char c, int count) { - WriteIndent(); - + WriteIndent(); + for (int i = 0; i < count; i++) { Writer.Write(c); - } + } return (T)this; }