module ApplicationHelper
  def application_reference_date
    @application_reference_date ||=
      if Doubtfire::Application.config.respond_to?(:application_reference_date)
        Time.zone.parse(Doubtfire::Application.config.reference_date)
      else
        Time.zone.now
      end
  end

  # Escape text for inclusion in Latex documents
  def lesc(text)
    # Use gsub to remove any characters that are not printable
    LatexToPdf.escape_latex(text.gsub(/[^[:print:]]/,''))
  end
end

module ApplicationHelper
  def application_reference_date
    @application_reference_date ||=
      if Doubtfire::Application.config.respond_to?(:application_reference_date)
        Time.zone.parse(Doubtfire::Application.config.reference_date)
      else
        Time.zone.now
      end
  end

  # Escape text for inclusion in Latex documents
  def lesc(text)
    # Convert to latex text, then use gsub to remove any characters that are not printable
    LatexToPdf.escape_latex(text).gsub(/[^[:print:]]/,'')
  end
end

Switch gsub in lesc to ensure running on text
FIX: Switch gsub in lesc to ensure running on text
