473,584 Members | 2,897 Online
Bytes | Software Development & Data Engineering Community
+ 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 1770
On Tue, 23 Nov 2004 19:51:08 -0800, Roger Binns <ro****@rogerbi nns.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***@brunningo nline.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**********@i nvalid.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
3877
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 data strucure like this: structList =
1
3403
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 error. The innerHTML property is blank even though there is text between the tag. Is there a work around for IE. What gives with IE and being...
82
6277
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 of getting wrong it seems I am on very shaky ground . For example, pretty much every book and web course on html that I have read tells me I must...
32
2655
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 really it should be the other way around. And yet, although this seems fairly obvious to me, having tried myself to write a web browser and given up, I...
9
6718
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 page, I want to grab a URL and parse /change the HTML and send it to the JSP page. I take the URL from the user in a textbox (not the
4
4850
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> </table> With an XSLT styles sheet, I can use for-each to grab the values in
6
8118
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 attachments were discouraged. I am sorry if I have offended anyone by attaching. Note the left side table tiles or repeats towards the right side of...
11
1767
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 different from all my others which I'm using quite successfully. Here are the key tags I'm using: <xsl:stylesheet version="1.0"...
7
3602
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. http://www.marco.com.cn/web-content/marco_re10.html -------------------------------------------------------------- <head> <!-- InstanceBeginEditable...
0
7897
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8190
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8331
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7940
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8200
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3850
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2336
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 we have to send another system
1
1441
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1163
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.