pirave / postmarkup

Automatically exported from code.google.com/p/postmarkup
0 stars 0 forks source link

Support [img=] syntax, currently raises AssertionError #19

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

postmarkup.render_bbcode('[url=http://www.google.com/][img=http://google.com/ima
ges/logo.gif][/url]')

What is the expected output? What do you see instead?

Expeced: <a href="http://www.google.com/"><img 
src="http://google.com/images/logo.gif"></img></a> [google.com]

AssertionError: Node index must be non-None

What version of the product are you using? On what operating system?

1.1.4

Please provide any additional information below.

I came across this issue while importing bbcode previously parsed by a 
different bbcode lib (in Ruby).

Original issue reported on code.google.com by jaap.roes@gmail.com on 12 Dec 2010 at 9:41

GoogleCodeExporter commented 8 years ago
I currently work around by having my own ImgTag implementation:

  import postmarkup

  class ImgTag(postmarkup.ImgTag):

      def render_open(self, parser, node_index):
          # Check for params (like [url=] tag)
          if self.params:
              url = self.params.strip()
          # Default behaviour (url is between [img][/img]
          else:
              contents = self.get_contents(parser)
              self.skip_contents(parser)
              url = postmarkup.strip_bbcode(contents).replace(u'"', "%22")

          return u'<img src="%s"></img>' % url

  markup = postmarkup.create()
  markup.add_tag(ImgTag, 'img')
  markup.render_to_html('[url=http://www.google.com/][img=http://google.com/images/logo.gif][/url]')

Original comment by jaap.roes@gmail.com on 12 Dec 2010 at 9:44

GoogleCodeExporter commented 8 years ago
Thanks. Fixed in trunk.

Original comment by willmcgugan on 4 Jan 2011 at 5:01