from jinja2._compat import text_type
import re

def do_right(value, width=80):
    """Right-justifies the value in a field of a given width."""
    return text_type(value).rjust(width)

_LATEX_SUBS = (
    (re.compile(r'\\'), r'\\textbackslash'),
    (re.compile(r'([{}_#%&$])'), r'\\\1'),
    (re.compile(r'~'), r'\~{}'),
    (re.compile(r'\^'), r'\^{}'),
    (re.compile(r'"'), r"''"),
    (re.compile(r'\.\.\.+'), r'\\ldots'),
    (re.compile(r'&'), r'&'),
    (re.compile(r'LaTeX'), r'\\LaTeX')
)

def escape_tex(value):
    """
    Escapes TeX characters to avoid breaking {La,Lua,Xe}Tex compilers.

    Kang'd (with permission!) from http://flask.pocoo.org/snippets/55/
    """
    newval = value
    for pattern, replacement in _LATEX_SUBS:
        newval = pattern.sub(replacement, newval)
    return newval

from jinja2._compat import text_type
import re

def do_right(value, width=80):
    """Right-justifies the value in a field of a given width."""
    return text_type(value).rjust(width)

_LATEX_SUBS = (
    (re.compile(r'\\'), r'\\textbackslash'),
    (re.compile(r'([{}_#%&$])'), r'\\\1'),
    (re.compile(r'~'), r'\~{}'),
    (re.compile(r'\^'), r'\^{}'),
    (re.compile(r'"'), r"''"),
    (re.compile(r'\.\.\.+'), r'\\ldots'),
    (re.compile(r'&'), r'&'),
    (re.compile(r'LaTeX'), r'\\textrm{\\LaTeX}')
)

def escape_tex(value):
    """
    Escapes TeX characters to avoid breaking {La,Lua,Xe}Tex compilers.

    Kang'd (with permission!) from http://flask.pocoo.org/snippets/55/
    """
    newval = value
    for pattern, replacement in _LATEX_SUBS:
        newval = pattern.sub(replacement, newval)
    return newval

Use Computer Modern for \LaTeX macro
Use Computer Modern for \LaTeX macro

Source Sans pro (and most othe sans-serif fonts) render the LaTeX macro
pretty weirdly, so the classic Computer Modern should be okay here.  It
may wind up being an odd contrast in an otherwise sans-serif document
though, so this may eventually get reverted!

  from jinja2._compat import text_type
  import re
  
  def do_right(value, width=80):
      """Right-justifies the value in a field of a given width."""
      return text_type(value).rjust(width)
  
  _LATEX_SUBS = (
      (re.compile(r'\\'), r'\\textbackslash'),
      (re.compile(r'([{}_#%&$])'), r'\\\1'),
      (re.compile(r'~'), r'\~{}'),
      (re.compile(r'\^'), r'\^{}'),
      (re.compile(r'"'), r"''"),
      (re.compile(r'\.\.\.+'), r'\\ldots'),
      (re.compile(r'&'), r'&'),
-     (re.compile(r'LaTeX'), r'\\LaTeX')
+     (re.compile(r'LaTeX'), r'\\textrm{\\LaTeX}')
  )
  
  def escape_tex(value):
      """
      Escapes TeX characters to avoid breaking {La,Lua,Xe}Tex compilers.
  
      Kang'd (with permission!) from http://flask.pocoo.org/snippets/55/
      """
      newval = value
      for pattern, replacement in _LATEX_SUBS:
          newval = pattern.sub(replacement, newval)
      return newval
  
Use Computer Modern for \LaTeX macro
## Code Before:
from jinja2._compat import text_type
import re

def do_right(value, width=80):
    """Right-justifies the value in a field of a given width."""
    return text_type(value).rjust(width)

_LATEX_SUBS = (
    (re.compile(r'\\'), r'\\textbackslash'),
    (re.compile(r'([{}_#%&$])'), r'\\\1'),
    (re.compile(r'~'), r'\~{}'),
    (re.compile(r'\^'), r'\^{}'),
    (re.compile(r'"'), r"''"),
    (re.compile(r'\.\.\.+'), r'\\ldots'),
    (re.compile(r'&'), r'&'),
    (re.compile(r'LaTeX'), r'\\LaTeX')
)

def escape_tex(value):
    """
    Escapes TeX characters to avoid breaking {La,Lua,Xe}Tex compilers.

    Kang'd (with permission!) from http://flask.pocoo.org/snippets/55/
    """
    newval = value
    for pattern, replacement in _LATEX_SUBS:
        newval = pattern.sub(replacement, newval)
    return newval

## Instruction:
Use Computer Modern for \LaTeX macro
## Code After:
from jinja2._compat import text_type
import re

def do_right(value, width=80):
    """Right-justifies the value in a field of a given width."""
    return text_type(value).rjust(width)

_LATEX_SUBS = (
    (re.compile(r'\\'), r'\\textbackslash'),
    (re.compile(r'([{}_#%&$])'), r'\\\1'),
    (re.compile(r'~'), r'\~{}'),
    (re.compile(r'\^'), r'\^{}'),
    (re.compile(r'"'), r"''"),
    (re.compile(r'\.\.\.+'), r'\\ldots'),
    (re.compile(r'&'), r'&'),
    (re.compile(r'LaTeX'), r'\\textrm{\\LaTeX}')
)

def escape_tex(value):
    """
    Escapes TeX characters to avoid breaking {La,Lua,Xe}Tex compilers.

    Kang'd (with permission!) from http://flask.pocoo.org/snippets/55/
    """
    newval = value
    for pattern, replacement in _LATEX_SUBS:
        newval = pattern.sub(replacement, newval)
    return newval
