Fixed #382: positional parameters whose vlaue contains markup are not rendered correctly in snippets (the equal sign generated by a link, for example, confused the formatter).

This commit is contained in:
Dario Solera 2009-10-14 08:10:16 +00:00
parent 12dbdda9fe
commit 695e715c06
2 changed files with 5 additions and 3 deletions

View file

@ -16,5 +16,5 @@ using System.Reflection;
// //
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("3.0.1.400")] [assembly: AssemblyVersion("3.0.1.401")]
[assembly: AssemblyFileVersion("3.0.1.400")] [assembly: AssemblyFileVersion("3.0.1.401")]

View file

@ -48,6 +48,7 @@ namespace ScrewTurn.Wiki {
private static readonly Regex HRRegex = new Regex(@"(?<=(\n|^))(\ )*----(\ )*\n", RegexOptions.Compiled); private static readonly Regex HRRegex = new Regex(@"(?<=(\n|^))(\ )*----(\ )*\n", RegexOptions.Compiled);
//private static readonly Regex SnippetRegex = new Regex(@"\{S(\:|\|)(.+?)(\|(.+?))*}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); //private static readonly Regex SnippetRegex = new Regex(@"\{S(\:|\|)(.+?)(\|(.+?))*}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
private static readonly Regex SnippetRegex = new Regex(@"\{s\:(.+?)(\|.*?)*\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Singleline); private static readonly Regex SnippetRegex = new Regex(@"\{s\:(.+?)(\|.*?)*\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Singleline);
private static readonly Regex ClassicSnippetVerifier = new Regex(@"\|\ ?[a-z0-9]+\ ?\=", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex TableRegex = new Regex(@"\{\|(\ [^\n]*)?\n.+?\|\}", RegexOptions.Compiled | RegexOptions.Singleline); private static readonly Regex TableRegex = new Regex(@"\{\|(\ [^\n]*)?\n.+?\|\}", RegexOptions.Compiled | RegexOptions.Singleline);
private static readonly Regex IndentRegex = new Regex(@"(?<=(\n|^))\:+(\ )?.+?\n", RegexOptions.Compiled); private static readonly Regex IndentRegex = new Regex(@"(?<=(\n|^))\:+(\ )?.+?\n", RegexOptions.Compiled);
private static readonly Regex EscRegex = new Regex(@"\<esc\>(.|\n|\r)*?\<\/esc\>", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Singleline); private static readonly Regex EscRegex = new Regex(@"\<esc\>(.|\n|\r)*?\<\/esc\>", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Singleline);
@ -1296,7 +1297,8 @@ namespace ScrewTurn.Wiki {
/// <returns>The formatted result.</returns> /// <returns>The formatted result.</returns>
private static string FormatSnippet(string capturedMarkup, string cachedToc) { private static string FormatSnippet(string capturedMarkup, string cachedToc) {
// If the markup does not contain equal signs, process it using the classic method, assuming there are only positional parameters // If the markup does not contain equal signs, process it using the classic method, assuming there are only positional parameters
if(capturedMarkup.IndexOf("=") == -1) { //if(capturedMarkup.IndexOf("=") == -1) {
if(!ClassicSnippetVerifier.IsMatch(capturedMarkup)) {
string tempRes = FormatClassicSnippet(capturedMarkup); string tempRes = FormatClassicSnippet(capturedMarkup);
return ReplaceToc(tempRes, cachedToc); return ReplaceToc(tempRes, cachedToc);
} }