Sync with trunk
This commit is contained in:
commit
1cc2043cf6
|
@ -13,10 +13,25 @@
|
|||
%
|
||||
% Unresolved issues:
|
||||
%
|
||||
% \binom{}{}
|
||||
%
|
||||
% \righttoleftarrow
|
||||
% \lefttorightarrow
|
||||
%
|
||||
% \color{} with HTML colorspec
|
||||
% \bgcolor
|
||||
% \array
|
||||
|
||||
% Of the standard HTML named colors, white, black, red, green, blue and yellow
|
||||
% are predefined in the color package. Here are the rest.
|
||||
\definecolor{aqua}{rgb}{0, 1.0, 1.0}
|
||||
\definecolor{fuschia}{rgb}{1.0, 0, 1.0}
|
||||
\definecolor{gray}{rgb}{0.502, 0.502, 0.502}
|
||||
\definecolor{lime}{rgb}{0, 1.0, 0}
|
||||
\definecolor{maroon}{rgb}{0.502, 0, 0}
|
||||
\definecolor{navy}{rgb}{0, 0, 0.502}
|
||||
\definecolor{olive}{rgb}{0.502, 0.502, 0}
|
||||
\definecolor{purple}{rgb}{0.502, 0, 0.502}
|
||||
\definecolor{silver}{rgb}{0.753, 0.753, 0.753}
|
||||
\definecolor{teal}{rgb}{0, 0.502, 0.502}
|
||||
|
||||
% Because of conflicts, \space and \mathop are converted to
|
||||
% \itexspace and \operatorname during preprocessing.
|
||||
|
@ -175,6 +190,8 @@
|
|||
\renewcommand{\scriptsize}{\scriptstyle}
|
||||
\newcommand{\scriptscriptsize}{\scriptscriptstyle}
|
||||
\newcommand{\mathfr}{\mathfrak}
|
||||
\newcommand{\statusline}[2]{#2}
|
||||
\newcommand{\toggle}[2]{#1}
|
||||
|
||||
%-------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ class AbstractUrlGenerator
|
|||
else
|
||||
known_page = web.has_file?(name)
|
||||
description = web.description(name)
|
||||
description = CGI.escapeHTML(CGI.unescapeHTML(description)) if description
|
||||
end
|
||||
if (text == name)
|
||||
text = description || text
|
||||
|
@ -29,7 +30,7 @@ class AbstractUrlGenerator
|
|||
when :show
|
||||
page_link(mode, name, text, web.address, known_page)
|
||||
when :file
|
||||
file_link(mode, name, text, web.address, known_page)
|
||||
file_link(mode, name, text, web.address, known_page, description)
|
||||
when :pic
|
||||
pic_link(mode, name, text, web.address, known_page)
|
||||
else
|
||||
|
@ -43,11 +44,11 @@ class UrlGenerator < AbstractUrlGenerator
|
|||
|
||||
private
|
||||
|
||||
def file_link(mode, name, text, web_address, known_file)
|
||||
def file_link(mode, name, text, web_address, known_file, description)
|
||||
case mode
|
||||
when :export
|
||||
if known_file
|
||||
%{<a class="existingWikiWord" title="#{text}" href="#{CGI.escape(name)}.html">#{text}</a>}
|
||||
%{<a class="existingWikiWord" title="#{description}" href="#{CGI.escape(name)}.html">#{text}</a>}
|
||||
else
|
||||
%{<span class="newWikiWord">#{text}</span>}
|
||||
end
|
||||
|
@ -55,7 +56,7 @@ class UrlGenerator < AbstractUrlGenerator
|
|||
if known_file
|
||||
href = @controller.url_for :controller => 'file', :web => web_address, :action => 'file',
|
||||
:id => name
|
||||
%{<a class="existingWikiWord" title="#{text}" href="#{href}">#{text}</a>}
|
||||
%{<a class="existingWikiWord" title="#{description}" href="#{href}">#{text}</a>}
|
||||
else
|
||||
%{<span class="newWikiWord">#{text}</span>}
|
||||
end
|
||||
|
@ -63,7 +64,7 @@ class UrlGenerator < AbstractUrlGenerator
|
|||
href = @controller.url_for :controller => 'file', :web => web_address, :action => 'file',
|
||||
:id => name
|
||||
if known_file
|
||||
%{<a class="existingWikiWord" title="#{text}" href="#{href}">#{text}</a>}
|
||||
%{<a class="existingWikiWord" title="#{description}" href="#{href}">#{text}</a>}
|
||||
else
|
||||
%{<span class="newWikiWord">#{text}<a href="#{href}">?</a></span>}
|
||||
end
|
||||
|
|
|
@ -102,18 +102,18 @@ class StubUrlGenerator < AbstractUrlGenerator
|
|||
super(:doesnt_need_controller)
|
||||
end
|
||||
|
||||
def file_link(mode, name, text, web_name, known_file)
|
||||
def file_link(mode, name, text, web_name, known_file, description)
|
||||
link = CGI.escape(name)
|
||||
case mode
|
||||
when :export
|
||||
if known_file then %{<a class="existingWikiWord" title="#{title}" href="#{link}.html">#{text}</a>}
|
||||
if known_file then %{<a class="existingWikiWord" title="#{description}" href="#{link}.html">#{text}</a>}
|
||||
else %{<span class="newWikiWord">#{text}</span>} end
|
||||
when :publish
|
||||
if known_file then %{<a class="existingWikiWord" title="#{title}" href="../published/#{link}">#{text}</a>}
|
||||
if known_file then %{<a class="existingWikiWord" title="#{description}" href="../published/#{link}">#{text}</a>}
|
||||
else %{<span class=\"newWikiWord\">#{text}</span>} end
|
||||
else
|
||||
if known_file
|
||||
%{<a class=\"existingWikiWord\" title="#{title}" href=\"../file/#{link}\">#{text}</a>}
|
||||
%{<a class=\"existingWikiWord\" title="#{description}" href=\"../file/#{link}\">#{text}</a>}
|
||||
else
|
||||
%{<span class=\"newWikiWord\">#{text}<a href=\"../file/#{link}\">?</a></span>}
|
||||
end
|
||||
|
|
|
@ -299,7 +299,7 @@ class PageRendererTest < Test::Unit::TestCase
|
|||
'[[doc.pdf:file]]')
|
||||
end
|
||||
|
||||
def test_link_to_pic
|
||||
def test_link_to_pic_and_file
|
||||
WikiFile.delete_all
|
||||
require 'fileutils'
|
||||
FileUtils.rm_rf("#{RAILS_ROOT}/public/wiki1/files/*")
|
||||
|
@ -310,6 +310,31 @@ class PageRendererTest < Test::Unit::TestCase
|
|||
assert_markup_parsed_as(
|
||||
'<p><img alt="Square" src="../file/square.jpg" /></p>',
|
||||
'[[square.jpg:pic]]')
|
||||
assert_markup_parsed_as(
|
||||
'<p><a class="existingWikiWord" title="Square" href="../file/square.jpg">Blue Square</a></p>',
|
||||
'[[square.jpg|Blue Square:file]]')
|
||||
assert_markup_parsed_as(
|
||||
'<p><a class="existingWikiWord" title="Square" href="../file/square.jpg">Square</a></p>',
|
||||
'[[square.jpg:file]]')
|
||||
end
|
||||
|
||||
def test_link_to_pic_and_file_null_desc
|
||||
WikiFile.delete_all
|
||||
require 'fileutils'
|
||||
FileUtils.rm_rf("#{RAILS_ROOT}/public/wiki1/files/*")
|
||||
@web.wiki_files.create(:file_name => 'square.jpg', :description => '', :content => 'never mind')
|
||||
assert_markup_parsed_as(
|
||||
'<p><img alt="Blue Square" src="../file/square.jpg" /></p>',
|
||||
'[[square.jpg|Blue Square:pic]]')
|
||||
assert_markup_parsed_as(
|
||||
'<p><img alt="" src="../file/square.jpg" /></p>',
|
||||
'[[square.jpg:pic]]')
|
||||
assert_markup_parsed_as(
|
||||
'<p><a class="existingWikiWord" title="" href="../file/square.jpg">Blue Square</a></p>',
|
||||
'[[square.jpg|Blue Square:file]]')
|
||||
assert_markup_parsed_as(
|
||||
'<p><a class="existingWikiWord" title="" href="../file/square.jpg"></a></p>',
|
||||
'[[square.jpg:file]]')
|
||||
end
|
||||
|
||||
def test_link_to_non_existant_pic
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
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
|
||||
# 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
|
||||
|
|
|
@ -14,8 +14,8 @@ module MaRuKu; module Out; module HTML
|
|||
doc = Document.new(mathml, {:respect_whitespace =>:all}).root
|
||||
return doc
|
||||
rescue LoadError => e
|
||||
maruku_error "Could not load package 'itex2mml'.\n"+
|
||||
"Please install it."
|
||||
maruku_error "Could not load package 'itex2mml'.\n"+ "Please install it." unless $already_warned_itex2mml
|
||||
$already_warned_itex2mml = true
|
||||
rescue REXML::ParseException => e
|
||||
maruku_error "Invalid MathML TeX: \n#{add_tabs(tex,1,'tex>')}"+
|
||||
"\n\n #{e.inspect}"
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
module MaRuKu; module Out; module Latex
|
||||
|
||||
require 'maruku/ext/math/latex_fix'
|
||||
|
||||
module MaRuKu; module Out; module Latex
|
||||
|
||||
def to_latex_inline_math
|
||||
s = "$#{self.math.strip}$".fix_latex
|
||||
"$#{self.math.strip}$".fix_latex
|
||||
end
|
||||
|
||||
def to_latex_equation
|
||||
|
|
|
@ -173,6 +173,7 @@ Disabled by default because of security concerns.
|
|||
self.abbreviations.each do |abbrev, title|
|
||||
reg = Regexp.new(Regexp.escape(abbrev))
|
||||
self.replace_each_string do |s|
|
||||
# bug if many abbreviations are present (agorf)
|
||||
if m = reg.match(s)
|
||||
e = md_abbr(abbrev.dup, title ? title.dup : nil)
|
||||
[m.pre_match, e, m.post_match]
|
||||
|
|
|
@ -18,9 +18,16 @@
|
|||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#++
|
||||
|
||||
|
||||
require 'rexml/document'
|
||||
|
||||
begin
|
||||
require 'rexml/formatters/pretty'
|
||||
require 'rexml/formatters/default'
|
||||
$rexml_new_version = true
|
||||
rescue LoadError
|
||||
$rexml_new_version = false
|
||||
end
|
||||
|
||||
class String
|
||||
# A string is rendered into HTML by creating
|
||||
# a REXML::Text node. REXML takes care of all the encoding.
|
||||
|
@ -30,11 +37,6 @@ class String
|
|||
end
|
||||
|
||||
|
||||
class REXML::Element
|
||||
# We only want to output the children in Maruku::to_html
|
||||
public :write_children
|
||||
end
|
||||
|
||||
# This module groups all functions related to HTML export.
|
||||
module MaRuKu; module Out; module HTML
|
||||
include REXML
|
||||
|
@ -42,7 +44,7 @@ module MaRuKu; module Out; module HTML
|
|||
# Render as an HTML fragment (no head, just the content of BODY). (returns a string)
|
||||
def to_html(context={})
|
||||
indent = context[:indent] || -1
|
||||
ie_hack = context[:ie_hack] ||true
|
||||
ie_hack = context[:ie_hack] || true
|
||||
|
||||
div = Element.new 'dummy'
|
||||
children_to_html.each do |e|
|
||||
|
@ -60,7 +62,21 @@ module MaRuKu; module Out; module HTML
|
|||
# REXML Bug? if indent!=-1 whitespace is not respected for 'pre' elements
|
||||
# containing code.
|
||||
xml =""
|
||||
div.write_children(xml,indent,transitive=true,ie_hack)
|
||||
|
||||
if $rexml_new_version
|
||||
formatter = if indent > -1
|
||||
REXML::Formatters::Pretty.new( indent, ie_hack )
|
||||
else
|
||||
REXML::Formatters::Default.new( ie_hack )
|
||||
end
|
||||
formatter.write( div, xml)
|
||||
else
|
||||
div.write(xml,indent,transitive=true,ie_hack)
|
||||
end
|
||||
|
||||
xml.gsub!(/\A<dummy>\s*/,'')
|
||||
xml.gsub!(/\s*<\/dummy>\Z/,'')
|
||||
xml.gsub!(/\A<dummy\s*\/>/,'')
|
||||
xml
|
||||
end
|
||||
|
||||
|
@ -141,6 +157,23 @@ Synonim for `title`.
|
|||
=end
|
||||
|
||||
|
||||
# Render to an HTML fragment (returns a REXML document tree)
|
||||
def to_html_tree
|
||||
div = Element.new 'div'
|
||||
div.attributes['class'] = 'maruku_wrapper_div'
|
||||
children_to_html.each do |e|
|
||||
div << e
|
||||
end
|
||||
|
||||
# render footnotes
|
||||
if @doc.footnotes_order.size > 0
|
||||
div << render_footnotes
|
||||
end
|
||||
|
||||
doc = Document.new(nil,{:respect_whitespace =>:all})
|
||||
doc << div
|
||||
end
|
||||
|
||||
=begin maruku_doc
|
||||
Attribute: css
|
||||
Scope: document
|
||||
|
@ -150,26 +183,11 @@ Summary: Activates CSS stylesheets for HTML.
|
|||
`css` should be a space-separated list of urls.
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
CSS: style.css math.css
|
||||
|
||||
=end
|
||||
# Render to an HTML fragment (returns a REXML document tree)
|
||||
def to_html_tree
|
||||
div = Element.new 'div'
|
||||
div.attributes['class'] = 'maruku_wrapper_div'
|
||||
children_to_html.each do |e|
|
||||
div << e
|
||||
end
|
||||
|
||||
# render footnotes
|
||||
if @doc.footnotes_order.size > 0
|
||||
div << render_footnotes
|
||||
end
|
||||
|
||||
doc = Document.new(nil,{:respect_whitespace =>:all})
|
||||
doc << div
|
||||
end
|
||||
|
||||
# Render to a complete HTML document (returns a REXML document tree)
|
||||
def to_html_document_tree
|
||||
|
@ -465,7 +483,7 @@ by Maruku, to have the same results in both HTML and LaTeX.
|
|||
end
|
||||
|
||||
def source2html(source)
|
||||
source = source.gsub(/&/,'&')
|
||||
# source = source.gsub(/&/,'&')
|
||||
source = Text.normalize(source)
|
||||
source = source.gsub(/\'/,''') # IE bug
|
||||
source = source.gsub(/'/,''') # IE bug
|
||||
|
@ -591,7 +609,7 @@ of the form `#ff00ff`.
|
|||
code = Element.new 'code', pre
|
||||
s = source
|
||||
|
||||
s = s.gsub(/&/,'&')
|
||||
# s = s.gsub(/&/,'&')
|
||||
s = Text.normalize(s)
|
||||
s = s.gsub(/\'/,''') # IE bug
|
||||
s = s.gsub(/'/,''') # IE bug
|
||||
|
@ -892,7 +910,7 @@ If true, raw HTML is discarded from the output.
|
|||
# Entity.new(entity_name)
|
||||
Text.new('&#%d;' % [entity_name], false, nil, true)
|
||||
else
|
||||
Text.new('&%s;' % [entity_name])
|
||||
Text.new('&%s;' % [entity_name], false, nil, true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
2
vendor/plugins/maruku/lib/maruku/version.rb
vendored
2
vendor/plugins/maruku/lib/maruku/version.rb
vendored
|
@ -19,7 +19,7 @@
|
|||
#++
|
||||
|
||||
module MaRuKu
|
||||
Version = '0.5.6'
|
||||
Version = '0.5.7'
|
||||
|
||||
MarukuURL = 'http://maruku.rubyforge.org/'
|
||||
|
||||
|
|
Loading…
Reference in a new issue