Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
4c4f7a7b82
|
@ -2313,7 +2313,7 @@ end
|
||||||
"'" => ''',
|
"'" => ''',
|
||||||
'"' => '"',
|
'"' => '"',
|
||||||
}
|
}
|
||||||
TO_ESCAPE_PATTERN = Regexp.union(TO_ESCAPE.keys)
|
TO_ESCAPE_PATTERN = Regexp.union(*TO_ESCAPE.keys)
|
||||||
|
|
||||||
def escapeHTML
|
def escapeHTML
|
||||||
self.gsub(TO_ESCAPE_PATTERN){|m| TO_ESCAPE[m]}
|
self.gsub(TO_ESCAPE_PATTERN){|m| TO_ESCAPE[m]}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
module MaRuKu; module Out; module HTML
|
module MaRuKu; module Out; module HTML
|
||||||
|
|
||||||
|
require 'maruku/string_utils'
|
||||||
|
|
||||||
def convert_to_mathml_none(kind, tex)
|
def convert_to_mathml_none(kind, tex)
|
||||||
# You can: either return a REXML::Element
|
# You can: either return a REXML::Element
|
||||||
# return Element.new 'div'
|
# return Element.new 'div'
|
||||||
# or return an empty array on error
|
# or return an empty array on error
|
||||||
# return []
|
# return []
|
||||||
# or have a string parsed by REXML:
|
# or have a string parsed by REXML:
|
||||||
mathml = "<code>#{tex.gsub( /&/, "&" ).
|
mathml = "<code>#{html_escape(tex)}</code>"
|
||||||
gsub( /</, "<" ).gsub( />/, ">" ).
|
|
||||||
gsub(/'/, "'" ).gsub(/"/, """ )}</code>"
|
|
||||||
return Document.new(mathml).root
|
return Document.new(mathml).root
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ begin
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
$rexml_new_version = false
|
$rexml_new_version = false
|
||||||
end
|
end
|
||||||
|
require 'maruku/string_utils'
|
||||||
|
|
||||||
class MDDocument
|
class MDDocument
|
||||||
|
|
||||||
|
@ -15,14 +16,6 @@ end
|
||||||
html_escape(self.attributes[:slide_theme] || "default")
|
html_escape(self.attributes[:slide_theme] || "default")
|
||||||
end
|
end
|
||||||
|
|
||||||
def html_escape(string)
|
|
||||||
string.gsub( /&/, "&" ).
|
|
||||||
gsub( /</, "<" ).
|
|
||||||
gsub( />/, ">" ).
|
|
||||||
gsub( /'/, "'" ).
|
|
||||||
gsub( /"/, """ )
|
|
||||||
end
|
|
||||||
|
|
||||||
# Render as an HTML fragment (no head, just the content of BODY). (returns a string)
|
# Render as an HTML fragment (no head, just the content of BODY). (returns a string)
|
||||||
def to_s5(context={})
|
def to_s5(context={})
|
||||||
indent = context[:indent] || -1
|
indent = context[:indent] || -1
|
||||||
|
|
|
@ -74,9 +74,7 @@ module MaRuKu; module Out; module HTML
|
||||||
div.write(xml,indent,transitive=true,ie_hack)
|
div.write(xml,indent,transitive=true,ie_hack)
|
||||||
end
|
end
|
||||||
|
|
||||||
xml.gsub!(/\A<dummy>\s*/,'')
|
xml.gsub!(/\A<dummy>\s*|\s*<\/dummy>\Z|\A<dummy\s*\/>/,'')
|
||||||
xml.gsub!(/\s*<\/dummy>\Z/,'')
|
|
||||||
xml.gsub!(/\A<dummy\s*\/>/,'')
|
|
||||||
xml
|
xml
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -507,8 +505,7 @@ by Maruku, to have the same results in both HTML and LaTeX.
|
||||||
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.gsub!(/\'|'/,''') # IE bug
|
||||||
source = source.gsub(/'/,''') # IE bug
|
|
||||||
Text.new(source, true, nil, true )
|
Text.new(source, true, nil, true )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -571,8 +568,7 @@ and
|
||||||
source = source.gsub(/\n*\Z/,'')
|
source = source.gsub(/\n*\Z/,'')
|
||||||
|
|
||||||
html = convertor.convert( source )
|
html = convertor.convert( source )
|
||||||
html = html.gsub(/\'/,''') # IE bug
|
html.gsub!(/\'|'/,''') # IE bug
|
||||||
html = html.gsub(/'/,''') # IE bug
|
|
||||||
# html = html.gsub(/&/,'&')
|
# html = html.gsub(/&/,'&')
|
||||||
|
|
||||||
code = Document.new(html, {:respect_whitespace =>:all}).root
|
code = Document.new(html, {:respect_whitespace =>:all}).root
|
||||||
|
@ -633,9 +629,7 @@ of the form `#ff00ff`.
|
||||||
s = source
|
s = source
|
||||||
|
|
||||||
# s = s.gsub(/&/,'&')
|
# s = s.gsub(/&/,'&')
|
||||||
s = Text.normalize(s)
|
s = Text.normalize(s).gsub(/\'|'/,''') # IE bug
|
||||||
s = s.gsub(/\'/,''') # IE bug
|
|
||||||
s = s.gsub(/'/,''') # IE bug
|
|
||||||
|
|
||||||
if get_setting(:code_show_spaces)
|
if get_setting(:code_show_spaces)
|
||||||
# 187 = raquo
|
# 187 = raquo
|
||||||
|
|
20
vendor/plugins/maruku/lib/maruku/string_utils.rb
vendored
20
vendor/plugins/maruku/lib/maruku/string_utils.rb
vendored
|
@ -141,6 +141,26 @@ module MaRuKu
|
||||||
return s
|
return s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#--
|
||||||
|
MARUKU_HTML_ESCAPE = {
|
||||||
|
'&' => '&',
|
||||||
|
'<' => '<',
|
||||||
|
'>' => '>',
|
||||||
|
"'" => ''',
|
||||||
|
'"' => '"',
|
||||||
|
}
|
||||||
|
MARUKU_HTML_ESCAPE_PATTERN = Regexp.union(*MARUKU_HTML_ESCAPE.keys)
|
||||||
|
#++
|
||||||
|
|
||||||
|
# HTML-escapes a string.
|
||||||
|
#
|
||||||
|
# @param str [String]
|
||||||
|
# @return [String]
|
||||||
|
|
||||||
|
def html_escape(string)
|
||||||
|
string.gsub(MARUKU_HTML_ESCAPE_PATTERN){|m| MARUKU_HTML_ESCAPE[m]}
|
||||||
|
end
|
||||||
|
|
||||||
# Escapes a string so that it can be safely used in a Bourne shell command line.
|
# Escapes a string so that it can be safely used in a Bourne shell command line.
|
||||||
#
|
#
|
||||||
# Note that a resulted string should be used unquoted
|
# Note that a resulted string should be used unquoted
|
||||||
|
|
Loading…
Reference in a new issue