How to preserve linked stylesheets in HTML?

  • Hi,

    I need to develop a simple HTML editor. This editor loads HTML files that have the styles in a separate css file. The stylesheet is linked with

    Code
    <link href="../res/docstyle.css" rel="stylesheet" type="text/css" />

    When saving the HTML file, this stylesheet link is removed from the HTML code. Saving is done with

    Code
    wpEditor.SaveToFile(wpEditor.LastFileName, false, 'HTML-DontWriteFontParams,HTML-DontWriteStyleParam');


    and the resulting HTML file includes a new <style> section with all the definitions from the original css - but commented out with <!--.

    How can I prevent the removal of the link?
    Is there a tutorial for editing HTML files in TWPRichText with minimum impact on the already existing HTML code?

    Best regards,
    Fred[/code]

    • Offizieller Beitrag

    WPTools is designed as word processor, it imports and exports HTML and so makes changes.

    There is also the XML reader/writer in unit WPIOXml1.pas. That unit is an example how an XML structure can be loaded as saved to a file. It contains several constants which can be customized.

    The comments around style can be disabled in WPIOHTML,

    WriteString(#13 + #10 + '<style><!--' + #13 + #10);
    WriteStyleSheet;
    WriteString(#13 + #10 + '--></style>');

    unless you decide to save the CSS from WPRichText.ParStyles directly and use -csspath:"...." as an option.