Difference between revisions of "Software/Html2mediawiki"

From ThorstensHome
Jump to: navigation, search
(Download)
 
(27 intermediate revisions by one user not shown)
Line 1: Line 1:
 +
{{DISPLAYTITLE:Html2mediawiki}}
 +
= Overview =
 
html2mediawiki converts html syntax to mediawiki syntax.
 
html2mediawiki converts html syntax to mediawiki syntax.
  
[http://www.linuxintro.org/staerk/files/html2mediawiki.tar.gz Download]
+
For example, this html syntax:
 +
<pre>
 +
<!-- 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>
 +
</pre>
 +
is converted to this mediawiki syntax:
 +
= heading 1 =
 +
* list item 1
 +
* list item 2
 +
== heading 2 ==
 +
whatever text
 +
 
 +
= Download =
 +
* [http://www.linuxintro.org/staerk/files/html2mediawiki.tar.gz Download version 0.2 - sourcecode]
 +
To download the latest development source code, open a Linux terminal and issue:
 +
svn co svn://linuxintro.org/html2mediawiki
  
 
= Install it =
 
= Install it =
To install html2mediawiki, download the tarball and unpack it:
+
To install html2mediawiki,
 +
 
 +
== SUSE ==
 +
* 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
 
  tar xvzf html2mediawiki.tar.gz
And build it:
+
* And build it:
 +
cd html2mediawiki/
 
  cmake . && make && make install
 
  cmake . && make && make install
 +
 +
== 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.
 +
* get the html2mediawiki source
 +
cd
 +
wget http://www.linuxintro.org/staerk/files/html2mediawiki.tar.gz
 +
tar xvzf html2mediawiki.tar.gz
 +
* build and install it
 +
cd html2mediawiki
 +
cmake . && make && sudo make install
 +
* test it like in this screenshot
 +
tstaerk@tstaerk-desktop:~/html2mediawiki$  ./html2mediawiki example.htm 2>/dev/null
 +
 +
= heading 1 =
 +
* list item 1
 +
* list item 2
 +
== heading 2 ==
 +
whatever text
 +
 +
= Run it =
 +
 +
== Prerequisites ==
 +
You must have your html files UTF-8 encoded. For info how to do this, read http://www.linuxintro.org/wiki/Unicode.
 +
 +
== Call 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:
 +
<pre>
 +
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
 +
</pre>
 +
 +
= Thanks to =
 +
The two users I know of, Anne and Erik :)
  
 
= See also =
 
= See also =
 
* [[spider]]
 
* [[spider]]
 
* [[add_toc]]
 
* [[add_toc]]

Latest revision as of 19:23, 17 May 2009

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

To download the latest development source code, open a Linux terminal and issue:

svn co svn://linuxintro.org/html2mediawiki

Install it

To install html2mediawiki,

SUSE

  • 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

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.

  • get the html2mediawiki source
cd
wget http://www.linuxintro.org/staerk/files/html2mediawiki.tar.gz
tar xvzf html2mediawiki.tar.gz
  • build and install it
cd html2mediawiki
cmake . && make && sudo make install
  • test it like in this screenshot
tstaerk@tstaerk-desktop:~/html2mediawiki$  ./html2mediawiki example.htm 2>/dev/null 

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

Run it

Prerequisites

You must have your html files UTF-8 encoded. For info how to do this, read http://www.linuxintro.org/wiki/Unicode.

Call 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

Thanks to

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

See also