Add ability to handle Font tags

Create issue
Issue #8 resolved
Rob Hills created an issue

AFAICT, html2bbcode doesn't handle font tags.

The challenge is that the bbcode output depends on an attribute of the font tag:

<font face="arial"> -> [font=arial] <font color="red"> -> [color=red] <font size=2> -> [size=2]

A bigger challenge is that a font tag could have more than one attribute.

If you could add the facility to define a combination of a tag + single attribute -> bbcode in the mapping file, that would be excellent. If there was a way of doing this so that it also handled the tag + multiple attributes, that would be outstanding!

Comments (5)

  1. Vladimir Korsun repo owner

    Hey, @rhills

    Thank you for advice. You can use own map file to define new or redefine existing tags. As sample for font tag:

    [font]
    start: [color=%(color)s][font=%(face)s][size=%(size)s]
    end: [/size][/font][/color]
    
  2. Rob Hills reporter

    Hi Vladimir, Thanks for your prompt reply. Your suggestion will certainly work well if the <font> tag has all three attributes. However, if it only has one or two, it doesn't work as well. For example, this text:

    <font color=RED>do not</font>
    

    converts to:

    [color=RED][font=][size=]do not[/size][/font][/color]
    

    Ideally, only the attributes that are present in the tag would be converted. Is there any other magic that could be done in the map file definition to achieve that? I suspect not and that handling this case would require some code refactoring.

  3. Vladimir Korsun repo owner

    @rhills,

    I added attribute transformation to tags. New version of package released.

  4. Log in to comment