0
votes

What is different here? Am I doing something wrong? Is it maybe because of my BBCode parser? I believe both of these should look like the first example.

<span style="color:#00369B"><span style="font-size:47px">aaaaaaaaaaaaaaaa</span></span>

Outcome: Image

<span style="font-size:47px"><span style="color:#00369B">aaaaaaaaaaaaaaa</span></span>

Outcome: Image 2

Here is the BBCode parser code for SizeTag:

class SizeTag(Tag):
    def _to_html(self):
        size = self.params.get('size')

        try:
            size = int(size)
        except (TypeError, ValueError):
            size = None

        if size is None:
            return self.get_content()

        if size == 1:
            return u'<span style="font-size:11px">' , self.get_content(), u'</span>',
        elif size == 2:
            return u'<span style="font-size:13px">' , self.get_content(), u'</span>',
        elif size == 3:
            return u'<span style="font-size:15px">' , self.get_content(), u'</span>',
        elif size == 4:
            return u'<span style="font-size:17px">' , self.get_content(), u'</span>',
        elif size == 5:
            return u'<span style="font-size:23px">' , self.get_content(), u'</span>',
        elif size == 6:
            return u'<span style="font-size:31px">' , self.get_content(), u'</span>',
        elif size == 7:
            return u'<span style="font-size:47px">' , self.get_content(), u'</span>',

And here's the BBCode parser code for ColorTag:

class ColorTag(Tag):
    def _to_html(self):
        color = self.params.get('color')

        if not color:
            return self.get_content()

        return u'<span style="color:%s">' % color, self.get_content(), u'</span>',

BBCode parser taken from here

EDIT: My problem is that the font size is not changing in the second example when it's the same code, just written differently.

EDIT 2: The problem appears to be the font size, because color works with everything else. I tested it with lists along with some other tags like bold or italic. The font-size is the main problem here, it doesn't work when there are other tags included over it.

1

1 Answers

0
votes

where is the else ? there is only had if,elif, and no else in code.

you must using else condition after elif condition in codes.

that's my suggest. hope it works