Ich habe Tidy mit libtidy von Michael Elsdörfer verwendet. Es gibt Ihnen eine Menge Optionen und Sie können sie extern für die Anwendung konfigurieren. Gilt auch für HTML.
Dies ist ein sehr grober Code, den ich verwendet habe. Mach damit, wie es dir gefällt.
function TForm1.DoTidy(const Source: string): string;
var
Tidy : TLibTidy;
begin
if not TidyGlobal.LoadTidyLibrary('libtidy.dll') then
begin
// Application.MessageBox('TidyLib is not available.', 'Error', 16);
// exit;
raise Exception.Create('Cannot load TidyLib.dll');
end;
Tidy := TLibTidy.Create(Self);
try
Tidy.LoadConfigFile(ExtractFilePath(Application.ExeName) +
'tidyconfig.txt');
// Tidy.Configuration.IndentContent := tsYes;
// Tidy.Configuration.IndentSpaces := 5;
// Tidy.Configuration.UpperCaseTags := False;
// Tidy.Configuration.NumEntities := True;
// Tidy.Configuration.AccessibilityCheckLevel := 2;
// Tidy.Configuration.InlineTags := 'foo,bar';
// Tidy.Configuration.XmlDecl := True;
// Tidy.Configuration.XmlTags := True;
// Tidy.Configuration.CharEncoding := TidyUTF8;
// Tidy.Configuration.WrapLen := 0;
// Tidy.SaveConfigFile('tidyconfig.txt');
Tidy.ParseString(Source);
Result := Tidy.RunDiagnosticsAndRepair;
finally
Tidy.Free;
end;
end;
PS - Dies wird- kollabieren. –
dacracot