/// <summary>
        /// Formats the given text.
        /// </summary>
        /// <param name="input">The text to format.</param>
        public void Format(string input)
        {
            m_output.Begin();

            // Initialize stuff.
            foreach (BlockModifier blockModifier in m_blockModifiers)
            {
                if (blockModifier.IsEnabled)
                {
                    blockModifier.Initialize();
                }
            }

            // Clean the text...
            string str = PrepareInputForFormatting(input);

            // ...run pre-processing on it...
            foreach (ProcessorModifier modifier in m_processorModifiers)
            {
                if (modifier.IsEnabled)
                {
                    str = modifier.PreProcess(str);
                }
            }
            // ...and format each line.
            string[] lines = str.Split('\n');
            for (int i = 0; i < lines.Length; ++i)
            {
                string tmp          = lines[i];
                string tmpLookAhead = null;
                if (i < lines.Length - 1)
                {
                    tmpLookAhead = lines[i + 1];
                }

                // Let's see if the current state(s) is(are) finished...
                while (CurrentState != null && CurrentState.ShouldExit(tmp, tmpLookAhead))
                {
                    PopState();
                }

                if (!EmptyLineRegex.IsMatch(tmp))
                {
                    // Figure out the new state for this text line, if possible.
                    if (CurrentState == null || CurrentState.ShouldParseForNewFormatterState(tmp))
                    {
                        tmp = HandleFormattingState(tmp, tmpLookAhead);
                    }
                    // else, the current state doesn't want to be superceded by
                    // a new one. We'll leave him be.

                    // Modify the line with our block modifiers.
                    if (CurrentState == null || CurrentState.ShouldFormatBlocks(tmp))
                    {
                        tmp = ApplyBlockModifiers(tmp);
                    }

                    // Post-process the line.
                    if (CurrentState == null || CurrentState.ShouldPostProcess(tmp))
                    {
                        tmp = ApplyPostProcessors(tmp);
                    }

                    // Format the current line.
                    CurrentState.FormatLine(tmp);
                }
            }
            // We're done. There might be a few states still on
            // the stack (for example if the text ends with a nested
            // list), so we must pop them all so that they have
            // their "Exit" method called correctly.
            while (m_stackOfStates.Count > 0)
            {
                PopState();
            }

            m_output.End();
        }