Skip to content

Commit 88c5b5c

Browse files
committed
Added method for clearing indents in TextRendererBase as well as added case handling to PopIndent()
1 parent d1233ff commit 88c5b5c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Markdig/Renderers/TextRendererBase.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) Alexandre Mutel. All rights reserved.
2-
// This file is licensed under the BSD-Clause 2 license.
2+
// This file is licensed under the BSD-Clause 2 license.
33
// See the license.txt file in the project root for more information.
44

55
using System.Diagnostics.CodeAnalysis;
@@ -174,10 +174,12 @@ public void PushIndent(string[] lineSpecific)
174174

175175
public void PopIndent()
176176
{
177-
// TODO: Check
178-
indents.RemoveAt(indents.Count - 1);
177+
if (this.indents.Count > 0)
178+
indents.RemoveAt(indents.Count - 1);
179179
}
180180

181+
public void ClearIndent() => indents.Clear();
182+
181183
[MethodImpl(MethodImplOptions.AggressiveInlining)]
182184
private protected void WriteIndent()
183185
{
@@ -220,12 +222,12 @@ public T Write(string? content)
220222
[MethodImpl(MethodImplOptions.AggressiveInlining)]
221223
internal T Write(char c, int count)
222224
{
223-
WriteIndent();
224-
225+
WriteIndent();
226+
225227
for (int i = 0; i < count; i++)
226228
{
227229
Writer.Write(c);
228-
}
230+
}
229231

230232
return (T)this;
231233
}

0 commit comments

Comments
 (0)