473,320 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Re: convert xhtml back to html

On 2008-04-24 19:16, John Krukoff wrote:
>-----Original Message-----
From: py***********************************@python.org [mailto:python-
li****************************@python.org] On Behalf Of Tim Arnold
Sent: Thursday, April 24, 2008 9:34 AM
To: py*********@python.org
Subject: convert xhtml back to html

hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop
to
create CHM files. That application really hates xhtml, so I need to
convert
self-ending tags (e.g. <br />) to plain html (e.g. <br>).

Seems simple enough, but I'm having some trouble with it. regexps trip up
because I also have to take into account 'img', 'meta', 'link' tags, not
just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to do
that with regexps, but my simpleminded <img[^(/>)]+/doesn't work. I'm
not
enough of a regexp pro to figure out that lookahead stuff.

I'm not sure where to start now; I looked at BeautifulSoup and
BeautifulStoneSoup, but I can't see how to modify the actual tag.
You could filter the XHTML through mxTidy and set the hide_endtags to 1:

http://www.egenix.com/products/pytho...mental/mxTidy/

--
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source (#1, Apr 24 2008)
>>Python/Zope Consulting and Support ... http://www.egenix.com/
mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
__________________________________________________ ______________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
Jun 27 '08 #1
0 1082

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

Similar topics

1
by: Sebastien B. | last post by:
I'm looking for the best tool to convert 'every day' html into proper XHTML so that I can parse it as an XML document. So far I've been using Tidylib to do this, but it doesn't handle things as...
20
by: John Bokma | last post by:
Hi, I converted most (not all) of my pages at http://johnbokma.com/ to XHTML. I thought this was just a small change from 4.01. However someone stated quite vaguely that my pages are *not*...
7
by: Simon Strandgaard | last post by:
There are no <iframe> tag in xhtml strict, instead I should use <object>. If I change <iframe> to <object> then my javascript stops working. I am curious to how to use <object> with javascript...
9
by: MLibby | last post by:
How do I convert an HTML page into XML? My initial thought is to convert the page to xslt but I'm not sure how to do this. Please provide any source code examples if you have them. Thanks, Mike...
24
by: Dan Jacobson | last post by:
I shall jump on the XHTML bandwagon. I run my perfectly good html4/strict pages thru $ tidy -asxhtml -utf8 #to get: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"...
13
by: Peter Williams | last post by:
Hello, If my html is valid XHTML accroding to http://validator.w3.org/, does thuis mean it is also valid (4.0.1) Html? Thanks in Advance
6
by: PenguinPig | last post by:
Dear All Experts I would like to know how to convert a HTML into Image using C#. Or allow me contains HTML code (parsed) in Image? I also tried this way but it just display the character "<" &...
11
by: Tim Arnold | last post by:
hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to create CHM files. That application really hates xhtml, so I need to convert self-ending tags (e.g. <br />) to plain html...
0
by: John Krukoff | last post by:
-----Original Message----- One method which wouldn't require much python code, would be to run the XHTML through a simple identity XSL tranform with the output method set to HTML. It would...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.