from django import template
from django.utils.safestring import mark_safe
from django.utils.html import escape


register = template.Library()

def highlight_request(message):
    content = message.get_content()
    description = message.request.description
    try:
        index = content.index(description)
    except ValueError:
        return content
    offset = index + len(description)
    return mark_safe('%s<div class="highlight">%s</div>%s' % (escape(content[:index]),
            escape(description), escape(content[offset:])))

register.simple_tag(highlight_request)

from django import template
from django.utils.safestring import mark_safe
from django.utils.html import escape


register = template.Library()

def highlight_request(message):
    content = message.get_content()
    description = message.request.description
    description = description.replace("\r\n", "\n")
    try:
        index = content.index(description)
    except ValueError:
        return content
    offset = index + len(description)
    return mark_safe('%s<div class="highlight">%s</div>%s' % (escape(content[:index]),
            escape(description), escape(content[offset:])))

register.simple_tag(highlight_request)

Replace uni linebreaks with simple linefeeds in order to make highlighting work
Replace uni linebreaks with simple linefeeds in order to make highlighting work
  from django import template
  from django.utils.safestring import mark_safe
  from django.utils.html import escape
  
  
  register = template.Library()
  
  def highlight_request(message):
      content = message.get_content()
      description = message.request.description
+     description = description.replace("\r\n", "\n")
      try:
          index = content.index(description)
      except ValueError:
          return content
      offset = index + len(description)
      return mark_safe('%s<div class="highlight">%s</div>%s' % (escape(content[:index]),
              escape(description), escape(content[offset:])))
  
  register.simple_tag(highlight_request)
  
Replace uni linebreaks with simple linefeeds in order to make highlighting work
## Code Before:
from django import template
from django.utils.safestring import mark_safe
from django.utils.html import escape


register = template.Library()

def highlight_request(message):
    content = message.get_content()
    description = message.request.description
    try:
        index = content.index(description)
    except ValueError:
        return content
    offset = index + len(description)
    return mark_safe('%s<div class="highlight">%s</div>%s' % (escape(content[:index]),
            escape(description), escape(content[offset:])))

register.simple_tag(highlight_request)

## Instruction:
Replace uni linebreaks with simple linefeeds in order to make highlighting work
## Code After:
from django import template
from django.utils.safestring import mark_safe
from django.utils.html import escape


register = template.Library()

def highlight_request(message):
    content = message.get_content()
    description = message.request.description
    description = description.replace("\r\n", "\n")
    try:
        index = content.index(description)
    except ValueError:
        return content
    offset = index + len(description)
    return mark_safe('%s<div class="highlight">%s</div>%s' % (escape(content[:index]),
            escape(description), escape(content[offset:])))

register.simple_tag(highlight_request)
