private bool InvokeZenCoding()
        {
            Span zenSpan = GetText();

            if (zenSpan.Length == 0 || TextView.Selection.SelectedSpans[0].Length > 0 || !IsValidTextBuffer())
                return false;

            string zenSyntax = TextView.TextBuffer.CurrentSnapshot.GetText(zenSpan);

            Parser parser = new Parser();
            string result = parser.Parse(zenSyntax, ZenType.HTML);

            if (!string.IsNullOrEmpty(result))
            {
                Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
                {
                    using (EditorExtensionsPackage.UndoContext("ZenCoding"))
                    {
                        ITextSelection selection = UpdateTextBuffer(zenSpan, result);

                        EditorExtensionsPackage.ExecuteCommand("Edit.FormatSelection");

                        Span newSpan = new Span(zenSpan.Start, selection.SelectedSpans[0].Length);
                        selection.Clear();
                        SetCaret(newSpan, false);
                    }
                }), DispatcherPriority.ApplicationIdle, null);

                return true;
            }

            return false;
        }
        private bool InvokeZenCoding()
        {
            Span zenSpan = GetText();

            if (zenSpan.Length == 0 || TextView.Selection.SelectedSpans[0].Length > 0 || !IsValidTextBuffer())
                return false;

            string zenSyntax = TextView.TextBuffer.CurrentSnapshot.GetText(zenSpan);

            Parser parser = new Parser();
            string result = parser.Parse(zenSyntax, ZenType.HTML);

            if (!string.IsNullOrEmpty(result))
            {
                EditorExtensionsPackage.DTE.UndoContext.Open("ZenCoding");

                ITextSelection selection = UpdateTextBuffer(zenSpan, result);
                Span newSpan = new Span(zenSpan.Start, selection.SelectedSpans[0].Length);

                if (result.Count(c => c == '>') > 2)
                {
                    _trackingSpan = TextView.TextBuffer.CurrentSnapshot.CreateTrackingSpan(newSpan, SpanTrackingMode.EdgeExclusive);
                }

                selection.Clear();

                EditorExtensionsPackage.DTE.UndoContext.Close();

                Dispatcher.CurrentDispatcher.BeginInvoke(
                    new Action(() => SetCaret(newSpan, false)), DispatcherPriority.Normal, null);

                return true;
            }

            return false;
        }