Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

HTML to BBCode converter

NOTE: This is a old python 2 library written by Vladimir Korsun. The original repo on bitbucket is now defunct and there hasn't been any updates since 2017. I fixed a few issues with would prevent installation on python 3.

Usage

Command line converter

Input data will be read from the specified file and the result will be written to the specified file using custom elements mapping:

$ html2bbcode --map map.conf input.html output.bbcode

Input data will be read from the specified file and the result will be written to the standart output:

$ html2bbcode input.html

Input data will be read from the standard input and the result will be written to the specified file:

$ cat input.html | html2bbcode output.bbcode

Input data will be read from the standard input and the result will be written to the standard output:

$ cat input.html | html2bbcode

Mapping

--map option used to extend and change the default mapping:

[blockquote]
start: [quote]
end: [/quote]

Python module

>>> parser = HTML2BBCode()
>>> str(parser.feed('<ul><li>one</li><li>two</li></ul>'))
'[list][li]one[/li][li]two[/li][/list]'
>>> str(parser.feed('<a href="http://google.com/">Google</a>'))
'[url=http://google.com/]Google[/url]'
>>> str(parser.feed('<img src="http://www.google.com/images/logo.png">'))
'[img]http://www.google.com/images/logo.png[/img]'
>>> str(parser.feed('<em>EM test</em>'))
'[i]EM test[/i]'
>>> str(parser.feed('<strong>Strong text</strong>'))
'[b]Strong text[/b]'
>>> str(parser.feed('<code>a = 10;</code>'))
'[code]a = 10;[/code]'
>>> str(parser.feed('<blockquote>Beautiful is better than ugly.</blockquote>'))
'[quote]Beautiful is better than ugly.[/quote]'

About

Convert HTML to BBCode either using CLI or as a python package

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages