Html Tidy einstellen



  • Hallo

    ich habe ein kleines programm gschrieben, was mit html tidy arbeitet. aber leidet ist die doku sehr schlecht. ist das so richtig eingestellt?

    TidyBuffer output = {0};
    	  TidyBuffer errbuf = {0};
    	  Bool ok;
    	  int rc = -1;
    
    	int nLen = m_strFilename.GetLength();
    	LPTSTR lpszBuf = m_strFilename.GetBuffer(nLen);
    	m_strFilename.ReleaseBuffer();
    
      TidyDoc tdoc = tidyCreate();                                  /* Das "Document" initialisieren */
    //  printf( "Säubere:\t%s\n", input );
    
      ok = tidyOptSetBool( tdoc, TidyXhtmlOut, yes );               /* Konvertierung nach XHTML */
      tidyOptSetInt(tdoc,TidyIndentContent, TidyAutoState);
    	tidyOptSetInt(tdoc,TidyDoctypeMode, TidyDoctypeAuto);
    	tidyOptSetBool( tdoc, TidyWrapAsp, yes );
    	tidyOptSetBool( tdoc, TidyWrapPhp, yes );
    	tidyOptSetBool( tdoc, TidyWrapSection, yes );
    	tidyOptSetBool( tdoc, TidyWrapJste, yes );
    	tidyOptSetBool( tdoc, TidyFixUri, yes );
    	tidyOptSetBool( tdoc, TidyFixComments, yes );
    	tidyOptSetBool( tdoc, TidyFixBackslash, yes );
    	tidyOptSetBool( tdoc, TidyDropEmptyParas, yes );
    	tidyOptSetBool( tdoc, TidyJoinStyles, yes );
    	tidyOptSetBool( tdoc, TidyQuoteAmpersand, yes );
    	tidyOptSetBool( tdoc, TidyQuoteNbsp, yes );
    	tidyOptSetInt( tdoc, TidyWrapLen, 90 );
    	tidyOptSetInt( tdoc, TidyTabSize, 4 );
    	tidyOptSetBool( tdoc, TidyAsciiChars, yes );
    	tidyOptSetValue(tdoc,TidyCharEncoding,"ascii");
    
      if (   ok    ) rc = tidySetErrorBuffer( tdoc, &errbuf );      /* Erfassen der Fehlerdiagnosen */
     // if ( rc >= 0 ) rc = tidyParseString(    tdoc, input );        /* Analysiere die Eingabe */
      if ( rc >= 0 ) rc = tidyParseFile(    tdoc, m_strFilename);
      if ( rc >= 0 ) rc = tidyCleanAndRepair( tdoc );               /* Bereinige es! */
      if ( rc >= 0 ) rc = tidyRunDiagnostics( tdoc );               /* Kvetch */
      if ( rc >  1 ) rc = ( tidyOptSetBool(   tdoc, TidyForceOutput, yes) ? rc : -1 ); /* Bei einem Fehler die Ausgabe erzwingen. */
      if ( rc >= 0 ) rc = tidySaveBuffer(     tdoc, &output );      /* gut formatieren */
      if ( rc >= 0 )
    
    //  CString strTemp;
      m_strError.Format("%s",errbuf.bp);
      m_strError.Replace("\r\n","|");
    
      m_iCountError = tidyErrorCount(tdoc) + tidyWarningCount(tdoc) + tidyAccessWarningCount(tdoc);
      SortError(m_strError,tidyErrorCount(tdoc) + tidyWarningCount(tdoc) + tidyAccessWarningCount(tdoc));
    
      m_strOutput.Format("%s",output.bp);
    
      tidyBufFree( &output );
      tidyBufFree( &errbuf );
      tidyRelease( tdoc );
    
      return rc;
    


  • Das solltest Du vielleicht in einem Tidy-Forum fragen... oder am besten doch mal die Doku lesen 😉 oder die Beispiele...

    http://tidy.sourceforge.net/docs/api/tidy_8h-source.html



  • und jetzt mal eine kompetente antwort...

    die doku ist sehr schlecht, und beispiele gibts auch nur wenige



  • Dein Beispiel sieht doch 1-zu-1 so aus wie das Beispiel in der "doku"...
    Und nur zu Fragen: "Ist das so richtig?" könntest Du vielleicht Dein Problem schildern und dann dazu eine konkrete Frage stellen (aber besser Aufgehoben wäre die Frage vermutlich im sf-Forum von Tidy).



  • oh ja stimmt.

    es geht um die optionen bzw einstellungen. tidy zeigt ab und zu wirre fehler an und find einfach keine hilfe im inet. ich such mich schon eine wiche zu tote, nur um z erfahren, wie man tidy in c/c++ einstellt.

    oder was die einzelnen punkte bedeuten und wie man sie einstellt. die doku von tidy ist so umfangreich, wie ein herr stoiber an fachkompetenz 🙄



  • hallo forum,
    mich würde interesieren mit welcher funktion tidy die html seiten nach href-tags durchsucht??? kennt jemand die funktion??? ich hab zwar den quelltext von tidy, aber das sind jede menge dateien, bis ich alle durch bin.... 🙂 🤡 , und ich kann das projekt tidy nicht zum laufen bringen und dann mit debug die funktion ermitteln, gibts da eine projekt mappe mit allen dateien, das kompiliert werden kann usw.?? 😕

    danke
    pixel


Anmelden zum Antworten