parameters: (n=5, html=True, min=20, max=100)
return_statement: return Markup(u'\n'.join(u'<p>%s</p>' % escape(x) for x in result))
docstring: Generate some lorem impsum for the template.
docstring_summary: Generate some lorem impsum for the template.
docstring_tokens: Generate some lorem impsum for the template .
function: def generate_lorem_ipsum(n=5, html=True, min=20, max=100):
      """Generate some lorem impsum for the template."""
      from jinja2.constants import LOREM_IPSUM_WORDS
      from random import choice, randrange
      words = LOREM_IPSUM_WORDS.split()
      result = []
  
      for _ in range(n):
          next_capitalized = True
          last_comma = last_fullstop = 0
          word = None
          last = None
          p = []
  
          # each paragraph contains out of 20 to 100 words.
          for idx, _ in enumerate(range(randrange(min, max))):
              while True:
                  word = choice(words)
                  if word != last:
                      last = word
                      break
              if next_capitalized:
                  word = word.capitalize()
                  next_capitalized = False
              # add commas
              if idx - randrange(3, 8) > last_comma:
                  last_comma = idx
                  last_fullstop += 2
                  word += ','
              # add end of sentences
              if idx - randrange(10, 20) > last_fullstop:
                  last_comma = last_fullstop = idx
                  word += '.'
                  next_capitalized = True
              p.append(word)
  
          # ensure that the paragraph ends with a dot.
          p = u' '.join(p)
          if p.endswith(','):
              p = p[:-1] + '.'
          elif not p.endswith('.'):
              p += '.'
          result.append(p)
  
      if not html:
          return u'\n\n'.join(result)
      return Markup(u'\n'.join(u'<p>%s</p>' % escape(x) for x in result))
function_tokens: def generate_lorem_ipsum ( n = 5 , html = True , min = 20 , max = 100 ) : from jinja2 . constants import LOREM_IPSUM_WORDS from random import choice , randrange words = LOREM_IPSUM_WORDS . split ( ) result = [ ] for _ in range ( n ) : next_capitalized = True last_comma = last_fullstop = 0 word = None last = None p = [ ] # each paragraph contains out of 20 to 100 words. for idx , _ in enumerate ( range ( randrange ( min , max ) ) ) : while True : word = choice ( words ) if word != last : last = word break if next_capitalized : word = word . capitalize ( ) next_capitalized = False # add commas if idx - randrange ( 3 , 8 ) > last_comma : last_comma = idx last_fullstop += 2 word += ',' # add end of sentences if idx - randrange ( 10 , 20 ) > last_fullstop : last_comma = last_fullstop = idx word += '.' next_capitalized = True p . append ( word ) # ensure that the paragraph ends with a dot. p = u' ' . join ( p ) if p . endswith ( ',' ) : p = p [ : - 1 ] + '.' elif not p . endswith ( '.' ) : p += '.' result . append ( p ) if not html : return u'\n\n' . join ( result ) return Markup ( u'\n' . join ( u'<p>%s</p>' % escape ( x ) for x in result ) )