components/policy/tools/template_writers/writers/doc_writer.py
def _AddTextWithLinks(self, parent, text):
    '''Parse a string for URLs and add it to a DOM node with the URLs replaced
    with <a> HTML links.

    Args:
      parent: The DOM node to which the text will be added.
      text: The string to be added.
    '''
    # A simple regexp to search for URLs. It is enough for now.
    url_matcher = re.compile('(https?://[^\\s]*[^\\s\\.\\)\\"])')

    # Iterate through all the URLs and replace them with links.
    while True:
      # Look for the first URL.
      res = url_matcher.search(text)
      if not res:
        break
      # Calculate positions of the substring of the URL.
      url = res.group(0)
      start = res.start(0)
      end = res.end(0)
      # Add the text prior to the URL.
      self.AddText(parent, text[:start])
      # Add a link for the URL.
      self.AddElement(parent, 'a', {'href': url}, url)
      # Drop the part of text that is added.
      text = text[end:]
    self.AddText(parent, text)
Parse a string for URLs and add it to a DOM node with the URLs replaced
    with <a> HTML links.

    Args:
      parent: The DOM node to which the text will be added.
      text: The string to be added.
    
Parse a string for URLs and add it to a DOM node with the URLs replaced
with  HTML links.
Parse a string for URLs and add it to a DOM node with the URLs replaced with HTML links .
def _AddTextWithLinks(self, parent, text):
    url_matcher = re.compile('(https?://[^\\s]*[^\\s\\.\\)\\"])')
    while True:
      res = url_matcher.search(text)
      if not res:
        break
      url = res.group(0)
      start = res.start(0)
      end = res.end(0)
      self.AddText(parent, text[:start])
      self.AddElement(parent, 'a', {'href': url}, url)
      text = text[end:]
    self.AddText(parent, text)
def _AddTextWithLinks ( self , parent , text ) : url_matcher = re . compile ( '(https?://[^\\s]*[^\\s\\.\\)\\"])' ) while True : res = url_matcher . search ( text ) if not res : break url = res . group ( 0 ) start = res . start ( 0 ) end = res . end ( 0 ) self . AddText ( parent , text [ : start ] ) self . AddElement ( parent , 'a' , { 'href' : url } , url ) text = text [ end : ] self . AddText ( parent , text )
Parse a string for URLs and add it to a DOM node with the URLs replaced
with <a> HTML links.
Parse a string for URLs and add it to a DOM node with the URLs replaced with <a > HTML links .
'''Parse a string for URLs and add it to a DOM node with the URLs replaced
    with <a> HTML links.

    Args:
      parent: The DOM node to which the text will be added.
      text: The string to be added.
    ''' # A simple regexp to search for URLs. It is enough for now. # Iterate through all the URLs and replace them with links. # Look for the first URL. # Calculate positions of the substring of the URL. # Add the text prior to the URL. # Add a link for the URL. # Drop the part of text that is added.
self
parent
The DOM node to which the text will be added.
The DOM node to which the text will be added .
text
The string to be added.
The string to be added .