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
|
||||
self.gsub(TO_ESCAPE_PATTERN){|m| TO_ESCAPE[m]}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
module MaRuKu; module Out; module HTML
|
||||
|
||||
require 'maruku/string_utils'
|
||||
|
||||
def convert_to_mathml_none(kind, tex)
|
||||
# You can: either return a REXML::Element
|
||||
# return Element.new 'div'
|
||||
# or return an empty array on error
|
||||
# return []
|
||||
# or have a string parsed by REXML:
|
||||
mathml = "<code>#{tex.gsub( /&/, "&" ).
|
||||
gsub( /</, "<" ).gsub( />/, ">" ).
|
||||
gsub(/'/, "'" ).gsub(/"/, """ )}</code>"
|
||||
mathml = "<code>#{html_escape(tex)}</code>"
|
||||
return Document.new(mathml).root
|
||||
end
|
||||
|
||||
|
|
|
@ -8,20 +8,13 @@ begin
|
|||
rescue LoadError
|
||||
$rexml_new_version = false
|
||||
end
|
||||
require 'maruku/string_utils'
|
||||
|
||||
class MDDocument
|
||||
|
||||
def s5_theme
|
||||
html_escape(self.attributes[:slide_theme] || "default")
|
||||
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)
|
||||
def to_s5(context={})
|
||||
|
|
|
@ -74,9 +74,7 @@ module MaRuKu; module Out; module HTML
|
|||
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.gsub!(/\A<dummy>\s*|\s*<\/dummy>\Z|\A<dummy\s*\/>/,'')
|
||||
xml
|
||||
end
|
||||
|
||||
|
@ -507,8 +505,7 @@ by Maruku, to have the same results in both HTML and LaTeX.
|
|||
def source2html(source)
|
||||
# source = source.gsub(/&/,'&')
|
||||
source = Text.normalize(source)
|
||||
source = source.gsub(/\'/,''') # IE bug
|
||||
source = source.gsub(/'/,''') # IE bug
|
||||
source.gsub!(/\'|'/,''') # IE bug
|
||||
Text.new(source, true, nil, true )
|
||||
end
|
||||
|
||||
|
@ -571,8 +568,7 @@ and
|
|||
source = source.gsub(/\n*\Z/,'')
|
||||
|
||||
html = convertor.convert( source )
|
||||
html = html.gsub(/\'/,''') # IE bug
|
||||
html = html.gsub(/'/,''') # IE bug
|
||||
html.gsub!(/\'|'/,''') # IE bug
|
||||
# html = html.gsub(/&/,'&')
|
||||
|
||||
code = Document.new(html, {:respect_whitespace =>:all}).root
|
||||
|
@ -633,9 +629,7 @@ of the form `#ff00ff`.
|
|||
s = source
|
||||
|
||||
# s = s.gsub(/&/,'&')
|
||||
s = Text.normalize(s)
|
||||
s = s.gsub(/\'/,''') # IE bug
|
||||
s = s.gsub(/'/,''') # IE bug
|
||||
s = Text.normalize(s).gsub(/\'|'/,''') # IE bug
|
||||
|
||||
if get_setting(:code_show_spaces)
|
||||
# 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
|
||||
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.
|
||||
#
|
||||
# Note that a resulted string should be used unquoted
|
||||
|
|
Loading…
Reference in a new issue