Exemplo n.º 1
0
        /// <summary>
        /// Performs numerous minor improvements to the page text
        /// </summary>
        /// <param name="parsers">A parser object</param>
        /// <param name="removeText"></param>
        /// <param name="skip">Skip options</param>
        /// <param name="replaceReferenceTags">If true, <div class="references-small"><references/></div> and so on
        /// will be replaced with {{reflist}}</param>
        public void PerformGeneralFixes(Parsers parsers, HideText removeText, ISkipOptions skip, bool replaceReferenceTags)
        {
            BeforeGeneralFixesTextChanged();

            HideText(removeText);

            Variables.Profiler.Profile("HideText");

            FixHeaderErrors(parsers, Variables.LangCode, skip.SkipNoHeaderError);
            Variables.Profiler.Profile("FixHeaderErrors");
            SetDefaultSort(parsers, Variables.LangCode, skip.SkipNoDefaultSortAdded);
            Variables.Profiler.Profile("SetDefaultSort");

            AWBChangeArticleText("Fix categories", Parsers.FixCategories(ArticleText), true);
            Variables.Profiler.Profile("FixCategories");

            AWBChangeArticleText("Fix images", Parsers.FixImages(ArticleText), true);
            Variables.Profiler.Profile("FixImages");

            AWBChangeArticleText("Fix whitespace in links", Parsers.FixLinkWhitespace(ArticleText, Name), true);
            Variables.Profiler.Profile("FixLinkWhitespace");

            AWBChangeArticleText("Fix syntax", parsers.FixSyntax(ArticleText), true);
            Variables.Profiler.Profile("FixSyntax");

            AWBChangeArticleText("Fix temperatures", parsers.FixTemperatures(ArticleText), true);
            Variables.Profiler.Profile("FixTemperatures");

            AWBChangeArticleText("Fix main article", Parsers.FixMainArticle(ArticleText), true);
            Variables.Profiler.Profile("FixMainArticle");

            if (replaceReferenceTags)
            {
                AWBChangeArticleText("Fix reference tags", parsers.FixReferenceListTags(ArticleText), true);
                Variables.Profiler.Profile("FixReferenceTags");
            }

            AWBChangeArticleText("Fix empty links and templates", Parsers.FixEmptyLinksAndTemplates(ArticleText), true);
            Variables.Profiler.Profile("FixEmptyLinksAndTemplates");

            AWBChangeArticleText("Fix empty references", Parsers.SimplifyReferenceTags(ArticleText), true);
            Variables.Profiler.Profile("FixEmptyReferences");

            if (IsMissingReferencesDisplay)
            {
                AWBChangeArticleText("Add missing {{reflist}}", Parsers.AddMissingReflist(ArticleText), true);
                Variables.Profiler.Profile("AddMissingReflist");
            }

            //Just a bit broken/Some unwanted fixes (moving of <ref> tags around)
            //AWBChangeArticleText("Fix Footnotes", parsers.FixFootnotes(ArticleText), true);
            //Variables.Profiler.Profile("FixFootnotes");

            FixLinks(parsers, skip.SkipNoBadLink);
            Variables.Profiler.Profile("FixLinks");
            BulletExternalLinks(parsers, skip.SkipNoBulletedLink);
            Variables.Profiler.Profile("BulletExternalLinks");

            AWBChangeArticleText("Remove empty comments", Parsers.RemoveEmptyComments(ArticleText), false);
            Variables.Profiler.Profile("RemoveEmptyComments");

            //if (Variables.IsWikimediaProject)
            //{
            //    AWBChangeArticleText("External to internal links", Parsers.ExternalURLToInternalLink(ArticleText), true);
            //    Variables.Profiler.Profile("ExternalURLToInternalLink");
            //}

            Variables.Profiler.Profile("Links");

            if (!Globals.UnitTestMode) // disable to avoid ssslow network requests
            {
                AWBChangeArticleText("Sort meta data",
                                     parsers.SortMetaData(ArticleText, Name), true);

                Variables.Profiler.Profile("Metadata");
            }

            EmboldenTitles(parsers, skip.SkipNoBoldTitle);

            AWBChangeArticleText("Format sticky links",
                                 Parsers.StickyLinks(Parsers.SimplifyLinks(ArticleText)), true);

            //AWBChangeArticleText("Remove duplicate wikilink", parsers.RemoveDuplicateWikiLinks(ArticleText), true);

            UnHideText(removeText);

            AfterGeneralFixesTextChanged();

            Variables.Profiler.Profile("End of general fixes");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Performs numerous minor improvements to the page text
        /// </summary>
        /// <param name="parsers">A parser object</param>
        /// <param name="removeText"></param>
        /// <param name="skip">Skip options</param>
        /// <param name="replaceReferenceTags">If true, <div class="references-small"><references/></div> and so on
        /// will be replaced with {{reflist}}</param>
        public void PerformGeneralFixes(Parsers parsers, HideText removeText, ISkipOptions skip, bool replaceReferenceTags)
        { //TODO: 2009-01-28 review which of the genfixes below should be labelled 'significant'
            BeforeGeneralFixesTextChanged();

            HideText(removeText);

            Variables.Profiler.Profile("HideText");

            // call this before FixHeaderErrors so that Parsers.Conversions cleans up from ArticleIssues
            AWBChangeArticleText("Fixes for {{article issues}}", parsers.ArticleIssues(ArticleText), true);
            Variables.Profiler.Profile("ArticleIssues");

            FixHeaderErrors(parsers, Variables.LangCode, skip.SkipNoHeaderError);
            Variables.Profiler.Profile("FixHeaderErrors");
            SetDefaultSort(Variables.LangCode, skip.SkipNoDefaultSortAdded);
            Variables.Profiler.Profile("SetDefaultSort");

            AWBChangeArticleText("Fix categories", Parsers.FixCategories(ArticleText), true);
            Variables.Profiler.Profile("FixCategories");

            AWBChangeArticleText("Fix images", Parsers.FixImages(ArticleText), true);
            Variables.Profiler.Profile("FixImages");

            AWBChangeArticleText("Fix whitespace in links", Parsers.FixLinkWhitespace(ArticleText, Name), true);
            Variables.Profiler.Profile("FixLinkWhitespace");

            // does significant fixes
            AWBChangeArticleText("Fix syntax", Parsers.FixSyntax(ArticleText), true, true);
            Variables.Profiler.Profile("FixSyntax");

            AWBChangeArticleText("Fix temperatures", Parsers.FixTemperatures(ArticleText), true);
            Variables.Profiler.Profile("FixTemperatures");

            AWBChangeArticleText("Fix non-breaking spaces", parsers.FixNonBreakingSpaces(ArticleText), true);
            Variables.Profiler.Profile("FixNonBreakingSpaces");

            AWBChangeArticleText("Fix main article", Parsers.FixMainArticle(ArticleText), true);
            Variables.Profiler.Profile("FixMainArticle");

            if (replaceReferenceTags)
            {
                AWBChangeArticleText("Fix reference tags", Parsers.FixReferenceListTags(ArticleText), true);
                Variables.Profiler.Profile("FixReferenceListTags");
            }

            AWBChangeArticleText("Fix empty links and templates", Parsers.FixEmptyLinksAndTemplates(ArticleText), true);
            Variables.Profiler.Profile("FixEmptyLinksAndTemplates");

            AWBChangeArticleText("FixReferenceTags", Parsers.FixReferenceTags(ArticleText), true);
            Variables.Profiler.Profile("FixReferenceTags");

            AWBChangeArticleText("DuplicateNamedReferences", Parsers.DuplicateNamedReferences(ArticleText), true);
            Variables.Profiler.Profile("DuplicateNamedReferences");

            AWBChangeArticleText("ReorderReferences", Parsers.ReorderReferences(ArticleText), true);
            Variables.Profiler.Profile("ReorderReferences");

            AWBChangeArticleText("Fix empty references", Parsers.SimplifyReferenceTags(ArticleText), true);
            Variables.Profiler.Profile("FixEmptyReferences");

            // does significant fixes
            if (IsMissingReferencesDisplay)
            {
                AWBChangeArticleText("Add missing {{reflist}}", Parsers.AddMissingReflist(ArticleText), true, true);
                Variables.Profiler.Profile("AddMissingReflist");
            }

            AWBChangeArticleText("Mdashes", parsers.Mdashes(ArticleText, Name, NameSpaceKey), true);
            Variables.Profiler.Profile("Mdashes");

            CiteTemplateDates(parsers, skip.SkipNoCiteTemplateDatesFixed);
            Variables.Profiler.Profile("CiteTemplateDates");

            //Just a bit broken/Some unwanted fixes (moving of <ref> tags around)
            //AWBChangeArticleText("Fix Footnotes", parsers.FixFootnotes(ArticleText), true);
            //Variables.Profiler.Profile("FixFootnotes");

            FixLinks(skip.SkipNoBadLink);
            Variables.Profiler.Profile("FixLinks");
            BulletExternalLinks(skip.SkipNoBulletedLink);
            Variables.Profiler.Profile("BulletExternalLinks");

            AWBChangeArticleText("Remove empty comments", Parsers.RemoveEmptyComments(ArticleText), false);
            Variables.Profiler.Profile("RemoveEmptyComments");

            AWBChangeArticleText("Fix Date Ordinals/Of", parsers.FixDateOrdinalsAndOf(ArticleText, Name), true, true);
            Variables.Profiler.Profile("FixDateOrdinalsAndOf");

            //if (Variables.IsWikimediaProject)
            //{
            //    AWBChangeArticleText("External to internal links", Parsers.ExternalURLToInternalLink(ArticleText), true);
            //    Variables.Profiler.Profile("ExternalURLToInternalLink");
            //}

            Variables.Profiler.Profile("Links");

            if (!Globals.UnitTestMode) // disable to avoid ssslow network requests
            {
                AWBChangeArticleText("Sort meta data",
                                     parsers.SortMetaData(ArticleText, Name), true);

                Variables.Profiler.Profile("Metadata");
            }

            EmboldenTitles(parsers, skip.SkipNoBoldTitle);

            AWBChangeArticleText("Format sticky links",
                                 Parsers.StickyLinks(Parsers.SimplifyLinks(ArticleText)), true);

            //AWBChangeArticleText("Remove duplicate wikilink", parsers.RemoveDuplicateWikiLinks(ArticleText), true);

            UnHideText(removeText);

            AfterGeneralFixesTextChanged();

            Variables.Profiler.Profile("End of general fixes");
        }