Salagir's Blog

Bon le blog est devenu tout simple tout moche, mais j’ai passé 24h à le mettre à jour. Il a peu de visites. Son ancien design n’était pas foufou. On va en rester là, hein. C’est surtout du texte après tout.

Convert HTML into BBcode

BBcode is the syntax used in phpBB forums and some other websites with edit forms, due to it’s simple and intuitive syntax, opposed to that stupid wiki code no one ever gets.

If, like me, you ever wanted to post the content of an html page, this Perl script is for you.
It takes a HTML file and creates a text file with the BB syntax.
You only need to copy this text into your post.

This is not made to copy-paste images, weird colors and CSS… Only text with some bold, italic, paragraphs, and others…

I wrote this script, in 2005, simply because I didn’t find any that was doing the same thing as well as I wanted.

It’d be better, for a good use of the script, that the html is valid

Example :
File test.html :

<p>What a <b>beautiful</b> day!!<br />
The sun...</p>
<p>The sunny shines !</p>

Running:

$ perl html2bbcode.pl test.html

Resulting file test.bb :

What a [b]beautiful[/b] day!!
The sun...


The sunny shines !

You can download the code:


Commentaires

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *