public List <string> GenerateNewDebianChangelogEntry(string[] markdownLines)
        {
            string mdText = string.Join(Environment.NewLine, markdownLines);
            bool   isKeepAChangelogFormat = CreateReleaseNotesHtml.RemoveKeepAChangelogHeadIfPresent(ref mdText);

            markdownLines = mdText.Split(new [] { Environment.NewLine }, StringSplitOptions.None);

            if (isKeepAChangelogFormat)
            {
                markdownLines = ConvertKACSectionsToBullets(markdownLines);
            }

            var newEntryLines = new List <string>
            {
                // Write out the first line as the changelog version line
                $"{PackageName} ({VersionNumber}) {Distribution}; urgency={Urgency}",
                string.Empty
            };
            // Skip a beginning blank line after the version header, if present.
            // (Not to be confused with a Keep a Changelog heading, that would have been removed earlier.)
            int contentStartingLineAfterVersionHeader = 1;

            if (string.IsNullOrWhiteSpace(markdownLines[1]))
            {
                contentStartingLineAfterVersionHeader = 2;
            }
            for (var i = contentStartingLineAfterVersionHeader; i < markdownLines.Length; ++i)
            {
                if (markdownLines[i].StartsWith("##"))
                {
                    break;
                }
                ConvertMarkdownLineToChangelogLine(markdownLines[i], newEntryLines);
            }
            if (newEntryLines[newEntryLines.Count - 1] != string.Empty)
            {
                // End body with a blank line, if not already.
                newEntryLines.Add(string.Empty);
            }
            // The debian changelog needs RFC 2822 format (Thu, 15 Oct 2015 08:25:16 -0500), which is not quite what .NET can provide
            var debianDate = CreateChangelogEntry.DebianDate(EntryDate);

            newEntryLines.Add($" -- {MaintainerInfo}  {debianDate}");
            newEntryLines.Add(string.Empty);
            return(newEntryLines);
        }
        public override bool Execute()
        {
            if (!File.Exists(ChangelogFile))
            {
                Log.LogError($"The given markdown file ({ChangelogFile}) does not exist.");
                return(false);
            }

            var markDownTransformer = new Markdown();

            try
            {
                string inputMarkdown = File.ReadAllText(ChangelogFile);
                CreateReleaseNotesHtml.RemoveKeepAChangelogHeadIfPresent(ref inputMarkdown);
                // MarkdownDeep appears to use \n for newlines. Rather than mix those with platform line-endings, just
                // convert them to platform line-endings if needed.
                var markdownHtml = markDownTransformer.Transform(inputMarkdown).Replace("\n", Environment.NewLine);
                if (File.Exists(HtmlFile))
                {
                    var htmlDoc             = XDocument.Load(HtmlFile);
                    var releaseNotesElement = htmlDoc.XPathSelectElement("//*[@class='releasenotes']");
                    if (releaseNotesElement == null)
                    {
                        return(true);
                    }

                    releaseNotesElement.RemoveNodes();
                    var mdDocument = XDocument.Parse($"<div>{markdownHtml}</div>");
                    // ReSharper disable once PossibleNullReferenceException - Will either throw or work
                    releaseNotesElement.Add(mdDocument.Root.Elements());
                    htmlDoc.Save(HtmlFile);
                }
                else
                {
                    WriteBasicHtmlFromMarkdown(markdownHtml);
                }
                return(true);
            }
            catch (Exception e)
            {
                Log.LogErrorFromException(e, true);
                return(false);
            }
        }