admin@glassfish.java.net

Re: questions about converting html to wiki

From: Bobby Bissett <bobby.bissett_at_oracle.com>
Date: Fri, 4 Jun 2010 15:39:41 -0400

On Jun 3, 2010, at 7:30 PM, Vince Kraemer wrote:
> Anissa Lam wrote:
>>
>> I have an html doc, that i need to convert to a wiki page. Is
>> there an easy way to do the conversion ?
>
> Not that I know of...

Would a tool like this be useful for others? Out of curiosity, in
about 20 minutes (sorry I didn't see this earlier) I wrote a Python
app that turns this html:

<table>
   <tr>
     <th>header0</th>
     <th>header1</th>
     <th>header2</th>
   </tr>
   <tr><td>data0</td><td>data1</td><td>data2</td></tr>
   <tr>
     <td>more data0</td>
     <td>more data1</td>
     <td>more data2</td>
   </tr>
</table>

Into this wiki markup:

|| header0 || header1 || header2
| data0 | data1 | data2
| more data0 | more data1 | more data2

It's a simple sax handler that parses the input, so it has to be valid
xhtml (I guess). And you can hack the output easily enough by editing
a file that has methods like these:

def th(data):
   print '||', data,

def td(data):
   print '|', data,

It's pretty simple, but could be expanded to handle most of what we
want in wiki pages.

Cheers,
Bobby