WikiFunctions.Parse.HideText.AddBackMore C# (CSharp) Метод

AddBackMore() публичный Метод

Adds back hidden stuff from HideMore
public AddBackMore ( string articleText ) : string
articleText string
Результат string
        public string AddBackMore(string articleText)
        {
            // performance: return cached value if no changes made to articleText
            if (cachedArticleTextAfterHideMore.Equals(articleText))
            {
                articleText = cachedOriginalArticleTextBeforeHideMore;

                // clear down
                cachedOriginalArticleTextBeforeHideMore = "";
                cachedArticleTextAfterHideMore = "";
            }
            else
            {
                // while loop as there can be nested hiding
                while (HiddenMoreRegex.IsMatch(articleText))
                    articleText = HiddenMoreRegex.Replace(articleText, m => MoreHide[int.Parse(m.Groups[1].Value)].Text);
            }

            MoreHide.Clear();
            return articleText;
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Checks that the bold just added to the article is the first bold in the article, and that it's within the first 5% of the HideMore article OR immediately after the infobox
        /// </summary>
        private bool AddedBoldIsValid(string articleText, string escapedTitle)
        {
            HideText Hider2         = new HideText(true, true, true);
            Regex    RegexBoldAdded = new Regex(@"^(.*?)'''(" + escapedTitle + @")", RegexOptions.Singleline | RegexOptions.IgnoreCase);

            int boldAddedPos = RegexBoldAdded.Match(articleText).Groups[2].Index;

            int firstBoldPos = RegexFirstBold.Match(articleText).Length;

            articleText = WikiRegexes.NestedTemplates.Replace(articleText, "");

            articleText = Hider2.HideMore(articleText);

            // was bold added in first 5% of article?
            bool inFirst5Percent = false;

            int articlelength = articleText.Length;

            if (articlelength > 5)
            {
                inFirst5Percent = articleText.Trim().Substring(0, Math.Max(articlelength / 20, 5)).Contains("'''");
            }

            articleText = Hider2.AddBackMore(articleText);
            // check that the bold added is the first bit in bold in the main body of the article, and in first 5% of HideMore article
            return(inFirst5Percent && boldAddedPos <= firstBoldPos);
        }
All Usage Examples Of WikiFunctions.Parse.HideText::AddBackMore