Start on LaTeX

Pave the way for Jason's LaTeX macro support.
Also, uniformize the capitalization of "ETag".
This commit is contained in:
Jacques Distler 2007-10-04 02:50:08 -05:00
parent b0e316e37c
commit c67382d340
3 changed files with 21 additions and 8 deletions

View file

@ -135,7 +135,7 @@ module ActionController
controller.response.headers['Cache-Control'] == 'no-cache'
controller.response.headers['Cache-Control'] = "max-age=#{controller.response.time_to_live}"
end
controller.response.headers['Etag'] = %{"#{MD5.new(controller.response.body).to_s}"}
controller.response.headers['ETag'] = %{"#{MD5.new(controller.response.body).to_s}"}
controller.response.headers['Last-Modified'] ||= Time.now.httpdate
end
@ -148,13 +148,13 @@ module ActionController
def send_not_modified(controller)
controller.logger.info "Send Not Modified"
controller.response.headers['Etag'] = %{"#{MD5.new(fragment_body(controller)).to_s}"}
controller.response.headers['ETag'] = %{"#{MD5.new(fragment_body(controller)).to_s}"}
controller.render(:text => "", :status => 304)
end
def client_has_latest?(cache_entry, controller)
requestEtag = controller.request.env['HTTP_IF_NONE_MATCH'] rescue nil
responseEtag = cache_entry.headers['Etag'] rescue nil
responseEtag = cache_entry.headers['ETag'] rescue nil
return true if (requestEtag and responseEtag and requestEtag == responseEtag)
requestTime = Time.rfc2822(controller.request.env["HTTP_IF_MODIFIED_SINCE"]) rescue nil
responseTime = Time.rfc2822(cache_entry.headers['Last-Modified']) rescue nil

View file

@ -0,0 +1,12 @@
class String
# fix some LaTeX command-name clashes
def fix_latex
if #{html_math_engine} == 'itex2mml'
s = self.gsub("\\mathop{", "\\operatorname{")
s.gsub("\\space{", "\\itexspace{")
else
self
end
end
end

View file

@ -1,16 +1,17 @@
module MaRuKu; module Out; module Latex
require 'maruku/ext/math/latex_fix'
def to_latex_inline_math
"$#{self.math.strip}$"
s = "$#{self.math.strip}$".fix_latex
end
def to_latex_equation
if self.label
l = "\\label{#{self.label}}"
"\\begin{equation}\n#{self.math.strip}\n#{l}\\end{equation}\n"
"\\begin{equation}\n#{self.math.strip}\n#{l}\\end{equation}\n".fix_latex
else
"\\begin{displaymath}\n#{self.math.strip}\n\\end{displaymath}\n"
"\\begin{displaymath}\n#{self.math.strip}\n\\end{displaymath}\n".fix_latex
end
end