Sync with trunk
This commit is contained in:
commit
1cc2043cf6
|
@ -13,10 +13,25 @@
|
||||||
%
|
%
|
||||||
% Unresolved issues:
|
% Unresolved issues:
|
||||||
%
|
%
|
||||||
% \binom{}{}
|
|
||||||
%
|
|
||||||
% \righttoleftarrow
|
% \righttoleftarrow
|
||||||
% \lefttorightarrow
|
% \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
|
% Because of conflicts, \space and \mathop are converted to
|
||||||
% \itexspace and \operatorname during preprocessing.
|
% \itexspace and \operatorname during preprocessing.
|
||||||
|
@ -175,6 +190,8 @@
|
||||||
\renewcommand{\scriptsize}{\scriptstyle}
|
\renewcommand{\scriptsize}{\scriptstyle}
|
||||||
\newcommand{\scriptscriptsize}{\scriptscriptstyle}
|
\newcommand{\scriptscriptsize}{\scriptscriptstyle}
|
||||||
\newcommand{\mathfr}{\mathfrak}
|
\newcommand{\mathfr}{\mathfrak}
|
||||||
|
\newcommand{\statusline}[2]{#2}
|
||||||
|
\newcommand{\toggle}[2]{#1}
|
||||||
|
|
||||||
%-------------------------------------------------------------------
|
%-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ class AbstractUrlGenerator
|
||||||
else
|
else
|
||||||
known_page = web.has_file?(name)
|
known_page = web.has_file?(name)
|
||||||
description = web.description(name)
|
description = web.description(name)
|
||||||
|
description = CGI.escapeHTML(CGI.unescapeHTML(description)) if description
|
||||||
end
|
end
|
||||||
if (text == name)
|
if (text == name)
|
||||||
text = description || text
|
text = description || text
|
||||||
|
@ -29,7 +30,7 @@ class AbstractUrlGenerator
|
||||||
when :show
|
when :show
|
||||||
page_link(mode, name, text, web.address, known_page)
|
page_link(mode, name, text, web.address, known_page)
|
||||||
when :file
|
when :file
|
||||||
file_link(mode, name, text, web.address, known_page)
|
file_link(mode, name, text, web.address, known_page, description)
|
||||||
when :pic
|
when :pic
|
||||||
pic_link(mode, name, text, web.address, known_page)
|
pic_link(mode, name, text, web.address, known_page)
|
||||||
else
|
else
|
||||||
|
@ -43,11 +44,11 @@ class UrlGenerator < AbstractUrlGenerator
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def file_link(mode, name, text, web_address, known_file)
|
def file_link(mode, name, text, web_address, known_file, description)
|
||||||
case mode
|
case mode
|
||||||
when :export
|
when :export
|
||||||
if known_file
|
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
|
else
|
||||||
%{<span class="newWikiWord">#{text}</span>}
|
%{<span class="newWikiWord">#{text}</span>}
|
||||||
end
|
end
|
||||||
|
@ -55,7 +56,7 @@ class UrlGenerator < AbstractUrlGenerator
|
||||||
if known_file
|
if known_file
|
||||||
href = @controller.url_for :controller => 'file', :web => web_address, :action => 'file',
|
href = @controller.url_for :controller => 'file', :web => web_address, :action => 'file',
|
||||||
:id => name
|
:id => name
|
||||||
%{<a class="existingWikiWord" title="#{text}" href="#{href}">#{text}</a>}
|
%{<a class="existingWikiWord" title="#{description}" href="#{href}">#{text}</a>}
|
||||||
else
|
else
|
||||||
%{<span class="newWikiWord">#{text}</span>}
|
%{<span class="newWikiWord">#{text}</span>}
|
||||||
end
|
end
|
||||||
|
@ -63,7 +64,7 @@ class UrlGenerator < AbstractUrlGenerator
|
||||||
href = @controller.url_for :controller => 'file', :web => web_address, :action => 'file',
|
href = @controller.url_for :controller => 'file', :web => web_address, :action => 'file',
|
||||||
:id => name
|
:id => name
|
||||||
if known_file
|
if known_file
|
||||||
%{<a class="existingWikiWord" title="#{text}" href="#{href}">#{text}</a>}
|
%{<a class="existingWikiWord" title="#{description}" href="#{href}">#{text}</a>}
|
||||||
else
|
else
|
||||||
%{<span class="newWikiWord">#{text}<a href="#{href}">?</a></span>}
|
%{<span class="newWikiWord">#{text}<a href="#{href}">?</a></span>}
|
||||||
end
|
end
|
||||||
|
|
|
@ -102,18 +102,18 @@ class StubUrlGenerator < AbstractUrlGenerator
|
||||||
super(:doesnt_need_controller)
|
super(:doesnt_need_controller)
|
||||||
end
|
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)
|
link = CGI.escape(name)
|
||||||
case mode
|
case mode
|
||||||
when :export
|
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
|
else %{<span class="newWikiWord">#{text}</span>} end
|
||||||
when :publish
|
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 %{<span class=\"newWikiWord\">#{text}</span>} end
|
||||||
else
|
else
|
||||||
if known_file
|
if known_file
|
||||||
%{<a class=\"existingWikiWord\" title="#{title}" href=\"../file/#{link}\">#{text}</a>}
|
%{<a class=\"existingWikiWord\" title="#{description}" href=\"../file/#{link}\">#{text}</a>}
|
||||||
else
|
else
|
||||||
%{<span class=\"newWikiWord\">#{text}<a href=\"../file/#{link}\">?</a></span>}
|
%{<span class=\"newWikiWord\">#{text}<a href=\"../file/#{link}\">?</a></span>}
|
||||||
end
|
end
|
||||||
|
|
|
@ -299,7 +299,7 @@ class PageRendererTest < Test::Unit::TestCase
|
||||||
'[[doc.pdf:file]]')
|
'[[doc.pdf:file]]')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_link_to_pic
|
def test_link_to_pic_and_file
|
||||||
WikiFile.delete_all
|
WikiFile.delete_all
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
FileUtils.rm_rf("#{RAILS_ROOT}/public/wiki1/files/*")
|
FileUtils.rm_rf("#{RAILS_ROOT}/public/wiki1/files/*")
|
||||||
|
@ -310,6 +310,31 @@ class PageRendererTest < Test::Unit::TestCase
|
||||||
assert_markup_parsed_as(
|
assert_markup_parsed_as(
|
||||||
'<p><img alt="Square" src="../file/square.jpg" /></p>',
|
'<p><img alt="Square" src="../file/square.jpg" /></p>',
|
||||||
'[[square.jpg:pic]]')
|
'[[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
|
end
|
||||||
|
|
||||||
def test_link_to_non_existant_pic
|
def test_link_to_non_existant_pic
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
class String
|
class String
|
||||||
|
|
||||||
# fix some LaTeX command-name clashes
|
# fix some LaTeX command-name clashes
|
||||||
def fix_latex
|
def fix_latex
|
||||||
if #{html_math_engine} == 'itex2mml'
|
if #{html_math_engine} == 'itex2mml'
|
||||||
|
|
|
@ -14,8 +14,8 @@ module MaRuKu; module Out; module HTML
|
||||||
doc = Document.new(mathml, {:respect_whitespace =>:all}).root
|
doc = Document.new(mathml, {:respect_whitespace =>:all}).root
|
||||||
return doc
|
return doc
|
||||||
rescue LoadError => e
|
rescue LoadError => e
|
||||||
maruku_error "Could not load package 'itex2mml'.\n"+
|
maruku_error "Could not load package 'itex2mml'.\n"+ "Please install it." unless $already_warned_itex2mml
|
||||||
"Please install it."
|
$already_warned_itex2mml = true
|
||||||
rescue REXML::ParseException => e
|
rescue REXML::ParseException => e
|
||||||
maruku_error "Invalid MathML TeX: \n#{add_tabs(tex,1,'tex>')}"+
|
maruku_error "Invalid MathML TeX: \n#{add_tabs(tex,1,'tex>')}"+
|
||||||
"\n\n #{e.inspect}"
|
"\n\n #{e.inspect}"
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
module MaRuKu; module Out; module Latex
|
|
||||||
|
|
||||||
require 'maruku/ext/math/latex_fix'
|
require 'maruku/ext/math/latex_fix'
|
||||||
|
|
||||||
|
module MaRuKu; module Out; module Latex
|
||||||
|
|
||||||
def to_latex_inline_math
|
def to_latex_inline_math
|
||||||
s = "$#{self.math.strip}$".fix_latex
|
"$#{self.math.strip}$".fix_latex
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_latex_equation
|
def to_latex_equation
|
||||||
|
|
|
@ -173,6 +173,7 @@ Disabled by default because of security concerns.
|
||||||
self.abbreviations.each do |abbrev, title|
|
self.abbreviations.each do |abbrev, title|
|
||||||
reg = Regexp.new(Regexp.escape(abbrev))
|
reg = Regexp.new(Regexp.escape(abbrev))
|
||||||
self.replace_each_string do |s|
|
self.replace_each_string do |s|
|
||||||
|
# bug if many abbreviations are present (agorf)
|
||||||
if m = reg.match(s)
|
if m = reg.match(s)
|
||||||
e = md_abbr(abbrev.dup, title ? title.dup : nil)
|
e = md_abbr(abbrev.dup, title ? title.dup : nil)
|
||||||
[m.pre_match, e, m.post_match]
|
[m.pre_match, e, m.post_match]
|
||||||
|
|
|
@ -18,9 +18,16 @@
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#++
|
#++
|
||||||
|
|
||||||
|
|
||||||
require 'rexml/document'
|
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
|
class String
|
||||||
# A string is rendered into HTML by creating
|
# A string is rendered into HTML by creating
|
||||||
# a REXML::Text node. REXML takes care of all the encoding.
|
# a REXML::Text node. REXML takes care of all the encoding.
|
||||||
|
@ -30,11 +37,6 @@ class String
|
||||||
end
|
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.
|
# This module groups all functions related to HTML export.
|
||||||
module MaRuKu; module Out; module HTML
|
module MaRuKu; module Out; module HTML
|
||||||
include REXML
|
include REXML
|
||||||
|
@ -60,7 +62,21 @@ module MaRuKu; module Out; module HTML
|
||||||
# REXML Bug? if indent!=-1 whitespace is not respected for 'pre' elements
|
# REXML Bug? if indent!=-1 whitespace is not respected for 'pre' elements
|
||||||
# containing code.
|
# containing code.
|
||||||
xml =""
|
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
|
xml
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -141,19 +157,6 @@ Synonim for `title`.
|
||||||
=end
|
=end
|
||||||
|
|
||||||
|
|
||||||
=begin maruku_doc
|
|
||||||
Attribute: css
|
|
||||||
Scope: document
|
|
||||||
Output: HTML
|
|
||||||
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)
|
# Render to an HTML fragment (returns a REXML document tree)
|
||||||
def to_html_tree
|
def to_html_tree
|
||||||
div = Element.new 'div'
|
div = Element.new 'div'
|
||||||
|
@ -171,6 +174,21 @@ Example:
|
||||||
doc << div
|
doc << div
|
||||||
end
|
end
|
||||||
|
|
||||||
|
=begin maruku_doc
|
||||||
|
Attribute: css
|
||||||
|
Scope: document
|
||||||
|
Output: HTML
|
||||||
|
Summary: Activates CSS stylesheets for HTML.
|
||||||
|
|
||||||
|
`css` should be a space-separated list of urls.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
CSS: style.css math.css
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
|
||||||
# Render to a complete HTML document (returns a REXML document tree)
|
# Render to a complete HTML document (returns a REXML document tree)
|
||||||
def to_html_document_tree
|
def to_html_document_tree
|
||||||
doc = Document.new(nil,{:respect_whitespace =>:all})
|
doc = Document.new(nil,{:respect_whitespace =>:all})
|
||||||
|
@ -465,7 +483,7 @@ by Maruku, to have the same results in both HTML and LaTeX.
|
||||||
end
|
end
|
||||||
|
|
||||||
def source2html(source)
|
def source2html(source)
|
||||||
source = source.gsub(/&/,'&')
|
# source = source.gsub(/&/,'&')
|
||||||
source = Text.normalize(source)
|
source = Text.normalize(source)
|
||||||
source = source.gsub(/\'/,''') # IE bug
|
source = source.gsub(/\'/,''') # IE bug
|
||||||
source = source.gsub(/'/,''') # IE bug
|
source = source.gsub(/'/,''') # IE bug
|
||||||
|
@ -591,7 +609,7 @@ of the form `#ff00ff`.
|
||||||
code = Element.new 'code', pre
|
code = Element.new 'code', pre
|
||||||
s = source
|
s = source
|
||||||
|
|
||||||
s = s.gsub(/&/,'&')
|
# s = s.gsub(/&/,'&')
|
||||||
s = Text.normalize(s)
|
s = Text.normalize(s)
|
||||||
s = s.gsub(/\'/,''') # IE bug
|
s = s.gsub(/\'/,''') # IE bug
|
||||||
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)
|
# Entity.new(entity_name)
|
||||||
Text.new('&#%d;' % [entity_name], false, nil, true)
|
Text.new('&#%d;' % [entity_name], false, nil, true)
|
||||||
else
|
else
|
||||||
Text.new('&%s;' % [entity_name])
|
Text.new('&%s;' % [entity_name], false, nil, true)
|
||||||
end
|
end
|
||||||
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
|
module MaRuKu
|
||||||
Version = '0.5.6'
|
Version = '0.5.7'
|
||||||
|
|
||||||
MarukuURL = 'http://maruku.rubyforge.org/'
|
MarukuURL = 'http://maruku.rubyforge.org/'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue