public void SetUp()
        {
            string author = "tester-joebob";
            _lm = new LinkMaker("http://bogusville");
            FederationConfiguration configuration = new FederationConfiguration();
            AuthorizationRule rule = new AuthorizationRule(new AuthorizationRuleWho(AuthorizationRuleWhoType.GenericAll, null),
                AuthorizationRulePolarity.Allow, AuthorizationRuleScope.Wiki, SecurableAction.ManageNamespace, 0);
            configuration.AuthorizationRules.Add(new WikiAuthorizationRule(rule));
            MockWikiApplication application = new MockWikiApplication(
                configuration,
                _lm,
                OutputFormat.HTML,
                new MockTimeProvider(TimeSpan.FromSeconds(1)));
            Federation = new Federation(application);

            _versions = new ArrayList();
            _storeManager = WikiTestUtilities.CreateMockStore(Federation, "FlexWiki.Base");

            WikiTestUtilities.WriteTestTopicAndNewVersion(_storeManager, "TopicOne", @"1
            2
            3
            4
            5
            6
            7
            8
            9", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_storeManager, "TopicOne", @"1
            2
            a
            b
            c
            3
            4
            5
            6
            7
            8
            9", author);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_storeManager, "TopicOne", @"1
            2
            a
            b
            6
            7
            8
            9", author);

            foreach (TopicChange change in _storeManager.AllChangesForTopic("TopicOne"))
            {
                _versions.Add(change.Version);
            }
        }
Ejemplo n.º 2
0
        public override void Initialize(NamespaceManager storeManager)
        {
            _storeManager = storeManager;
            _connectionString = StoreManager.Parameters["Connection String"].Value;
            throw new NotImplementedException();

            //      SetFederation(aFed);
            //
            //      Namespace = ns;
            //
            //      _connectionString = connectionString;
            //
            //      _state = SqlStoreState.New;
            //      // Check if the namespace exists in the database
            //      // If does not exist then create the database.
            //      if( SqlNamespaceProvider.Exists(Namespace, ConnectionString) )
            //      {
            //        Read();
            //      }
            //      else
            //      {
            //        SqlHelper.CreateNamespace(Namespace, ConnectionString);
            //      }

        }
Ejemplo n.º 3
0
 /// <summary>
 /// Format a string of wiki content in a given OutputFormat with references all being relative to a given namespace
 /// </summary>
 /// <param name="topic">Topic context</param>
 /// <param name="input">The input wiki text</param>
 /// <param name="format">The desired output format</param>
 /// <param name="relativeToContentStore">References will be relative to this namespace</param>
 /// <param name="lm">Link maker (unless no relativeTo content base is provide)</param>
 /// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
 /// <returns></returns>
 public static string FormattedString(QualifiedTopicRevision topic, string input, OutputFormat format, NamespaceManager relativeToContentStore, LinkMaker lm)
 {
     // TODO -- some of the cases in which this call happens actually *are* nested, even though the false arg
     // below says that they aren't.  This causes scripts to be emitted multiple times -- should clean up.
     WikiOutput output = WikiOutput.ForFormat(format, null);
     ExternalReferencesMap ew;
     if (relativeToContentStore != null)
     {
         ew = relativeToContentStore.ExternalReferences;
     }
     else
     {
         ew = new ExternalReferencesMap();
     }
     Format(topic, input, output, relativeToContentStore, lm, ew, 0);
     return output.ToString();
 }
        public void SetUp()
        {
            string author = "tester-joebob";
            _lm = new LinkMaker("http://bogusville");
            MockWikiApplication application = new MockWikiApplication(
                null,
                _lm,
                OutputFormat.HTML,
                new MockTimeProvider(TimeSpan.FromSeconds(1)));
            Federation = new Federation(application);

            _versions = new ArrayList();
            _storeManager = WikiTestUtilities.CreateMockStore(Federation, "FlexWiki.Base");

            WikiTestUtilities.WriteTestTopicAndNewVersion(_storeManager, "TopicOne", @"1
            2
            3
            4
            5
            6
            7
            8
            9", author);
            System.Threading.Thread.Sleep(100); // need the newer one to be newer enough!
            WikiTestUtilities.WriteTestTopicAndNewVersion(_storeManager, "TopicOne", @"1
            2
            a
            b
            c
            3
            4
            5
            6
            7
            8
            9", author);
            System.Threading.Thread.Sleep(100); // need the newer one to be newer enough!
            WikiTestUtilities.WriteTestTopicAndNewVersion(_storeManager, "TopicOne", @"1
            2
            a
            b
            6
            7
            8
            9", author);

            foreach (TopicChange change in _storeManager.AllChangesForTopic("TopicOne"))
                _versions.Add(change.Version);
        }
Ejemplo n.º 5
0
        public override void Initialize(NamespaceManager namespaceManager)
        {
            base.Initialize(namespaceManager);

            bool connectionStringAbsent = false;
            if (!NamespaceManager.Parameters.Contains(ConfigurationParameterNames.ConnectionString))
            {
                connectionStringAbsent = true;
            }
            else if (string.IsNullOrEmpty(NamespaceManager.Parameters[ConfigurationParameterNames.ConnectionString].Value))
            {
                connectionStringAbsent = true;
            }

            if (connectionStringAbsent)
            {
                throw new FlexWikiException("SqlStore requires that the ConnectionString parameter be specified.");
            }

            _database.ConnectionString = NamespaceManager.Parameters[ConfigurationParameterNames.ConnectionString].Value;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Create a new formatter for an input list of StyledLines
 /// </summary>
 /// <param name="source">Input wiki content as a list of StyledLines</param>
 /// <param name="output">Output object to which output is sent</param>
 /// <param name="namespaceManager">The ContentProviderChain that contains the wiki string text</param>
 /// <param name="maker">A link maker </param>
 /// <param name="external">External wiki map</param>
 /// <param name="headingLevelBase">Relative heading level</param>
 /// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
 /// 
 Formatter(QualifiedTopicRevision topic, IList source, WikiOutput output, NamespaceManager namespaceManager,
     LinkMaker maker, ExternalReferencesMap external, int headingLevelBase)
 {
     _topic = topic;
     _source = source;
     _output = output;
     _linkMaker = maker;
     NamespaceManager = namespaceManager;
     _externalWikiMap = external;
     _headingLevelBase = headingLevelBase;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Register the given content store in the federation.
        /// </summary>
        public NamespaceManager RegisterNamespace(ContentProviderBase contentStore, string ns, 
            NamespaceProviderParameterCollection parameters)
        {
            // These are the default providers that every namespace gets. Later we might
            // want to make these configurable
            ContentProviderBase providerChain = new BuiltinTopicsProvider(contentStore); 
            providerChain = new ParsingProvider(providerChain);
            
            NamespaceManager namespaceManager = new NamespaceManager(this, providerChain, ns, parameters);
            _namespaceToNamespaceManagerMap[namespaceManager.Namespace] = namespaceManager;

            return namespaceManager;
        }
Ejemplo n.º 8
0
        public override void Initialize(NamespaceManager namespaceManager)
        {
            throw new NotImplementedException();

            //foreach (DateTime each in Dates)
            //{
            //    AbsoluteTopicName abs = TopicNameForDate(each);
            //    _Topics[abs] = each;
            //    _Topics[abs.LocalName] = each;
            //}

            //AbsoluteTopicName a = new AbsoluteTopicName("_NormalBorders", namespaceManager.Namespace);
            //BackingTopic top = new BackingTopic(a, DefaultNormalBordersContent, true);
            //BackingTopics[a.Name] = top;
            //_Topics[a] = DateTime.MinValue;
        }
Ejemplo n.º 9
0
        public override void Initialize(NamespaceManager namespaceManager)
        {
            base.Initialize(namespaceManager);

            if (!NamespaceManager.Parameters.Contains("Root"))
            {
                throw new FlexWikiException("Missing parameter 'Root' in namespace definition: " + Namespace);
            }

            _root = NamespaceManager.Parameters["Root"].Value;

            // Turn the root into an absolute path
            _root = NamespaceManager.Federation.Application.ResolveRelativePath(_root);

            // Create the directory if it doesn't already exist.
            _fileSystem.CreateDirectory(_root);
        }
Ejemplo n.º 10
0
    public TopicContext(Federation f, NamespaceManager namespaceManager, TopicVersionInfo topic)
		{
			CurrentFederation = f;
			CurrentNamespaceManager = namespaceManager;
			CurrentTopic = topic;
		}
Ejemplo n.º 11
0
        public override void Initialize(NamespaceManager namespaceManager)
        {
            base.Initialize(namespaceManager);

            _root = NamespaceManager.Parameters["root"].Value; 
        }
Ejemplo n.º 12
0
 private static ContentProviderBase ContentStore(NamespaceManager storeManager)
 {
     throw new NotImplementedException("Deprecated because the configuration checker winds up with too much internal knowledge of the content provider chain.");
 }
Ejemplo n.º 13
0
 public override void Initialize(NamespaceManager namespaceManager)
 {
     base.Initialize(namespaceManager);
     _connectionString = NamespaceManager.Parameters["Connection String"].Value;
 }
Ejemplo n.º 14
0
        private static IContentProvider ContentStore(NamespaceManager storeManager)
        {
            BuiltinTopicsProvider builtInTopicsProvider =
                (BuiltinTopicsProvider) storeManager.GetProvider(typeof(BuiltinTopicsProvider));
            IContentProvider provider = builtInTopicsProvider.Next;
            while (provider.Next != null)
            {
                provider = provider.Next;
            }

            return provider;
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Unregister the given NamespaceManager in the federation.
 /// </summary>
 /// <param name="namespaceManager"></param>
 public void UnregisterNamespace(NamespaceManager namespaceManager)
 {
     _namespaceToNamespaceManagerMap.Remove(namespaceManager.Namespace);
     RecordNamespacesListChanged();
 }
Ejemplo n.º 16
0
 public virtual void Initialize(NamespaceManager namespaceManager)
 {
     _namespaceManager = namespaceManager;
     if (_next != null)
     {
         _next.Initialize(namespaceManager);
     }
 }
Ejemplo n.º 17
0
        public string FormattedTopic(QualifiedTopicRevision topic, OutputFormat fmt)
        {
            //initial version does not handle diffs
            string wikitext = "";
            string interpreted = "";
            _mgr = _fed.NamespaceManagerForNamespace(topic.Namespace);
            _topic = topic;
            WomDocument.ResetTableOfContents();
            WomDocument.anchors = new string[25];
            _processBehaviorToText = true;
            _behaviorTopic = topic;

            //Normally get data from the cache, but when debugging Womdocument need to avoid using cached data
            string wom = _mgr.GetTopicProperty(topic.AsUnqualifiedTopicRevision(), "_Wom").LastValue;
            //string wom = "";

            if (!String.IsNullOrEmpty(wom))
            {
                WomDocument xmldoc = new WomDocument(null);
                wom = findWikiBehavior.Replace(wom, new MatchEvaluator(wikiBehaviorMatch));
                xmldoc.ParsedDocument = findWikiBehavior.Replace(wom, new MatchEvaluator(wikiBehaviorMatch));

                if (findIncludedTopic.IsMatch(xmldoc.ParsedDocument))
                {
                    string included = xmldoc.ParsedDocument;
                    included = findIncludedTopic.Replace(included, new MatchEvaluator(wikiIncludedTopic));
                    xmldoc.ParsedDocument = included;
                }

                interpreted = xmldoc.ParsedDocument;
                xmldoc = null;
            }
            else
            {
                using (TextReader sr = _mgr.TextReaderForTopic(topic.AsUnqualifiedTopicRevision()))
                {
                    wikitext = sr.ReadToEnd() + "\r\n";
                }
                wikitext = escape(wikitext);
                int size = 0;
                while (String.IsNullOrEmpty(interpreted))
                {
                    try
                    {
                        string tempsize = _mgr.GetTopicProperty(topic.AsUnqualifiedTopicRevision(), "_ProcessTextSize").LastValue;
                        Int32.TryParse(tempsize, out size);
                        if (size == 0)
                        {
                            size = _chunk;
                        }
                        WomDocument xmldoc = ProcessText(wikitext, topic, _mgr, false, size);
                        //string womdoc = xmldoc.ParsedDocument;
                        _mgr.SetWomCache(topic.AsUnqualifiedTopicRevision(), xmldoc.ParsedDocument);
                        //string firstPass = findWikiBehavior.Replace(womdoc, new MatchEvaluator(wikiBehaviorMatch));
                        //xmldoc.ParsedDocument = findWikiBehavior.Replace(firstPass, new MatchEvaluator(wikiBehaviorMatch));
                        while (findWikiBehavior.IsMatch(xmldoc.ParsedDocument))
                        {
                            xmldoc.ParsedDocument = findWikiBehavior.Replace(xmldoc.ParsedDocument, new MatchEvaluator(wikiBehaviorMatch));
                        }

                        _behaviorTopic = null;

                        if (findIncludedTopic.IsMatch(xmldoc.ParsedDocument))
                        {
                            string included = xmldoc.ParsedDocument;
                            included = findIncludedTopic.Replace(included, new MatchEvaluator(wikiIncludedTopic));
                            xmldoc.ParsedDocument = included;
                        }

                        interpreted = xmldoc.ParsedDocument;
                        xmldoc = null;
                    }
                    catch (XmlException ex)
                    {
                        _mgr.SetProcessTextSize(topic.AsUnqualifiedTopicRevision(), size * (chunkcnt + 1));
                        string error = ex.ToString();
                    }
                }
            }
            _processBehaviorToText = false;
            return interpreted;
        }
Ejemplo n.º 18
0
        public void Init()
        {
            _lm = new LinkMaker(_base);
            MockWikiApplication application = new MockWikiApplication(
                null,
                _lm,
                OutputFormat.HTML,
                new MockTimeProvider(TimeSpan.FromSeconds(1)));

            Federation = new Federation(application);
            Federation.WikiTalkVersion = 1;

            _namespaceManager = WikiTestUtilities.CreateMockStore(Federation, "FlexWiki");
            //_namespaceManager.Title  = "Friendly Title";

            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "HomePage", "Home is where the heart is", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "BigPolicy", "This is ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "BigDog", "This is ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "BigAddress", "This is ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "BigBox", "This is ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeOne", "inc1", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeTwo", "!inc2", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeThree", "!!inc3", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeFour", "!inc4", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeNest", @"		{{IncludeNest1}}
            {{IncludeNest2}}", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "TopicWithColor", "Color: Yellow", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeNest1", "!hey there", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeNest2", "!black dog", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "IncludeNestURI", @"wiki://IncludeNest1 wiki://IncludeNest2 ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "ResourceReference", @"URI: http://www.google.com/$$$", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "FlexWiki", "flex ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "InlineTestTopic", @"aaa @@""foo""@@ zzz", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "OneMinuteWiki", "one ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "TestIncludesBehaviors", "@@ProductName@@ somthing @@Now@@ then @@Now@@", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "_Underscore", "Underscore", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "TopicWithBehaviorProperties", @"
            Face: {""hello"".Length}
            one
            FaceWithArg: {arg | arg.Length }
            FaceSpanningLines:{ arg |

            arg.Length

            }

            ", user);
            WikiTestUtilities.WriteTestTopicAndNewVersion(_namespaceManager, "TestTopicWithBehaviorProperties", @"
            len=@@topics.TopicWithBehaviorProperties.Face@@
            lenWith=@@topics.TopicWithBehaviorProperties.FaceWithArg(""superb"")@@
            lenSpanning=@@topics.TopicWithBehaviorProperties.FaceSpanningLines(""parsing is wonderful"")@@
            ", user);

            _externals = new ExternalReferencesMap();
        }
Ejemplo n.º 19
0
        //this is where fragments are prepped for parsing
        public WomDocument FormatTextFragment(string wikiInput, QualifiedTopicRevision topic, NamespaceManager mgr, bool fragment, int sizeIn)
        {
            WomDocument xmldoc = new WomDocument(null);
            string wikitext = "";
            _mgr = mgr;
            _topic = topic;
            WomDocument.ResetTableOfContents();
            WomDocument.anchors = new string[25];
            _processBehaviorToText = true;
            _behaviorTopic = topic;

            wikitext = escape(wikiInput);
            int size = 0;
            bool done = false;
            while (!done)
            {
                try
                {
                    string tempsize = _mgr.GetTopicProperty(topic.AsUnqualifiedTopicRevision(), "_ProcessTextSize").LastValue;
                    Int32.TryParse(tempsize, out size);
                    if (size == 0)
                    {
                        size = sizeIn;
                    }
                    xmldoc = ProcessText(wikitext, topic, _mgr, fragment, size);
                    //string womdoc = xmldoc.ParsedDocument;
                    //string firstPass = findWikiBehavior.Replace(womdoc, new MatchEvaluator(wikiBehaviorMatch));
                    //xmldoc.ParsedDocument = findWikiBehavior.Replace(firstPass, new MatchEvaluator(wikiBehaviorMatch));
                    while (findWikiBehavior.IsMatch(xmldoc.ParsedDocument))
                    {
                        xmldoc.ParsedDocument = findWikiBehavior.Replace(xmldoc.ParsedDocument, new MatchEvaluator(wikiBehaviorMatch));
                    }

                    _behaviorTopic = null;

                    if (findIncludedTopic.IsMatch(xmldoc.ParsedDocument))
                    {
                        string included = xmldoc.ParsedDocument;
                        included = findIncludedTopic.Replace(included, new MatchEvaluator(wikiIncludedTopic));
                        xmldoc.ParsedDocument = included;
                    }
                    done = true;
                    //interpreted = xmldoc.ParsedDocument;
                    //xmldoc = null;
                }
                catch (XmlException ex)
                {
                    _mgr.SetProcessTextSize(topic.AsUnqualifiedTopicRevision(), size * (chunkcnt + 1));
                    string error = "<Error>" + ex.ToString() + "</Error>";
                    xmldoc.ParsedDocument = error;
                }
            }
            return xmldoc;
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Create a new formatter for a string of input content.
 /// </summary>
 /// <param name="source">Input wiki string</param>
 /// <param name="output">Output object to which output is sent</param>
 /// <param name="namespaceManager">The ContentProviderChain that contains the wiki string text</param>
 /// <param name="maker">A link maker </param>
 /// <param name="external">External wiki map</param>
 /// <param name="headingLevelBase">Relative heading level</param>
 /// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
 /// 
 Formatter(QualifiedTopicRevision topic, string source, WikiOutput output, NamespaceManager namespaceManager,
     LinkMaker maker, ExternalReferencesMap external, int headingLevelBase)
 {
     _topic = topic;
     _source = SplitStringIntoStyledLines(source, LineStyle.Unchanged);
     _linkMaker = maker;
     NamespaceManager = namespaceManager;
     _output = output;
     _externalWikiMap = external;
     _headingLevelBase = headingLevelBase;
 }
Ejemplo n.º 21
0
        //this is the main body where the real parsing work is done < 30 lines of code
        public WomDocument ProcessText(string wikiInput, QualifiedTopicRevision topic, NamespaceManager mgr, bool fragment, int size)
        {
            //_stopwatch = Stopwatch.StartNew();
            ParserContext savedcontext;
            bool redo = false;
            wikiInput = wikiInput.Replace("\r\n\r\n", "\r\n");
            if (!fragment)
            {
                wikiInput = "\r\n" + wikiInput;
            }
            else
            {
                while (wikiInput.EndsWith("\r\n"))
                {
                    wikiInput = wikiInput.Remove(wikiInput.LastIndexOf("\r\n"));
                }
            }
            _womDocument = new WomDocument(null);
            _womDocument.Fed = _fed;
            _womDocument.Mgr = mgr;
            _womDocument.FragmentOnly = fragment;
            _womDocument.Begin();

            int chunk = _chunk;  //set the initial chunk size (for cache use)
            if (size > 0)
            {
                chunk = size;
            }
            chunkcnt = 1;
            while (_context.ParentRule != null)
            {
                if (_context.ParentRule.ParentContext != null)
                {
                    _context = _context.ParentRule.ParentContext;
                }
            }
            if (!String.IsNullOrEmpty(wikiInput))
            {
                StringBuilder source = new StringBuilder();
                StringBuilder temp = new StringBuilder();
                source.AppendLine(externalWikiRef.Replace(wikiInput, new MatchEvaluator(externalWikiRefMatch)));
                temp.Append(multilinePre.Replace(source.ToString(), new MatchEvaluator(multilinePreMatch)));
                source = temp;
                string savedtemp = temp.ToString();
                MatchCollection matches;
                while (source.Length > 0)
                {
                    string womElement = _context.WomElement;
                    //optimize here by passing in less than the full string when source is very long
                    //this gives a 5 times performance improvement
                    int matchcnt = 0;

                    if (source.Length > chunk * chunkcnt)
                    {
                        matches = _context.RegExp.Matches(source.ToString(0, chunk * chunkcnt));
                        matchcnt = matches.Count;
                    }
                    else
                    {
                        matches = _context.RegExp.Matches(source.ToString());
                        matchcnt = matches.Count;
                    }
                    if (matchcnt > 0)
                    {
                        if (matches[0].Index > 0)
                        {
                            _womDocument.SimpleAdd(source.ToString(0, matches[0].Index), womElement, "", _context.RuleList[0]);
                        }
                        int x = 1;
                        if (_context.RegExpStr.StartsWith("(?:") && !matches[0].Value.StartsWith("%"))
                        {
                            x = 0;
                        }
                        int cnt = matches[0].Groups.Count;
                        for (int i = x; i < cnt; i++)
                        {
                            if (matches[0].Groups[i].Success)
                            {
                                if (womElement != "WikiText")
                                {
                                    //we are in a child rule set with an end condition
                                    //whereas WikiText ends by running out of source or matches
                                    if (i == 1)
                                    {
                                        i = 0;
                                    }
                                }
                                if (_womDocument.InTable && _womDocument.InItem && matches[0].Value.StartsWith("%"))
                                {
                                    i++;  //add one to the index here as we are in womText rules twice for this condition
                                }

                                ParserRule rule = _context.RuleList[i];
                                savedcontext = _context;
                                string addElement;
                                if (!String.IsNullOrEmpty(rule.WomElement))
                                {
                                    addElement = rule.WomElement;
                                }
                                else
                                {
                                    addElement = womElement;
                                }
                                _womDocument.SimpleAdd(matches[0].Value, addElement, rule.Jump, rule);
                                if (_womDocument.ParsedDocument.Contains("<<"))  //an error occurred
                                {
                                    chunkcnt++; //increase the chunk size and redo
                                    redo = true;
                                }
                                else
                                {
                                    if (addElement != "WikiStylingEnd")
                                    {
                                        _context = rule.Context;
                                    }
                                    //still in a line - only pop one context item
                                    else if (matches[0].Value == "%%" || matches[0].Value == "%" || matches[0].Value.Contains("{||"))
                                    {
                                        _context = _context.ParentRule.ParentContext;
                                    }
                                    else //done with that line - pop all context back to start
                                    {
                                        while (_context.ParentRule != null)
                                        {
                                            if (_context.ParentRule.ParentContext != null)
                                            {
                                                _context = _context.ParentRule.ParentContext;
                                            }
                                        }
                                    }
                                }
                                break;
                            }
                        }
                        if (!redo) //an error occurred
                        {
                            bool modifyRemove = false;

                            if (womElement == "womListText" && matches[0].Value.Contains("{||")) //need to leave this bit in source
                            {
                                modifyRemove = true;
                            }
                            else if (womElement == "womWikiStyledText" && matches[0].Value == "%")
                            {
                                modifyRemove = true;
                            }

                            if (modifyRemove)
                            {
                                source.Remove(0, matches[0].Index);
                            }
                            else
                            {
                                source.Remove(0, matches[0].Index + matches[0].Length);
                            }
                        }
                        else
                        {
                            //reset and start over with larger chunk
                            source = new StringBuilder();
                            source.Append(savedtemp);
                            _womDocument = new WomDocument(null);
                            _womDocument.Fed = _fed;
                            _womDocument.Mgr = mgr;
                            _womDocument.FragmentOnly = fragment;
                            _womDocument.Begin();
                            redo = false;
                            while (_context.ParentRule != null)
                            {
                                if (_context.ParentRule.ParentContext != null)
                                {
                                    _context = _context.ParentRule.ParentContext;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (source.Length > chunk * chunkcnt) //no match in that chunk, increase size and retry
                        {
                            source = new StringBuilder();
                            source.Append(savedtemp);
                            _womDocument = new WomDocument(null);
                            _womDocument.Fed = _fed;
                            _womDocument.Mgr = mgr;
                            _womDocument.FragmentOnly = fragment;
                            _womDocument.Begin();
                            chunkcnt++;
                            while (_context.ParentRule != null)
                            {
                                if (_context.ParentRule.ParentContext != null)
                                {
                                    _context = _context.ParentRule.ParentContext;
                                }
                            }
                        }
                        else
                        {
                            _womDocument.SimpleAdd(source.ToString(), womElement, "", _context.RuleList[0]);
                            source.Length = 0;
                        }
                    }
                }
                source = null;
                temp = null;
            }
            _womDocument.End();
            if (((bool)_fed.Application["DisableWikiEmoticons"] == false)) //&& (_mgr.DisableNamespaceEmoticons == false))
            {
                MatchCollection emoticonMatches = findEmoticon.Matches(_womDocument.ParsedDocument);
                if (emoticonMatches.Count > 0)
                {
                    _womDocument.ConvertEmoticons(emoticonMatches);
                }
            }
            //_stopwatch.Stop();
            if (chunkcnt > 1)
            {
                mgr.SetProcessTextSize(topic.AsUnqualifiedTopicRevision(), chunk * chunkcnt);
            }

            return _womDocument;
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Format a given input string to the given output
 /// </summary>pre
 /// <param name="source">Input wiki content as a list of StyledLines</param>
 /// <param name="output">Output object to which output is sent</param>
 /// <param name="namespaceManager">The ContentProviderChain that contains the wiki string text</param>
 /// <param name="maker">A link maker </param>
 /// <param name="external">External wiki map</param>
 /// <param name="headingLevelBase">Relative heading level</param>
 /// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
 /// 
 public static void Format(QualifiedTopicRevision topic, IList source, WikiOutput output,
     NamespaceManager namespaceManager, LinkMaker maker, ExternalReferencesMap external, int headingLevelBase)
 {
     Formatter f = new Formatter(topic, source, output, namespaceManager, maker, external, headingLevelBase);
     f.Format();
 }
Ejemplo n.º 23
0
 public IWikiToPresentation WikiToPresentation(QualifiedTopicRevision topic, WikiOutput output,
     NamespaceManager namespaceManager, LinkMaker maker, ExternalReferencesMap external, int headingLevelBase, bool fragment)
 {
     //ArrayList lines = new ArrayList();
     //lines.Add(new StyledLine("", LineStyle.Unchanged));
     //return new Formatter(topic, lines, output, namespaceManager, maker, external, headingLevelBase);
     WomDocument doc = (WomDocument)output;
     doc.Mgr = namespaceManager;
     doc.Fed = _fed;
     doc.FragmentOnly = fragment;
     output.Begin();
     return this;
 }
Ejemplo n.º 24
0
 public static IWikiToPresentation WikiToPresentation(QualifiedTopicRevision topic, WikiOutput output,
     NamespaceManager namespaceManager, LinkMaker maker, ExternalReferencesMap external, int headingLevelBase)
 {
     ArrayList lines = new ArrayList();
     lines.Add(new StyledLine("", LineStyle.Unchanged));
     return new Formatter(topic, lines, output, namespaceManager, maker, external, headingLevelBase);
 }
 public virtual void Initialize(NamespaceManager manager)
 {
     Next.Initialize(manager);
 }