original_docstring: Converts post markup (ie. bbcode) to XHTML. This method is threadsafe,
          buy virtue that the state is entirely stored on the stack.
  
          post_markup -- String containing bbcode.
          encoding -- Encoding of string, defaults to "ascii" if the string is not
          already unicode.
          exclude_tags -- A collection of tag names to ignore.
          auto_urls -- If True, then urls will be wrapped with url bbcode tags.
          paragraphs -- If True then line breaks will be replaced with paragraph
          tags, rather than break tags.
          clean -- If True, html will be run through the cleanup_html method.
          cosmetic_replace -- If True, then some 'smart' quotes will be enabled,
          in addition to replacing some character sequences with html entities.
          tag_data -- An optional dictionary to store tag data in. The default of
          None will create a dictionary internaly. Set this to your own dictionary
          if you want to retrieve information from the Tag Classes.
  
  
          
docstring: Converts post markup  to XHTML. This method is threadsafe,
  buy virtue that the state is entirely stored on the stack.
  
  - String containing bbcode.
  encoding -- Encoding of string, defaults to "ascii" if the string is not
  already unicode.
  exclude_tags -- A collection of tag names to ignore.
  auto_urls -- If True, then urls will be wrapped with url bbcode tags.
  paragraphs -- If True then line breaks will be replaced with paragraph
  tags, rather than break tags.
  clean -- If True, html will be run through the cleanup_html method.
  cosmetic_replace -- If True, then some 'smart' quotes will be enabled,
  in addition to replacing some character sequences with html entities.
  tag_data -- An optional dictionary to store tag data in. The default of
  None will create a dictionary internaly. Set this to your own dictionary
  if you want to retrieve information from the Tag Classes.
docstring_tokens: Converts post markup to XHTML . This method is threadsafe buy virtue that the state is entirely stored on the stack . - String containing bbcode . encoding -- Encoding of string defaults to " ascii " if the string is not already unicode . exclude_tags -- A collection of tag names to ignore . auto_urls -- If True then urls will be wrapped with url bbcode tags . paragraphs -- If True then line breaks will be replaced with paragraph tags rather than break tags . clean -- If True html will be run through the cleanup_html method . cosmetic_replace -- If True then some ' smart ' quotes will be enabled in addition to replacing some character sequences with html entities . tag_data -- An optional dictionary to store tag data in . The default of None will create a dictionary internaly . Set this to your own dictionary if you want to retrieve information from the Tag Classes .
code: def render_to_html(self,
                         post_markup,
                         encoding="ascii",
                         exclude_tags=None,
                         auto_urls=True,
                         paragraphs=False,
                         clean=True,
                         cosmetic_replace=True,
                         render_unknown_tags=False,                                            
                         tag_data=None):
  
          """Converts post markup (ie. bbcode) to XHTML. This method is threadsafe,
          buy virtue that the state is entirely stored on the stack.
  
          post_markup -- String containing bbcode.
          encoding -- Encoding of string, defaults to "ascii" if the string is not
          already unicode.
          exclude_tags -- A collection of tag names to ignore.
          auto_urls -- If True, then urls will be wrapped with url bbcode tags.
          paragraphs -- If True then line breaks will be replaced with paragraph
          tags, rather than break tags.
          clean -- If True, html will be run through the cleanup_html method.
          cosmetic_replace -- If True, then some 'smart' quotes will be enabled,
          in addition to replacing some character sequences with html entities.
          tag_data -- An optional dictionary to store tag data in. The default of
          None will create a dictionary internaly. Set this to your own dictionary
          if you want to retrieve information from the Tag Classes.
  
  
          """
  
          if not isinstance(post_markup, unicode):
              post_markup = unicode(post_markup, encoding, u'replace')
  
          if auto_urls:
              post_markup = self.tagify_urls(post_markup)
  
          post_markup = post_markup.replace(u'\r\n', u'\n')
          if paragraphs:
              post_markup = _re_break_groups.sub(u'\n\n', post_markup)      
  
          parser = _Parser(self, tag_data=tag_data)
          parser.tag_data.setdefault(u"output", {})
          parser.markup = post_markup
  
          if exclude_tags is None:
              exclude_tags = []
  
          tag_factory = self.tag_factory
  
          nodes = []
          parser.nodes = nodes
  
          parser.phase = 1
          parser.no_breaks_count = 0
          enclosed_count = 0
          tag_stack = []
          break_stack = []
          remove_next_newline = False
  
          def standard_replace(s):
              s = self.standard_replace(s)
              if cosmetic_replace:
                  s = _cosmetic_replace(s)
              return  s
  
          def standard_replace_no_break(s):
              s = self.standard_replace_no_break(s)
              if cosmetic_replace:
                  s = _cosmetic_replace(s)
              return  s
  
          def check_tag_stack(tag_name):
              for tag in reversed(tag_stack):
                  if tag_name == tag.name:
                      return True
              return False
  
          def redo_break_stack():
              while break_stack:
                  tag = break_stack.pop()
                  open_tag(tag)
                  tag_stack.append(tag)
  
          def break_inline_tags():
              while tag_stack:
                  if tag_stack[-1].inline:
                      tag = tag_stack.pop()
                      close_tag(tag)
                      break_stack.append(tag)
                  else:
                      break
  
          def open_tag(tag):
              def call(node_index):
                  return tag.render_open(parser, node_index)
              nodes.append(call)
  
          def close_tag(tag):
              def call(node_index):
                  return tag.render_close(parser, node_index)
              nodes.append(call)
  
          TOKEN_TEXT = PostMarkup.TOKEN_TEXT
                  
          if paragraphs:
              nodes.append(u"<p>")
          
          # Pass 1
          for tag_type, tag_token, start_pos, end_pos in self.tokenize(post_markup):
              
              if tag_type == TOKEN_TEXT:
                  if parser.no_breaks_count:
                      tag_token = tag_token.rstrip()
                      if not tag_token.strip():
                          continue
                  if remove_next_newline:
                      tag_token = tag_token.lstrip(u' ')
                      if tag_token.startswith(u'\n'):
                          tag_token = tag_token.lstrip(u' ')[1:]
                          if not tag_token:
                              continue
                      remove_next_newline = False
  
                  if tag_stack and tag_stack[-1].strip_first_newline:
                      tag_token = tag_token.lstrip()
                      tag_stack[-1].strip_first_newline = False
                      if not tag_stack[-1]:
                          tag_stack.pop()
                          continue
  
                  if not enclosed_count:
                      redo_break_stack()
                      
                  if paragraphs:                     
                      if not tag_stack:
                          while u'\n\n' in tag_token:
                              text, tag_token = tag_token.split(u'\n\n', 1)
                              if text.strip():                                                                                    
                                  nodes.append(standard_replace(text))                            
                              nodes.append(u"</p><p>")
  
                  nodes.append(standard_replace(tag_token))                
                  continue
  
              tag_name, tag_attribs, end_tag = self.parse_tag_token(tag_token)
              
              if tag_stack:
                  tag_stack[-1].strip_first_newline = False            
  
              if enclosed_count and tag_stack[-1].name != tag_name:
                  continue
  
              if tag_name in exclude_tags:
                  continue
  
              if not end_tag:
  
                  tag = tag_factory.get(tag_name, None)
                  if tag is None and render_unknown_tags:                    
                      tag = tag_factory.default_tag(tag_name)                                
                  if tag is None:
                      continue
  
                  redo_break_stack()
  
                  if not tag.inline:
                      break_inline_tags()
  
                  tag.open(parser, tag_attribs, end_pos, len(nodes), start_pos)
                  if tag.enclosed:
                      enclosed_count += 1
                  tag_stack.append(tag)
  
                  open_tag(tag)
  
                  if tag.auto_close:
                      tag = tag_stack.pop()                    
                      tag.close(self, end_pos, len(nodes)-1)
                      close_tag(tag)
  
              else:
                  if break_stack and break_stack[-1].name == tag_name:
                      break_stack.pop()
                      tag.close(parser, start_pos, len(nodes))
                  elif check_tag_stack(tag_name):
                      while tag_stack[-1].name != tag_name:
                          tag = tag_stack.pop()
                          break_stack.append(tag)
                          close_tag(tag)
  
                      tag = tag_stack.pop()
                      tag.close(parser, start_pos, len(nodes))
                      if tag.enclosed:
                          enclosed_count -= 1
  
                      close_tag(tag)
                      if paragraphs and not tag.inline and not tag_stack:
                          nodes.append(u"</p><p>")
  
                      if not tag.inline:
                          remove_next_newline = True
          
          if tag_stack:            
              redo_break_stack()
              while tag_stack:
                  tag = tag_stack.pop()
                  tag.close(parser, len(post_markup), len(nodes))
                  if tag.enclosed:
                      enclosed_count -= 1
                  close_tag(tag)
          
          if paragraphs:
              nodes.append('</p>')
  
          parser.phase = 2
          # Pass 2
          parser.nodes = nodes
  
          text = []
          text_append = text.append
          parser.render_node_index = 0
          while parser.render_node_index < len(parser.nodes):
              i = parser.render_node_index
              node_text = parser.nodes[i]
              if callable(node_text):
                  node_text = node_text(i)
              if node_text is not None:
                  text_append(node_text)
              parser.render_node_index += 1
  
          html = u"".join(text)
          if clean:
              html = self.cleanup_html(html)        
          return html
code_tokens: def render_to_html ( self , post_markup , encoding = "ascii" , exclude_tags = None , auto_urls = True , paragraphs = False , clean = True , cosmetic_replace = True , render_unknown_tags = False , tag_data = None ) : if not isinstance ( post_markup , unicode ) : post_markup = unicode ( post_markup , encoding , u'replace' ) if auto_urls : post_markup = self . tagify_urls ( post_markup ) post_markup = post_markup . replace ( u'\r\n' , u'\n' ) if paragraphs : post_markup = _re_break_groups . sub ( u'\n\n' , post_markup ) parser = _Parser ( self , tag_data = tag_data ) parser . tag_data . setdefault ( u"output" , { } ) parser . markup = post_markup if exclude_tags is None : exclude_tags = [ ] tag_factory = self . tag_factory nodes = [ ] parser . nodes = nodes parser . phase = 1 parser . no_breaks_count = 0 enclosed_count = 0 tag_stack = [ ] break_stack = [ ] remove_next_newline = False def standard_replace ( s ) : s = self . standard_replace ( s ) if cosmetic_replace : s = _cosmetic_replace ( s ) return s def standard_replace_no_break ( s ) : s = self . standard_replace_no_break ( s ) if cosmetic_replace : s = _cosmetic_replace ( s ) return s def check_tag_stack ( tag_name ) : for tag in reversed ( tag_stack ) : if tag_name == tag . name : return True return False def redo_break_stack ( ) : while break_stack : tag = break_stack . pop ( ) open_tag ( tag ) tag_stack . append ( tag ) def break_inline_tags ( ) : while tag_stack : if tag_stack [ - 1 ] . inline : tag = tag_stack . pop ( ) close_tag ( tag ) break_stack . append ( tag ) else : break def open_tag ( tag ) : def call ( node_index ) : return tag . render_open ( parser , node_index ) nodes . append ( call ) def close_tag ( tag ) : def call ( node_index ) : return tag . render_close ( parser , node_index ) nodes . append ( call ) TOKEN_TEXT = PostMarkup . TOKEN_TEXT if paragraphs : nodes . append ( u"<p>" ) for tag_type , tag_token , start_pos , end_pos in self . tokenize ( post_markup ) : if tag_type == TOKEN_TEXT : if parser . no_breaks_count : tag_token = tag_token . rstrip ( ) if not tag_token . strip ( ) : continue if remove_next_newline : tag_token = tag_token . lstrip ( u' ' ) if tag_token . startswith ( u'\n' ) : tag_token = tag_token . lstrip ( u' ' ) [ 1 : ] if not tag_token : continue remove_next_newline = False if tag_stack and tag_stack [ - 1 ] . strip_first_newline : tag_token = tag_token . lstrip ( ) tag_stack [ - 1 ] . strip_first_newline = False if not tag_stack [ - 1 ] : tag_stack . pop ( ) continue if not enclosed_count : redo_break_stack ( ) if paragraphs : if not tag_stack : while u'\n\n' in tag_token : text , tag_token = tag_token . split ( u'\n\n' , 1 ) if text . strip ( ) : nodes . append ( standard_replace ( text ) ) nodes . append ( u"</p><p>" ) nodes . append ( standard_replace ( tag_token ) ) continue tag_name , tag_attribs , end_tag = self . parse_tag_token ( tag_token ) if tag_stack : tag_stack [ - 1 ] . strip_first_newline = False if enclosed_count and tag_stack [ - 1 ] . name != tag_name : continue if tag_name in exclude_tags : continue if not end_tag : tag = tag_factory . get ( tag_name , None ) if tag is None and render_unknown_tags : tag = tag_factory . default_tag ( tag_name ) if tag is None : continue redo_break_stack ( ) if not tag . inline : break_inline_tags ( ) tag . open ( parser , tag_attribs , end_pos , len ( nodes ) , start_pos ) if tag . enclosed : enclosed_count += 1 tag_stack . append ( tag ) open_tag ( tag ) if tag . auto_close : tag = tag_stack . pop ( ) tag . close ( self , end_pos , len ( nodes ) - 1 ) close_tag ( tag ) else : if break_stack and break_stack [ - 1 ] . name == tag_name : break_stack . pop ( ) tag . close ( parser , start_pos , len ( nodes ) ) elif check_tag_stack ( tag_name ) : while tag_stack [ - 1 ] . name != tag_name : tag = tag_stack . pop ( ) break_stack . append ( tag ) close_tag ( tag ) tag = tag_stack . pop ( ) tag . close ( parser , start_pos , len ( nodes ) ) if tag . enclosed : enclosed_count -= 1 close_tag ( tag ) if paragraphs and not tag . inline and not tag_stack : nodes . append ( u"</p><p>" ) if not tag . inline : remove_next_newline = True if tag_stack : redo_break_stack ( ) while tag_stack : tag = tag_stack . pop ( ) tag . close ( parser , len ( post_markup ) , len ( nodes ) ) if tag . enclosed : enclosed_count -= 1 close_tag ( tag ) if paragraphs : nodes . append ( '</p>' ) parser . phase = 2 parser . nodes = nodes text = [ ] text_append = text . append parser . render_node_index = 0 while parser . render_node_index < len ( parser . nodes ) : i = parser . render_node_index node_text = parser . nodes [ i ] if callable ( node_text ) : node_text = node_text ( i ) if node_text is not None : text_append ( node_text ) parser . render_node_index += 1 html = u"" . join ( text ) if clean : html = self . cleanup_html ( html ) return html
short_docstring: Converts post markup (ie.
short_docstring_tokens: Converts post markup ( ie .
comment: """Converts post markup (ie. bbcode) to XHTML. This method is threadsafe,
          buy virtue that the state is entirely stored on the stack.
  
          post_markup -- String containing bbcode.
          encoding -- Encoding of string, defaults to "ascii" if the string is not
          already unicode.
          exclude_tags -- A collection of tag names to ignore.
          auto_urls -- If True, then urls will be wrapped with url bbcode tags.
          paragraphs -- If True then line breaks will be replaced with paragraph
          tags, rather than break tags.
          clean -- If True, html will be run through the cleanup_html method.
          cosmetic_replace -- If True, then some 'smart' quotes will be enabled,
          in addition to replacing some character sequences with html entities.
          tag_data -- An optional dictionary to store tag data in. The default of
          None will create a dictionary internaly. Set this to your own dictionary
          if you want to retrieve information from the Tag Classes.
  
  
          """$SEP$# Pass 1$SEP$# Pass 2