I've set up the Input Format - Filtered HTML - to accept these HTML tags:

<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockcode> <b> <i> <blockquote> <table> <tbody> <tr> <td> <th> <div> <img>

Some of my entries include a small 3 row x 2 column table. Publishing the table using the above filter works. My problem is when I add some style attributes, those style attributes are not recognised.

A sample entry is like so:

<table border="1" cellpadding="2" style="font-size: 70%;float:right; margin-right: 10px;margin-right:10px;margin-top: 10px;margin-bottom: 10px;"><tbody>
<tr align="center">
<td colspan="2"><b>C++ Study  w/e 23 Mar 2008</b></td>
</tr>...and so on.

The main intended purpose of the above code is that the table is positioned on the right side of the page and text floats around it on the left. I have to resort to Full HTML to get the desired result. A sample page of what is required is here http://prime357.org/node/50 . If using the Filtered HTML Input Format, the table is published but no style information is recognised and text starts below the table (not floating around it).

Any help would be appreciated.

Comments

dman’s picture

AFAIK, style is always filtered as being too dangerous.
If you let that through, you may as well not be filtering at all.
I think you can hack core if you want (keep searching) or just use unfiltered.

Filtering is used to stop folk breaking layouts. Do you or don't you want the power to ruin your own layout?

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

superjacent’s picture

I realise that I could use CSS for this sort of stuff but not all tables will be formatted in this way. Are you suggesting that this is probably the safest way to go ie. create a left & right floating classes, use them when needed without resorting to the style attribute. I'm thinking out aloud at the moment and probably answering my own question.

___________________________

Steven Taylor
http://prime357.org

dman’s picture

I wasn't suggesting that, hadn't even thought further than describing the status quo, but yes, I think that's a good solution to your own question!

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

gareth_w’s picture

I had a similar problem with Gallery2 images - trying to float them where I wanted, but just including Gallery2's float left (or right) formatting directly into it's link worked a charm.

Gareth

arh1’s picture

the HTML filter will always filter the style attribute, but not the class attribute. just assign classes to your table and define them in your stylesheet.

Chill35’s picture

This stripping of the <style> attribute requires special attention when one uses a code-highlighting module.

For example, the GeSHi Filter colors your code snippets using <span> tags, and it uses the style attribute of these <span> tags to set the color to red, or green or blue.

If you want to use the GeSHi filter with filtered HTLM, you *must* Rearrange the order of the filters of your input format to make sure that the HTML filter is applied before the GeSHi filter. That way, the HTML filter will not strip the style attributes added by the second filter. (Neither will it strip the <span> and <pre> tags...)

In addition to this, you must add certain special tags to your allowed tags to account for these used to communicate with the code filter. Let me give you an example. Let's say we create a node with a php code snippet. In order for the GeSHi filter to recognize our snippet as php, and color it accordingly, we use the following tag to enclose our snippet:

<blockcode type="php">My code</blockcode>.

Of course, the <blockcode> is a bogus HTML tag. The GeSHi filter replaces this tag with a <div>., and rewrites the content with whatever is appropriate so that *on screen* you get nicely formatted colored code.

If you're lazy...

With the GeSHi filter we may also use brackets to enclose our code snippet. We hence write our content as so:

[blockcode type="php"]My code[/blockcode]

No need to add tags to the allowed list of your HTML filter if you use brackets.

PS: The GeSHi filter can be configured to use the class attribute to color code, but the colors won't show if the content is aggregated on some other web site.

Caroline
Drupal on 11 heavens.com

superjacent’s picture

Thanks, very informative.

___________________________

Steven Taylor
http://prime357.org