public string HideMore(string articleText, bool hideOnlyTargetOfWikilink, bool hideWikiLinks, bool hideItalics)
{
MoreHide.Clear();
cachedOriginalArticleTextBeforeHideMore = articleText;
ReplaceMore(WikiRegexes.NestedTemplates.Matches(articleText), ref articleText);
ReplaceMore(WikiRegexes.AllTags.Matches(articleText), ref articleText);
// this replace done for performance: quickly clear out lots of standard refs
ReplaceMore(SimpleRef.Matches(articleText), ref articleText);
if (HideExternalLinks)
{
// performance: only use all-protocol regex if the uncommon protocols are in use
ReplaceMore(WikiRegexes.ExternalLinksHTTPOnly.Matches(articleText), ref articleText);
if (articleText.Contains("//"))
ReplaceMore(WikiRegexes.ExternalLinks.Matches(articleText), ref articleText);
}
ReplaceMore(WikiRegexes.Headings.Matches(articleText), ref articleText);
ReplaceMore(WikiRegexes.Comments.Matches(articleText), ref articleText);
ReplaceMore(WikiRegexes.IndentedText.Matches(articleText), ref articleText);
// This hides internal wikilinks (with or without pipe) with extra word character(s) e.g. [[link]]age, which need hiding even if hiding for typo fixing
// https://en.wikipedia.org/wiki/Wikipedia_talk:AutoWikiBrowser/Feature_requests#Improve_HideText.HideMore.28.29
// place this as first wikilink rule as otherwise WikiLinksOnly will grab link without extra word character(s)
if (hideWikiLinks)
ReplaceMore(WikiRegexes.WikiLinksOnlyPlusWord.Matches(articleText), ref articleText);
// if HideOnlyTargetOfWikilink is not set, pipes of links e.g. [[target|pipe]] will be hidden
// if set then don't mask the pipe of a link so that typo fixing can be done on it
if (!hideOnlyTargetOfWikilink && hideWikiLinks)
ReplaceMore(WikiRegexes.SimpleWikiLink.Matches(articleText), ref articleText);
// if hiding target of wikilinks only, this does not apply to Category links, hide all of these
if (hideOnlyTargetOfWikilink && hideWikiLinks)
ReplaceMore(WikiRegexes.Category.Matches(articleText), ref articleText);
ReplaceMore(WikiRegexes.Refs.Matches(articleText), ref articleText);
// performance: get all remaining tags in format <tag...> in article, apply ReplaceMore only if needed
List<string> AnyTagList = (from Match m in AnyTag.Matches(articleText)
select m.Groups[1].Value.Trim().ToLower()).ToList();
// gallery tag does not require Image: namespace link before image in gallery, so hide anything before pipe
if (AnyTagList.Any(t => t.Contains("gallery")))
articleText = WikiRegexes.GalleryTag.Replace(articleText, m => {
string res = m.Value;
ReplaceMore(ImageToBar.Matches(res), ref res);
return res;});
// this hides only the target of a link, leaving the pipe exposed
if (hideWikiLinks)
ReplaceMore(WikiRegexes.WikiLink.Matches(articleText), ref articleText);
// Image links within templates already hidden as NestedTemplates hides all of templates
if (AnyTagList.Any(t => t.Contains("gallery")) || articleText.Contains(@"[[")) // check for performance
ReplaceMore(WikiRegexes.ImagesNotTemplates.Matches(articleText), ref articleText);
// hide untemplated quotes between some form of quotation marks (most particularly for typo fixing)
ReplaceMore(WikiRegexes.UntemplatedQuotes.Matches(articleText), ref articleText);
if (hideItalics)
ReplaceMore(WikiRegexes.Italics.Matches(articleText), ref articleText);
if (AnyTagList.Any(t => t.Contains("p style")))
ReplaceMore(WikiRegexes.Pstyles.Matches(articleText), ref articleText);
cachedArticleTextAfterHideMore = articleText;
return articleText;
}