Difference between revisions of "Software/Html2mediawiki"

From ThorstensHome
Jump to: navigation, search
(Ubuntu)
(Ubuntu)
Line 121: Line 121:
 
* install tidy
 
* install tidy
 
  sudo apt-get install tidy
 
  sudo apt-get install tidy
 +
sudo apt-get install libtidy-dev
 
* install the KDE 4 development libs
 
* install the KDE 4 development libs
 
  sudo apt-get install kdelibs5-dev
 
  sudo apt-get install kdelibs5-dev
 
yes, really, to install KDE 4, you need to install kdelibs5. This is an Ubuntu feature.
 
yes, really, to install KDE 4, you need to install kdelibs5. This is an Ubuntu feature.
 +
* correct the placement of tidy
 +
sudo cp /usr/include/tidy/*.h /usr/include
  
 
= Thanks to =
 
= Thanks to =

Revision as of 11:50, 14 December 2008

Contents

Overview

html2mediawiki converts html syntax to mediawiki syntax.

For example, this html syntax:

<!-- this is an example html file for use with html2mediawiki -->
<html>
<body>
<h1>heading 1 </h1>
<ul>
<li>list item 1</li>
<li>list item 2 </li>
</ul>
<h2>heading 2 </h2>
whatever text
</body>
</html>

is converted to this mediawiki syntax:

= heading 1 =
* list item 1
* list item 2
== heading 2 ==
whatever text

Download

Download version 0.1

Install it

To install html2mediawiki,

  • Make sure you have the needed software packages installed, tidy, cmake and KDE4. With SUSE Linux, you can do it like this:
yast -i tidy cmake kdelibs4-devel
  • Download the tarball and unpack it:
wget http://www.linuxintro.org/staerk/files/html2mediawiki.tar.gz
tar xvzf html2mediawiki.tar.gz
  • And build it:
cd html2mediawiki/
cmake . && make && make install

Run it

You call html2mediawiki like this:

html2mediawiki example.htm > example.txt

This will transform the file example.htm to mediawiki format and store it in example.txt. Here is a screenshot from how I ran html2mediawiki:

tweedleburg:~/html2mediawiki # cat example.htm 
<!-- this is an example html file for use with html2mediawiki -->
<html>                                                           
<body>                                                           
<h1>heading 1 </h1>                                              
<ul>                                                             
<li>list item 1</li>                                             
<li>list item 2 </li>                                            
</ul>                                                            
<h2>heading 2 </h2>                                              
whatever text                                                    
</body>                                                          
</html>                                                          
tweedleburg:~/html2mediawiki # html2mediawiki example.htm > example.txt
html2mediawiki(1979) main: "file:///root/html2mediawiki/example.htm"   
html2mediawiki(1979) tidy: Entering function                           
html2mediawiki(1979) tidy: Tidying:   %s\n <!-- this is an example html file for use with html2mediawiki -->                                                                          
<html>                                                                                     
<body>                                                                                     
<h1>heading 1 </h1>                                                                        
<ul>                                                                                       
<li>list item 1</li>                                                                       
<li>list item 2 </li>                                                                      
</ul>                                                                                      
<h2>heading 2 </h2>                                                                        
whatever text                                                                              
</body>                                                                                    
</html>                                                                                    
html2mediawiki(1979) tidy: \nDiagnostics:\n\n%s 0x76e160
html2mediawiki(1979) tidy: allocating memory  492
html2mediawiki(1979) main: "html"
html2mediawiki(1979) main: "head"
html2mediawiki(1979) main: "h1"
html2mediawiki(1979) output: "body"
html2mediawiki(1979) output: "h1"
html2mediawiki(1979) output: "#text"
html2mediawiki(1979) output: "heading 1"
html2mediawiki(1979) output: ""
html2mediawiki(1979) output: "ul"
html2mediawiki(1979) output: "li"
html2mediawiki(1979) output: "#text"
html2mediawiki(1979) output: "list item 1"
html2mediawiki(1979) output: ""
html2mediawiki(1979) output: "li"
html2mediawiki(1979) output: "#text"
html2mediawiki(1979) output: "list item 2"
html2mediawiki(1979) output: ""
html2mediawiki(1979) output: ""
html2mediawiki(1979) output: "h2"
html2mediawiki(1979) output: "#text"
html2mediawiki(1979) output: "heading 2"
html2mediawiki(1979) output: ""
html2mediawiki(1979) output: "#text"
html2mediawiki(1979) output: "
whatever text
"
html2mediawiki(1979) output: ""
tweedleburg:~/html2mediawiki # cat example.txt

= heading 1 =
* list item 1
* list item 2
== heading 2 ==
whatever text

Ubuntu

Clever as I am ;) I have used a virtual machine and installed Ubuntu and tested html2mediawiki there. Here is how you install on Ubuntu:

  • Get the latest cmake
cd
wget http://www.cmake.org/files/v2.6/cmake-2.6.2.tar.gz
tar xvzf cmake-2.6.2.tar.gz
cd cmake-2.6.2
./bootstrap
make && sudo make install
  • install tidy
sudo apt-get install tidy
sudo apt-get install libtidy-dev
  • install the KDE 4 development libs
sudo apt-get install kdelibs5-dev

yes, really, to install KDE 4, you need to install kdelibs5. This is an Ubuntu feature.

  • correct the placement of tidy
sudo cp /usr/include/tidy/*.h /usr/include

Thanks to

The two users I know of, Anne and Erik :)

See also