From 800fd8fb790f76e5eb48b9cc565b9c7239967d23 Mon Sep 17 00:00:00 2001 From: Dario Solera Date: Sat, 28 Nov 2009 15:15:09 +0000 Subject: [PATCH] Tentatively fixed #424: Phase3 special tags can now be used inside snippets. --- AssemblyVersion.cs | 4 ++-- Core/Formatter.cs | 26 ++++++++++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/AssemblyVersion.cs b/AssemblyVersion.cs index 3d3f31f..948dafb 100644 --- a/AssemblyVersion.cs +++ b/AssemblyVersion.cs @@ -16,5 +16,5 @@ using System.Reflection; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("3.0.1.438")] -[assembly: AssemblyFileVersion("3.0.1.438")] +[assembly: AssemblyVersion("3.0.1.439")] +[assembly: AssemblyFileVersion("3.0.1.439")] diff --git a/Core/Formatter.cs b/Core/Formatter.cs index b04fb6d..8693eb4 100644 --- a/Core/Formatter.cs +++ b/Core/Formatter.cs @@ -805,10 +805,17 @@ namespace ScrewTurn.Wiki { firstClosedAfterLastOpen = balanced.IndexOf("}", lastOpen + 1); if(firstClosedAfterLastOpen <= lastOpen) break; // Give up - + string internalSnippet = balanced.Substring(lastOpen, firstClosedAfterLastOpen - lastOpen + 1); balanced = balanced.Remove(lastOpen, firstClosedAfterLastOpen - lastOpen + 1); + // This check allows to ignore special tags (especially Phase3) + if(!internalSnippet.ToLowerInvariant().StartsWith("{s:")) { + internalSnippet = internalSnippet.Replace("{", "$$$$$$$$OPEN$$$$$$$$").Replace("}", "$$$$$$$$CLOSE$$$$$$$$"); + balanced = balanced.Insert(lastOpen, internalSnippet); + continue; + } + string formattedInternalSnippet = FormatSnippet(internalSnippet, tocString); string[] temp; formattedInternalSnippet = Format(formattedInternalSnippet, forIndexing, context, current, out temp, bareBones).Trim('\n'); @@ -817,7 +824,7 @@ namespace ScrewTurn.Wiki { balanced = balanced.Insert(lastOpen, formattedInternalSnippet); } while(lastOpen != -1); - sb.Insert(match.Index, balanced); + sb.Insert(match.Index, balanced.Replace("$$$$$$$$OPEN$$$$$$$$", "{").Replace("$$$$$$$$CLOSE$$$$$$$$", "}")); } } ComputeNoWiki(sb.ToString(), ref noWikiBegin, ref noWikiEnd); @@ -1316,13 +1323,16 @@ namespace ScrewTurn.Wiki { string bigString = sb.ToString(); do { + int dummy = bigString.IndexOf("{", tempIndex + 1); + if(dummy != -1) openCount++; tempIndex = bigString.IndexOf("}", tempIndex + 1); - if(tempIndex != -1) { - closeCount++; - if(closeCount == openCount) { - // Balanced - return bigString.Substring(index, tempIndex - index + 1); - } + if(tempIndex != -1) closeCount++; + + tempIndex = Math.Max(dummy, tempIndex); + + if(closeCount == openCount) { + // Balanced + return bigString.Substring(index, tempIndex - index + 1); } } while(tempIndex != -1 && tempIndex < bigString.Length - 1);