当前位置: 首页>>代码示例>>C#>>正文


C# Parse.HideText类代码示例

本文整理汇总了C#中WikiFunctions.Parse.HideText的典型用法代码示例。如果您正苦于以下问题:C# HideText类的具体用法?C# HideText怎么用?C# HideText使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HideText类属于WikiFunctions.Parse命名空间,在下文中一共展示了HideText类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HideMore

 private string HideMore(string text, bool hideOnlyTargetOfWikilink)
 {
     Hider = new HideText();
     string s = Hider.HideMore(text, hideOnlyTargetOfWikilink);
     Assert.AreEqual(text, Hider.AddBackMore(s));
     return s;
 }
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:7,代码来源:MiscellaneousTests.cs

示例2: Hide

 private string Hide(string text, bool hideExternalLinks, bool leaveMetaHeadings, bool hideImages)
 {
     Hider = new HideText(hideExternalLinks, leaveMetaHeadings, hideImages);
     string s = Hider.Hide(text);
     Assert.AreEqual(text, Hider.AddBack(s));
     return s;
 }
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:7,代码来源:MiscellaneousTests.cs

示例3: HideMore

 private string HideMore(string text, bool hideExternalLinks, bool leaveMetaHeadings, bool hideImages)
 {
     Hider = new HideText(hideExternalLinks, leaveMetaHeadings, hideImages);
     return Hider.HideMore(text);
 }
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:5,代码来源:MiscellaneousTests.cs

示例4: AddedBoldIsValid

        /// <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;
        }
开发者ID:svn2github,项目名称:awb,代码行数:28,代码来源:BoldTitle.cs

示例5: HideImages

        public void HideImages()
        {
            AssertAllHidden(@"[[File:foo.jpg]]");
            AssertAllHidden(@"[[File:foo with space and 0004.jpg]]");
            AssertAllHidden(@"[[File:foo.jpeg]]");
            AssertAllHidden(@"[[File:foo.JPEG]]");
            AssertAllHidden(@"[[Image:foo with space and 0004.jpeg]]");
            AssertAllHidden(@"[[Image:foo.jpeg]]");
            AssertAllHidden(@"[[Image:foo with space and 0004.jpg]]");
            AssertAllHidden(@"[[File:foo.jpg|");
            AssertAllHidden(@"[[File:foo with space and 0004.jpg|");
            AssertAllHidden(@"[[File:foo.jpeg|");
            AssertAllHidden(@"[[Image:foo with space and 0004.jpeg|");
            AssertAllHidden(@"[[Image:foo.jpeg|");
            AssertAllHidden(@"[[Image:foo with SPACE() and 0004.jpg|");
            AssertAllHidden(@"[[File:foo.gif|");
            AssertAllHidden(@"[[Image:foo with space and 0004.gif|");
            AssertAllHidden(@"[[Image:foo.gif|");
            AssertAllHidden(@"[[Image:foo with SPACE() and 0004.gif|");
            AssertAllHidden(@"[[File:foo.png|");
            AssertAllHidden(@"[[Image:foo with space and 0004.png|");
            AssertAllHidden(@"[[Image:foo_here.png|");
            AssertAllHidden(@"[[Image:foo with SPACE() and 0004.png|");
            AssertAllHidden(@"[[Image:westminster.tube.station.jubilee.arp.jpg|");

            AssertAllHidden(@"<imagemap>
            File:Blogs001.jpeg|Description
            File:Blogs002.jpeg|Description
            </imagemap>");

            AssertBothHidden(@"[[File:foo.jpg]]");
            AssertBothHidden(@"[[Image:foo with space and 0004.png|");
            AssertBothHidden(@"[[Image:foo_here.png|");

            Assert.IsFalse(HideMore(@"[[Category:Foo|abc]]", false).Contains("abc"), "Category sort key always hidden if hiding wikilinks and not leaving target");
            Assert.IsFalse(HideMore(@"[[Category:Foo|abc]]", true).Contains("abc"), "Category sort key hidden even if keeping targets");

            HideText h = new HideText(true, false, false);
            Assert.IsTrue(h.HideMore(@"[[Category:Foo|abc]]", false, false).Contains("abc"), "Category sort key kept if keeping wikilinks");
        }
开发者ID:svn2github,项目名称:awb,代码行数:40,代码来源:MiscellaneousTests.cs

示例6: AssertBothHidden

 private void AssertBothHidden(string text, bool hideExternalLinks, bool leaveMetaHeadings, bool hideImages)
 {
     Hider = new HideText(hideExternalLinks, leaveMetaHeadings, hideImages);
     AssertAllHidden(text);
     AssertAllHiddenMore(text);
 }
开发者ID:svn2github,项目名称:awb,代码行数:6,代码来源:MiscellaneousTests.cs

示例7: PerformUniversalGeneralFixes

 public void PerformUniversalGeneralFixes()
 {
     HideText H = new HideText();
     MockSkipOptions S = new MockSkipOptions();
     Article ar1 = new Article("Hello", " '''Hello''' world text");
     ar1.PerformUniversalGeneralFixes();
     ar1.PerformGeneralFixes(parser, H, S, false, false, false);
     Assert.AreEqual("'''Hello''' world text", ar1.ArticleText);
 }
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:9,代码来源:GenfixesTests.cs

示例8: FixDates

        // Covered by: LinkTests.FixDates()
        /// <summary>
        /// Fix date and decade formatting errors.
        /// </summary>
        /// <param name="ArticleText">The wiki text of the article.</param>
        /// <returns>The modified article text.</returns>
        public string FixDates(string ArticleText)
        {
            HideText hidetext = new HideText();
            ArticleText = hidetext.HideMore(ArticleText);
            {
                ArticleText = FixDatesRaw(ArticleText);

                //Remove 2 or more <br />'s
                //This piece's existance here is counter-intuitive, but it requires HideMore()
                //and I don't want to call this slow function yet another time --MaxSem
                ArticleText = SyntaxRemoveBr.Replace(ArticleText, "\r\n");
                ArticleText = SyntaxRemoveParagraphs.Replace(ArticleText, "\r\n\r\n");

            }
            ArticleText = hidetext.AddBackMore(ArticleText);
            return ArticleText;
        }
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:23,代码来源:Parsers.cs

示例9: Tagger


//.........这里部分代码省略.........
            // nl wiki doesn't use {{Uncategorized}} template
            // prevent wictionary redirects from being tagged as uncategorised
            if (words > 6 && totalCategories == 0
                && !WikiRegexes.Uncat.IsMatch(articleText)
                && Variables.LangCode != "nl"
                && !Tools.NestedTemplateRegex("cat improve").IsMatch(articleText)
                // category count is from API; don't add uncat tag if genfixes added person categories
                && !WikiRegexes.DeathsOrLivingCategory.IsMatch(articleText)
                && !WikiRegexes.BirthsCategory.IsMatch(articleText))
            {
                if (WikiRegexes.Stub.IsMatch(commentsStripped))
                {
                    // add uncategorized stub tag
                    articleText += Tools.Newline("{{Uncategorized stub|", 2) + WikiRegexes.DateYearMonthParameter +
                        @"}}";
                    tagsAdded.Add("[[CAT:UNCATSTUBS|uncategorised]]");
                }
                else
                {
                    // add uncategorized tag
                    articleText += Tools.Newline("{{Uncategorized|", 2) + WikiRegexes.DateYearMonthParameter + @"}}";
                    tagsAdded.Add("[[CAT:UNCAT|uncategorised]]");
                }
            }

            // remove {{Uncategorized}} if > 0 real categories (stub categories not counted)
            // rename {{Uncategorized}} to {{Uncategorized stub}} if stub with zero categories (stub categories not counted)
            if (WikiRegexes.Uncat.IsMatch(articleText))
            {
                if (totalCategories > 0)
                {
                    articleText = WikiRegexes.Uncat.Replace(articleText, "");
                    tagsRemoved.Add("uncategorised");
                }
                else if (totalCategories == 0 && WikiRegexes.Stub.IsMatch(commentsStripped))
                {
                    string uncatname = WikiRegexes.Uncat.Match(articleText).Groups[1].Value;
                    if (!uncatname.Contains("stub"))
                        articleText = Tools.RenameTemplate(articleText, uncatname, "Uncategorized stub");
                }
            }

            if (linkCount == 0 && !WikiRegexes.DeadEnd.IsMatch(articleText) && Variables.LangCode != "sv"
                && !Regex.IsMatch(WikiRegexes.MultipleIssues.Match(articleText).Value.ToLower(), @"\bdead ?end\b"))
            {
                // add dead-end tag
                articleText = "{{dead end|" + WikiRegexes.DateYearMonthParameter + "}}\r\n\r\n" + articleText;
                tagsAdded.Add("[[:Category:Dead-end pages|deadend]]");
            }

            if (linkCount < 3 && underlinked && !WikiRegexes.Wikify.IsMatch(articleText)
                && !WikiRegexes.MultipleIssues.Match(articleText).Value.ToLower().Contains("wikify"))
            {
                // add wikify tag
                articleText = "{{Wikify|" + WikiRegexes.DateYearMonthParameter + "}}\r\n\r\n" + articleText;
                tagsAdded.Add("[[WP:WFY|wikify]]");
            }
            else if (linkCount > 3 && !underlinked &&
                     WikiRegexes.Wikify.IsMatch(articleText))
            {
                articleText = WikiRegexes.Wikify.Replace(articleText, new MatchEvaluator(SectionTagME));
                
                if(!WikiRegexes.Wikify.IsMatch(articleText))
                    tagsRemoved.Add("wikify");
            }

            // rename unreferenced --> refimprove if has existing refs
            if (WikiRegexes.Unreferenced.IsMatch(commentsCategoriesStripped)
                && WikiRegexes.Refs.Matches(commentsCategoriesStripped).Count > 0)
            {
                articleText = Tools.RenameTemplate(articleText, "unreferenced", "refimprove", true);
                
                Match m = WikiRegexes.MultipleIssues.Match(articleText);
                if(m.Success)
                {
                    string newValue = Tools.RenameTemplateParameter(m.Value,  "unreferenced", "refimprove");
                    if(!newValue.Equals(m.Value))
                        articleText = articleText.Replace(m.Value, newValue);
                }
            }

            if (tagsAdded.Count > 0 || tagsRemoved.Count > 0)
            {
                Parsers p = new Parsers();
                HideText ht = new HideText();

                articleText = ht.HideUnformatted(articleText);

                articleText = p.MultipleIssues(articleText);
                articleText = Conversions(articleText);
                articleText = ht.AddBackUnformatted(articleText);

                // sort again in case tag removal requires whitespace cleanup
                articleText = p.Sorter.Sort(articleText, articleTitle);
            }

            summary = PrepareTaggerEditSummary();

            return articleText;
        }
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:101,代码来源:Parsers.cs

示例10: Interwikis

        /// <summary>
        /// Extracts all of the interwiki and interwiki featured article links from the article text
        /// Ignores interwikis in comments/nowiki tags
        /// </summary>
        /// <param name="articleText">Article text with interwiki and interwiki featured article links removed</param>
        /// <returns>string of interwiki and interwiki featured article links</returns>
        public string Interwikis(ref string articleText)
        {
            string interWikiComment = "";
            if (InterLangRegex.IsMatch(articleText))
            {
                interWikiComment = InterLangRegex.Match(articleText).Value;
                articleText = articleText.Replace(interWikiComment, "");
            }
            
            // http://en.wikipedia.org/wiki/Wikipedia_talk:AutoWikiBrowser/Bugs/Archive_12#Interwiki_links_moved_out_of_comment
            HideText hider = new HideText(false, true, false);

            articleText = hider.Hide(articleText);

            string interWikis = ListToString(RemoveLinkFGAs(ref articleText));
            
            if(interWikiComment.Length > 0)
                interWikis += interWikiComment + "\r\n";
            
            interWikis += ListToString(RemoveInterWikis(ref articleText));

            articleText = hider.AddBack(articleText);
            
            return interWikis;
        }
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:31,代码来源:MetaDataSorter.cs

示例11: Tagger


//.........这里部分代码省略.........
                        articleText = Tools.NestedTemplateRegex("underlinked").Replace(articleText, "").TrimStart();
                        tagsRemoved.Add("underlinked");
                    }
                }
            }
            // add wikify tag, don't add underlinked/wikify if {{dead end}} already present
            // Dont' tag SIA pages, may create wikilinks from templates
            else if (wikiLinkCount < 3 && underlinked && !WikiRegexes.Wikify.IsMatch(articleText)
                     && !WikiRegexes.MultipleIssues.Match(articleText).Value.ToLower().Contains("wikify")
                     && !WikiRegexes.DeadEnd.IsMatch(articleText)
                     && !WikiRegexes.SIAs.IsMatch(articleText))
            {
                // Avoid excess newlines between templates
                string templateEnd = "}}\r\n" + (articleText.StartsWith(@"{{") ? "" : "\r\n");
                
                if (Variables.LangCode.Equals("ar"))
                {
                    articleText = "{{ويكي|" + WikiRegexes.DateYearMonthParameter + templateEnd + articleText;
                    tagsAdded.Add("[[وب:ويكي|ويكي]]");
                }
                else if (Variables.LangCode.Equals("arz"))
                {
                    articleText = "{{ويكى|" + WikiRegexes.DateYearMonthParameter + templateEnd + articleText;
                    tagsAdded.Add("[[قالب:ويكى|ويكى]]");
                }
                else if (Variables.LangCode.Equals("sv"))
                {
                    articleText = "{{Wikify|" + WikiRegexes.DateYearMonthParameter + templateEnd + articleText;
                    tagsAdded.Add("[[WP:WFY|wikify]]");
                }
                else
                {
                    articleText = "{{Underlinked|" + WikiRegexes.DateYearMonthParameter + templateEnd + articleText;
                    tagsAdded.Add("[[CAT:UL|underlinked]]");
                }
            }
            else if (wikiLinkCount > 3 && !underlinked &&
                     WikiRegexes.Wikify.IsMatch(articleText))
            {
                if (Variables.LangCode.Equals("ar") || Variables.LangCode.Equals("arz"))
                    articleText = WikiRegexes.Wikify.Replace(articleText, "");
                else
                    // remove wikify, except section templates or wikify tags with reason parameter specified
                    articleText = WikiRegexes.Wikify.Replace(articleText, m => Tools.IsSectionOrReasonTemplate(m.Value, articleText) ? m.Value : m.Groups[1].Value).TrimStart();

                if (!WikiRegexes.Wikify.IsMatch(articleText))
                {
	                if (Variables.LangCode.Equals("ar"))
	                {
	                	tagsRemoved.Add("ويكي");
                	}     
	                else if (Variables.LangCode.Equals("arz"))
	                {
	                	tagsRemoved.Add("ويكى");
                	}
	                else
	                {
	                	tagsRemoved.Add("underlinked");
                	}
                }
            }

            // rename unreferenced --> refimprove if has existing refs, update date
            if (WikiRegexes.Unreferenced.IsMatch(commentsCategoriesStripped)
                && (TotalRefsNotGrouped(commentsCategoriesStripped) + Tools.NestedTemplateRegex("sfn").Matches(articleText).Count) > 0)
            {
                articleText = Unreferenced.Replace(articleText, m2 => Tools.UpdateTemplateParameterValue(Tools.RenameTemplate(m2.Value, "refimprove"), "date", "{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}"));

                // update tag in old-style multiple issues
                Match m = WikiRegexes.MultipleIssues.Match(articleText);
                if (m.Success && Tools.GetTemplateParameterValue(m.Value, "unreferenced").Length > 0)
                {
                    string newValue = Tools.RenameTemplateParameter(m.Value, "unreferenced", "refimprove");
                    newValue = Tools.UpdateTemplateParameterValue(newValue, "refimprove", "{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}");
                    if (!newValue.Equals(m.Value))
                        articleText = articleText.Replace(m.Value, newValue);
                }
            }

            if (tagsAdded.Count > 0 || tagsRemoved.Count > 0)
            {
                Parsers p = new Parsers();
                HideText ht = new HideText();

                articleText = ht.HideUnformatted(articleText);

                articleText = p.MultipleIssues(articleText);
                articleText = Conversions(articleText);
                articleText = ht.AddBackUnformatted(articleText);

                // sort again in case tag removal requires whitespace cleanup
                // Don't sort interwikis, we can't specify the correct InterWikiSortOrder
                p.SortInterwikis = false;
                articleText = p.Sorter.Sort(articleText, articleTitle);
            }

            summary = PrepareTaggerEditSummary();

            return articleText;
        }
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:101,代码来源:Parsers.cs

示例12: PerformTypoFixes

        /// <summary>
        /// Performs typo fixes against the article text in multi-threaded mode
        /// Typo fixes not performed if no typos loaded or any sic tags on page
        /// </summary>
        /// <param name="articleText">The wiki text of the article.</param>
        /// <param name="noChange">True if no typos fixed</param>
        /// <param name="summary">Edit summary</param>
        /// <param name="articleTitle">Title of the article</param>
        /// <returns>Updated article text</returns>
        public string PerformTypoFixes(string articleText, out bool noChange, out string summary, string articleTitle)
        {
            string originalArticleText = articleText;
            summary = "";
            if (TypoCount == 0 || IgnoreRegex.IsMatch(articleText))
            {
                noChange = true;
                return articleText;
            }

            HideText removeText = new HideText(true, false, true);

            articleText = removeText.HideMore(articleText, true);

            // remove newlines, whitespace and hide tokens from bottom
            // to avoid running 2K regexps on them
            Match m = RemoveTail.Match(articleText);
            string tail = m.Value;
            if (!string.IsNullOrEmpty(tail))
                articleText = articleText.Remove(m.Index);

            string originalText = articleText;
            string strSummary = "";
            /* Run typos threaded, one thread per group for better performance
             * http://stackoverflow.com/questions/13776846/pass-paramters-through-parameterizedthreadstart
             * http://www.dotnetperls.com/parameterizedthreadstart
             * http://stackoverflow.com/questions/831009/thread-with-multiple-parameters */
            resultSummary.Clear();
            resultArticleText.Clear();

            Thread[] array = new Thread[Groups.Count];
            int i = 0;
            foreach (TypoGroup tg in Groups)
            {
                array[i] =
                    new Thread(
                        delegate()
                        {
                            tg.FixTypos2(articleText, strSummary, articleTitle, originalArticleText);
                        });
                array[i].Start();
                i++;
            }

            // Join all the threads: wait for all to complete
            foreach (Thread t in array)
            {
                t.Join();
            }

            foreach (TypoGroup tg in Groups)
            {
                string groupSummary;
                resultSummary.TryGetValue(tg.GroupSize, out groupSummary);
                string groupArticleText;
                resultArticleText.TryGetValue(tg.GroupSize, out groupArticleText);

                if (groupSummary.Length > 0)
                {
                    if (strSummary.Length > 0)
                    {
                        // earlier thread had changes, so need to re-run this one
                        tg.FixTypos(ref articleText, ref strSummary, articleTitle, originalArticleText);
                    }
                    else
                    {
                        strSummary = groupSummary;
                        articleText = groupArticleText;
                    }
                }
            }

            noChange = originalText.Equals(articleText);

            summary = Variables.TypoSummaryTag + strSummary.Trim();

            return removeText.AddBackMore(articleText + tail);
        }
开发者ID:reedy,项目名称:AutoWikiBrowser,代码行数:87,代码来源:RegExTypoFix.cs

示例13: DetectTypo

        /// <summary>
        /// Checks for known typos on the page
        /// </summary>
        /// <param name="articleText">The wiki text of the article.</param>
        /// <param name="articleTitle">Title of the article</param>
        /// <returns>whether there are typos on the page</returns>
        public bool DetectTypo(string articleText, string articleTitle)
        {
            string originalArticleText = articleText;
            if (TypoCount == 0 || IgnoreRegex.IsMatch(articleText))
                return false;

            HideText removeText = new HideText(true, false, true);

            articleText = removeText.HideMore(articleText, true);

            // remove newlines, whitespace and hide tokens from bottom
            // to avoid running 2K regexps on them
            Match m = RemoveTail.Match(articleText);
            if (m.Success)
                articleText = articleText.Remove(m.Index);

            string strSummary = "";

            foreach (TypoGroup grp in Groups)
            {
                grp.FixTypos(ref articleText, ref strSummary, articleTitle, originalArticleText);

                if (strSummary.Length > 0)
                    return true;
            }

            return false;
        }
开发者ID:reedy,项目名称:AutoWikiBrowser,代码行数:34,代码来源:RegExTypoFix.cs

示例14: Hide

 private string Hide(string text)
 {
     hider = new HideText();
     return hider.HideMore(text);
 }
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:5,代码来源:MiscellaneousTests.cs

示例15: TagUpdater

 /// <summary>
 /// Sets the date (month & year) for undated cleanup tags that take a date
 /// Avoids changing tags in unformatted text areas (wiki comments etc.)
 /// Note: bugzilla 2700 means {{ssubst}} within ref tags doesn't work, AWB doesn't do anything about it
 /// </summary>
 /// <param name="articleText">The wiki text of the article.</param>
 /// <returns>The updated article text</returns>
 public static string TagUpdater(string articleText)
 {
     HideText ht = new HideText();
     articleText = ht.HideUnformatted(articleText);
     
     foreach (KeyValuePair<Regex, string> k in RegexTagger)
     {
         articleText = k.Key.Replace(articleText, 
                                     m => (Tools.GetTemplateParameterValue(m.Value, "Date").Length > 0 ? 
                                           Tools.RenameTemplateParameter(m.Value, "Date", "date") : k.Value.Replace("$1", m.Groups[1].Value)));
     }
     return ht.AddBackUnformatted(articleText);
 }
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:20,代码来源:Parsers.cs


注:本文中的WikiFunctions.Parse.HideText类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。