(Saving as HTML) Force CSSClassnames even for tags like Body

General TRichView support forum. Please post your questions here
Post Reply
Memnarch
Posts: 24
Joined: Mon Jul 08, 2013 7:21 am

(Saving as HTML) Force CSSClassnames even for tags like Body

Post by Memnarch »

Hi,
Iam currently forced to use InlineCSS.
When i use the defaultoption, i have a few issues with the generated CSS-Table.

The content sofar is fine, if you use this HTML-Document as a standalone page in a Browser. But if you include the generated Dokument in another, it'll overwrite existing CSS-Deklarations.

This happens, because the Table includes definitions for the tags
Body,ul,ol,p
and others.

I'd like to force it to use classnames for all deklarations. So let's say i can give it a name or prefix "MyStyle", it should generated CSS like this:

Code: Select all

body.MyStyle
{
 font-size: 8pt;
 font-family: 'Tahoma', 'Geneva', sans-serif;
 font-style: normal;
 font-weight: normal;
 color: #000000;
 text-decoration: none;
}
and the html is written like this:

Code: Select all

<body class="MyStyle"></body>
This allows me to encapsulate the document much easier in other html-dokuments.

This is for specific reason, just to note: i mostly have no influence on how these documents are encapsulated, so i can't change this method.

Greetings
Memnarch
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

If you include rvsoNoDefCSSStyle in the Options parameter of SaveHTMLEx, CSS will not be saved for <body> at all.
Memnarch
Posts: 24
Joined: Mon Jul 08, 2013 7:21 am

Post by Memnarch »

I use this option, however, there is still:

Code: Select all


body {
  margin(some text i dont remember here)
}

=================TextSTyles==============
(styles for text here)
i don't have the code right now(where i am) but iirc i setup the margin for the TRichViewEdit after creation and this is what is written right there.

I think this was in GetBodyCSS of RVStyle and was hardcoded(always called when css is used)

However, if you changed this behaviour during the last 2-3 updates, i might have missed it( a bit behind with the updates atm ;) )
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, margins and background are saved in <body> (where else can they be saved?). But if you want to embed this HTML in another HTML, I believe you do not need these margins and <head> and <body> tags at all. You can save only content by including rvsoMiddleOnly in the options of SaveHTMLEx
Memnarch
Posts: 24
Joined: Mon Jul 08, 2013 7:21 am

Post by Memnarch »

ofcourse they need to be put in Body ;)

But in the CSS you could do body.mystyle

and use this mystyle class for the body. This assigns this style ONLY to this body. Currently it overrides all bodies.

Working around by doing a string replace on the first
"body"
and
"<body>"

to be the way i described above. But feels ugly^^"
Memnarch
Posts: 24
Joined: Mon Jul 08, 2013 7:21 am

Post by Memnarch »

Another Tag i noticed is the HR tag. Needs a classname too.(As this one occurs in the Body but is always redeclared in the CSS)
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I still suggest saving <body> yourself and using rvsoMiddleOnly option.
As for <hr> - it should not be saved in CSS if rvsoNoDefCSSStyle is in Options, I'll fix it.
Post Reply