From dfa5e04288cb15dd4a1a2338bbf1d3b86d4edd95 Mon Sep 17 00:00:00 2001
From: CRxTRDude )", RegexOptions.Multiline);
+ Regex paragraphEnd = new Regex(@"( tag. When it does,
+ // We turn on the paragraphBuilder to append the remaining lines.
+
+ // If the checks hit a line with the )", RegexOptions.Multiline);
- Regex paragraphEnd = new Regex(@"( tag. When it does,
- // We turn on the paragraphBuilder to append the remaining lines.
-
- // If the checks hit a line with the into tag. When it does,
+ // We turn on the paragraphBuilder to append the remaining lines.
+
+ // If the checks hit a line with the "))
+ {
+ isNewLine = 1;
+ }
+ else if (line.Contains("
" tags only if the current line and the next line are starting
- // with the opening/closing list tags. By doing this, it can prevent removing
- // line breaks that are intentionally added by the user.
- if (Regex.IsMatch(line, pattern) && Regex.IsMatch(nextLine, pattern))
+ // We first incrementally check if the line begins with
tags and then adding it to the builder variable
+ // where it is assembled with the rest of the file.
+
+ // Note, this is unoptimized code and will still need work.
+ if (paragraphBegin.IsMatch(line))
+ {
+ isNewLine = true;
+ }
+ else if (paragraphEnd.IsMatch(line))
+ {
+ isNewLine = false;
+ }
+
+ if (isNewLine)
{
- while (line.EndsWith("
"))
+ paragraphBuilder.AppendLine(line);
+
+ if (paragraphEnd.IsMatch(line))
{
- line = line.Substring(0, line.LastIndexOf("
"));
+ builder.AppendLine(line);
+ paragraphBuilder.Clear();
+ isNewLine = false;
}
}
+ else
+ {
+ paragraphBuilder.AppendLine(line);
+
+ newLineString = paragraphBuilder.ToString();
+ newLineString = Regex.Replace(newLineString, @"^([\w\*\>\<\[][^\r\n]*)(?=\r?\n[\w\*\>\<\[].*$)", "$1
", RegexOptions.Multiline);
- builder.AppendLine(line);
+ builder.AppendLine(newLineString);
+ paragraphBuilder.Clear();
+ }
}
builder.AppendLine(lines.Last());
- return builder.ToString();
+ strippedOver = Regex.Replace(builder.ToString(), @"^(\r\s)", string.Empty, RegexOptions.Multiline);
+
+ return strippedOver;
}
///
tags and then adding it to the builder variable
- // where it is assembled with the rest of the file.
-
- // Note, this is unoptimized code and will still need work.
- if (paragraphBegin.IsMatch(line))
- {
- isNewLine = true;
- }
- else if (paragraphEnd.IsMatch(line))
- {
- isNewLine = false;
- }
-
- if (isNewLine)
- {
- paragraphBuilder.AppendLine(line);
-
- if (paragraphEnd.IsMatch(line))
- {
- builder.AppendLine(line);
- paragraphBuilder.Clear();
- isNewLine = false;
- }
- }
- else
- {
- paragraphBuilder.AppendLine(line);
-
- newLineString = paragraphBuilder.ToString();
- newLineString = Regex.Replace(newLineString, @"^([\w\*\>\<\[][^\r\n]*)(?=\r?\n[\w\*\>\<\[].*$)", "$1
", RegexOptions.Multiline);
-
- builder.AppendLine(newLineString);
- paragraphBuilder.Clear();
- }
- }
-
- builder.AppendLine(lines.Last());
-
- strippedOver = Regex.Replace(builder.ToString(), @"^(\r\s)", string.Empty, RegexOptions.Multiline);
+ PostMarkdownParser.PostMarkdown(Markdown.Transform(initialString)));
- return strippedOver;
+ this.webBrowser.DocumentText = formattedString;
}
///
+ // which is used in almost all implementations of
+ // Markdown, even in the original Markdown specs.
+ formattedString = Regex.Replace(formattedString, @"
", RegexOptions.Multiline);
+
+ System.Text.StringBuilder builder = new System.Text.StringBuilder();
+ System.Text.StringBuilder paragraphBuilder = new System.Text.StringBuilder();
+
+ var isNewLine = 0;
+
+ string newLineString;
+ string strippedOverString;
+
+ var lines = formattedString.Split(
+ new string[] { "\r\n", "\n" },
+ StringSplitOptions.None);
+
+ for (int i = 0; i < lines.Length - 1; ++i)
+ {
+ string line = lines[i];
+
+ // We first incrementally check if the line begins with ", "", RegexOptions.Multiline);
+ formattedString = Regex.Replace(formattedString, @"
tags and then adding it to builder
+ // where it is assembled with the rest of the file.
+
+ // We dump the text to builder if it hits a tag.
+ if (line.Contains(""))
+ {
+ isNewLine = -1;
+ }
+
+ if (isNewLine == 1)
+ {
+ paragraphBuilder.AppendLine(line);
+
+ if (line.Contains("
(~~)", "
", RegexOptions.Multiline);
+ newLineString = Regex.Replace(newLineString, @"(~~)
tagged text, just skip check and append to builder + builder.AppendLine(line); + } + } + + builder.AppendLine(lines.Last()); + strippedOverString = Regex.Replace(builder.ToString(), @"^(\r\s)", string.Empty, RegexOptions.Multiline); + + return strippedOverString; + } + } +} From 5853c587a9dfed57d2e7f08197f5e88cdb8aa4fb Mon Sep 17 00:00:00 2001 From: crxtrdudeDate: Tue, 24 Nov 2015 16:54:39 +0800 Subject: [PATCH 3/6] Additional MarkdownDeep fixes ... - Improved PostMarkdown function as suggested by @yyoon. - Reverted screwed up csproj files due to Nuget Package Recovery. - Modified docType string to use HTML5 DOCTYPE standard. - Minor fixes. --- Journaley.Core/Journaley.Core.csproj | 2 - Journaley/Forms/MainForm.cs | 4 +- Journaley/Journaley.csproj | 2 - Journaley/Utilities/PostMarkdownParser.cs | 49 ++++++++++------------- VersionExtractor/VersionExtractor.csproj | 4 -- 5 files changed, 24 insertions(+), 37 deletions(-) diff --git a/Journaley.Core/Journaley.Core.csproj b/Journaley.Core/Journaley.Core.csproj index 89d791e..9ce425a 100644 --- a/Journaley.Core/Journaley.Core.csproj +++ b/Journaley.Core/Journaley.Core.csproj @@ -97,9 +97,7 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - \n{1}\n\n{2}\n\n{3}\n\n\n\n \n{4}\n\n\n", + "{0}\n\n\n\n\n{4}\n\n", docType, this.GetWebBrowserTypefaceCSS(), this.GetWebBrowserSizeCSS(), diff --git a/Journaley/Journaley.csproj b/Journaley/Journaley.csproj index 2d1e6d1..a62ff28 100644 --- a/Journaley/Journaley.csproj +++ b/Journaley/Journaley.csproj @@ -501,12 +501,10 @@This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - "$(SolutionDir)InsertIcons.exe" "$(TargetPath)" "$(ProjectDir)Images\NewEntry.ico"