473,487 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

HTML stylesheet expander?

Does anyone have any code or pointers to something
that can take some HTML with CSS style information
and expand it into HTML that works pre-CSS.

For example, say I had a style like this:

.citation { font-style: italic }

And had HTML like this:

<p class="citation>foo bar</p>

Then the results produced are:

<p><i>foo bar</i></p>

This does get somewhat complicated as the styles can be
"nested", apply to contained elements, expand to attributes
or new tags etc.

I generate the HTML and "own" the stylesheets.

The reason behind this is that the wxWidgets HTML control
doesn't support styles, and so something like this has to
be done to get the same kind of effect.

I do have a current solution that uses HTMLParser and
hierarchical style information that works, but really don't
like it. It requires every HTML tag to be perfectly closed
and is very hacky.

There is talk on the wxPython group of using Mozilla or KHTML
but these aren't available on Windows, Linux and Mac, and/or
you get an entire tabbed browser etc in the deal.

Roger
Jul 18 '05 #1
4 1760
On Tue, 23 Nov 2004 19:51:08 -0800, Roger Binns <ro****@rogerbinns.com> wrote:
Does anyone have any code or pointers to something
that can take some HTML with CSS style information
and expand it into HTML that works pre-CSS.


I'm not sure such a thing would be possible. You could convert some
CSS styling into roughly equivalent HTML, but you can do things with
CSS that simply aren't possible with HTML alone. What would you expect
to be done with that?

--
Cheers,
Simon B,
si***@brunningonline.net,
http://www.brunningonline.net/simon/blog/
Jul 18 '05 #2
Roger Binns wrote:
Does anyone have any code or pointers to something
that can take some HTML with CSS style information
and expand it into HTML that works pre-CSS.


It can't be done in general since CSS has far more control over the styling
than HTML ever gave you. However, if you are willing to restrict yourself
to simple cases I would suggest you might be best loading the HTML into a
browser and manipulating it there to find out what styles everything has.

If you are using Windows then there is no problem: just drive IE remotely
through COM and use Python to iterate over the document and pick out the
runtime style attributes that you are interested in.

If you are not using Windows, or you want portability, then you are
probably best doing this in Javascript.

Jul 18 '05 #3

"Duncan Booth" <du**********@invalid.invalid> wrote in message news:Xn***************************@127.0.0.1...
to simple cases I would suggest you might be best loading the HTML into a
browser and manipulating it there to find out what styles everything has.
This is in a program that runs on Windows, Linux and Mac and I am
generating the HTML, and supply the stylesheet.
If you are using Windows then there is no problem: just drive IE remotely
through COM and use Python to iterate over the document and pick out the
runtime style attributes that you are interested in.
My problem is that I want to display the HTML in the HTML widget
supplied with wxPython (which doesn't understand styles). If I
could use a different widget then that is fine, but at the moment
there are no alternatives (short of me spending many months of
working porting something to wxWidgets).
If you are not using Windows, or you want portability, then you are
probably best doing this in Javascript.


How exactly would I do that? There is no Javascript in Python and if
I had a way of displaying HTML then this is a non-issue.

Have a look at this screenshot: http://bitpim.org/screenshots/phonebook.jpg

The green backgrounded pane on the right is the wxPython HTML widget and
I use my current hacky scheme to apply styles for the various areas.

Roger
Jul 18 '05 #4
Roger Binns wrote:
If you are not using Windows, or you want portability, then you are
probably best doing this in Javascript.


How exactly would I do that? There is no Javascript in Python and if
I had a way of displaying HTML then this is a non-issue.


What I meant was that you do the conversion once and then use the converted
HTML in your program. Obviously if I misunderstood and the HTML is
dynamically generated that won't be possible.
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3859
by: Gregor Horvath | last post by:
Hi, Before I reinvent the wheel I`d like to ask if someone has done this before since I did not find an advice at Google. The goal is to create a dynamic Tree View in HTML. Say I have a...
1
3394
by: ryanmhuc | last post by:
I have a custom HTML tag: <custom>text is here</custom> I can do anything I would like in terms of calling methods with mozilla but not IE 6. For instance calling appendChild in IE results in an...
82
6217
by: Eric Lindsay | last post by:
I have been trying to get a better understanding of simple HTML, but I am finding conflicting information is very common. Not only that, even in what seemed elementary and without any possibility...
32
2621
by: Next | last post by:
Hi folks, Years ago, it occurred to me that a lot of the trouble of writing web browsers is caused by the upside-down arrangement of things: Javascript code exists inside a document, when...
9
6697
by: anupamjain | last post by:
Hi, After 2 weeks of search/hit-and-trial I finally thought to revert to the group to find solution to my problem.(something I should have done much earlier) This is the deal : On a JSP...
4
4841
by: Rick Walsh | last post by:
I have an HTML table in the following format: <table> <tr><td>Header 1</td><td>Header 2</td></tr> <tr><td>1</td><td>2</td></tr> <tr><td>3</td><td>4</td></tr> <tr><td>5</td><td>6</td></tr>...
6
8108
by: Christopher Glenn | last post by:
I have very basic html skills. My friend who has a wide screen monitor and is using IE7 sent me a jpg screen shot of my home page. I have attached this jpg, but I recall a while back that...
11
1750
by: David Schwartz | last post by:
I'm processing some xml with xsl stylesheets and, for some reason, I have one stylesheet that does not produce the needed html tags in the output. I can't figure out why this stylesheet would be...
7
3589
by: imtmub | last post by:
I have a page, Head tag Contains many Scripts and style sheet for Menu and Page. This code working fine and displaying menus and page as i wanted. Check this page for reference....
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.