WikiFunctions.Tools.RemoveExcessTemplatePipes C# (CSharp) Method

RemoveExcessTemplatePipes() public static method

Removes excess pipes from template calls, any where two pipes with no value/only whitespace between
public static RemoveExcessTemplatePipes ( string templatecall ) : string
templatecall string The template call to clean up
return string
        public static string RemoveExcessTemplatePipes(string templatecall)
        {
            if (SpacedPipes.IsMatch(templatecall))
            {
                string originalURL = CiteUrl.Match(templatecall).Groups[1].Value.TrimEnd("|".ToCharArray()), originalTemplateCall = templatecall;
                string pipecleanedtemplate = PipeCleanedTemplate(templatecall);

                while (SpacedPipes.IsMatch(pipecleanedtemplate))
                {
                    Match m = SpacedPipes.Match(pipecleanedtemplate);

                    // imatch is like "|   |" or "| }}" so remove first | and whitespace
                    templatecall = templatecall.Remove(m.Index, m.Groups[1].Length);

                    pipecleanedtemplate = PipeCleanedTemplate(templatecall);
                }

                // check for URL breakage due to unescaped pipes in URL
                if (originalURL.Length > 0 && !CiteUrl.Match(templatecall).Groups[1].Value.Equals(originalURL))
                    return originalTemplateCall;
            }

            return templatecall;
        }
Tools