From 0267d3ffe454d1a01265b4b7a6f5bc1062ca9995 Mon Sep 17 00:00:00 2001 From: Frans Bouma Date: Mon, 22 Feb 2016 12:35:09 +0100 Subject: [PATCH] Included fix from sibling Fork https://github.com/kuchikios/markdowndeep/commit/9473a8fee4e524daea2b777a2129533cbfc8954b --- src/MarkdownDeep/MardownDeep.cs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/MarkdownDeep/MardownDeep.cs b/src/MarkdownDeep/MardownDeep.cs index d74c70b..97b80c8 100644 --- a/src/MarkdownDeep/MardownDeep.cs +++ b/src/MarkdownDeep/MardownDeep.cs @@ -189,22 +189,23 @@ namespace MarkdownDeep string strReturnLink = string.Format("", (string)fn.Data); // Get the last child of the footnote - var child = fn.Children[fn.Children.Count - 1]; - if (child.BlockType == BlockType.p) + if(fn.Children.Count > 0) { - child.BlockType = BlockType.p_footnote; - child.Data = strReturnLink; + var child = fn.Children[fn.Children.Count - 1]; + if(child.BlockType == BlockType.p) + { + child.BlockType = BlockType.p_footnote; + child.Data = strReturnLink; + } + else + { + child = CreateBlock(); + child.ContentLen = 0; + child.BlockType = BlockType.p_footnote; + child.Data = strReturnLink; + fn.Children.Add(child); + } } - else - { - child = CreateBlock(); - child.ContentLen = 0; - child.BlockType = BlockType.p_footnote; - child.Data = strReturnLink; - fn.Children.Add(child); - } - - fn.Render(this, sb); sb.Append("\n");