Exemple #1
0
        private void HTMLTidyProcessFile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                String  tidyHTML   = "";
                TidyNet objTidyNet = new TidyNet();

                // Set up options
                objTidyNet.Option.Clean(true);
                objTidyNet.Option.NewInlineTags("tidy");
                objTidyNet.Option.OutputType(EfTidyNet.EfTidyOpt.EOutputType.XhtmlOut);
                objTidyNet.Option.DoctypeMode(EfTidyNet.EfTidyOpt.EDoctypeModes.DoctypeAuto);
                objTidyNet.Option.Indent(EfTidyNet.EfTidyOpt.EIndentScheme.AUTOINDENT);
                objTidyNet.Option.TabSize(4);
                objTidyNet.Option.IndentSpace(4);

                objTidyNet.TidyMemToMem(CurrentTab().TextEditor.Text, ref tidyHTML);

                int totalWarnings = 0;
                int totalErrors   = 0;
                objTidyNet.TotalWarnings(ref totalWarnings);
                objTidyNet.TotalErrors(ref totalErrors);
                string error = objTidyNet.ErrorWarning();

                if (StyledMessageBox.Show("HTML TIDY FINISHED WITH " + totalErrors.ToString() + " ERRORS AND " + totalWarnings.ToString() + " WARNINGS",
                                          error,
                                          true))
                {
                    CurrentTab().TextEditor.ReplaceText(0, CurrentTab().TextEditor.Text.Length, tidyHTML);
                }
                this.CancelSettingsUI();
            }
            catch
            {
            }
        }
Exemple #2
0
        private void HTMLTidyProcessFile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                String tidyHTML = "";
                TidyNet objTidyNet = new TidyNet();

                // Set up options
                objTidyNet.Option.Clean(true);
                objTidyNet.Option.NewInlineTags("tidy");
                objTidyNet.Option.OutputType(EfTidyNet.EfTidyOpt.EOutputType.XhtmlOut);
                objTidyNet.Option.DoctypeMode(EfTidyNet.EfTidyOpt.EDoctypeModes.DoctypeAuto);
                objTidyNet.Option.Indent(EfTidyNet.EfTidyOpt.EIndentScheme.AUTOINDENT);
                objTidyNet.Option.TabSize(4);
                objTidyNet.Option.IndentSpace(4);

                objTidyNet.TidyMemToMem(CurrentTab().TextEditor.Text, ref tidyHTML);

                int totalWarnings = 0;
                int totalErrors = 0;
                objTidyNet.TotalWarnings(ref totalWarnings);
                objTidyNet.TotalErrors(ref totalErrors);
                string error = objTidyNet.ErrorWarning();

                if (StyledMessageBox.Show("HTML TIDY FINISHED WITH " + totalErrors.ToString() + " ERRORS AND " + totalWarnings.ToString() + " WARNINGS",
                    error,
                    true))
                {
                    CurrentTab().TextEditor.ReplaceText(0, CurrentTab().TextEditor.Text.Length, tidyHTML);
                }
                this.CancelSettingsUI();
            }
            catch
            {
            }
        }
Exemple #3
0
 internal static Tidy.Result Parse(Text.Line[] sourceLines, TidyNet.TidyMessage tidy, int linesToSkip)
 {
     if (tidy == null)
         return null;
     Levels level;
     switch (tidy.Level)
     {
         case TidyNet.MessageLevel.Info:
             return null;
         case TidyNet.MessageLevel.Warning:
             level = Levels.Warning;
             break;
         default:
             level = Levels.Error;
             break;
     }
     int? selectionStart = null;
     int? selectionLength = null;
     bool ok = false;
     int lineBase0 = tidy.Line - linesToSkip - 1;
     int columnBase0 = tidy.Column - 1;
     if ((lineBase0 >= 0) && (lineBase0 < sourceLines.Length))
     {
         int ss = 0;
         for (int i = 0; i < lineBase0; i++)
         {
             ss += sourceLines[i].FullLength;
         }
         if (columnBase0 < 0)
         {
             ok = true;
             selectionStart = ss;
             selectionLength = sourceLines[lineBase0].TextLength;
         }
         else if (columnBase0 < sourceLines[lineBase0].TextLength)
         {
             ok = true;
             selectionStart = ss + columnBase0;
             if (columnBase0 >= (sourceLines[lineBase0].TextLength - 1))
             {
                 selectionLength = sourceLines[lineBase0].TextLength - columnBase0;
             }
             else
             {
                 string substr = sourceLines[lineBase0].Text.Substring(columnBase0 + 1);
                 Match match = Regex.Match(substr, @"[\W]", RegexOptions.ExplicitCapture | RegexOptions.Singleline);
                 selectionLength = 1 + (match.Success ? match.Index : 0);
             }
         }
     }
     return new Tidy.Result(level, ok ? (tidy.Line - linesToSkip) : (int?)null, ok ? tidy.Column : (int?)null, selectionStart, selectionLength, tidy.Message);
 }