From 070f689f9cbfba9c8188d90bc935db76abc8b952 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Sat, 13 Aug 2011 03:59:40 -0500 Subject: [PATCH] Fixed some Maruku bugs Email addresses and horizontal rules now work properly. --- .../maruku/lib/maruku/input/type_detection.rb | 12 +++--- .../maruku/lib/maruku/output/to_html.rb | 9 +++-- .../plugins/maruku/spec/block_docs/email.md | 2 +- .../plugins/maruku/spec/block_docs/hrule.md | 2 +- vendor/plugins/maruku/spec/block_docs/ie.md | 2 +- .../maruku/spec/block_docs/inline_html.md | 38 ++++++++++++------- .../plugins/maruku/spec/block_docs/links.md | 2 +- 7 files changed, 40 insertions(+), 27 deletions(-) diff --git a/vendor/plugins/maruku/lib/maruku/input/type_detection.rb b/vendor/plugins/maruku/lib/maruku/input/type_detection.rb index 9b1ad453..e52563a6 100644 --- a/vendor/plugins/maruku/lib/maruku/input/type_detection.rb +++ b/vendor/plugins/maruku/lib/maruku/input/type_detection.rb @@ -50,11 +50,6 @@ module MaRuKu; module Strings return :xml_instr if l =~ %r{^\s*<\?} return :raw_html if l =~ %r{^[ ]?[ ]?[ ]?/ return :metadata if l =~ /^@/ # if @@new_meta_data? @@ -143,5 +143,5 @@ module MaRuKu; module Strings TableSeparator = %r{^(\|?#{Sep}\|?)+?\s*$} - EMailAddress = /<([^:]+?@[^:]+?)>/ + EMailAddress = /<([^:@>]+?@[^:@>]+?)>/ end end diff --git a/vendor/plugins/maruku/lib/maruku/output/to_html.rb b/vendor/plugins/maruku/lib/maruku/output/to_html.rb index e8f59182..f773ebce 100644 --- a/vendor/plugins/maruku/lib/maruku/output/to_html.rb +++ b/vendor/plugins/maruku/lib/maruku/output/to_html.rb @@ -733,9 +733,10 @@ of the form `#ff00ff`. ##### Email address def obfuscate(s) - res = '' + d = Nokogiri::XML::Document.new + res = Nokogiri::XML::NodeSet.new(d) s.each_byte do |char| - res += "&#%03d;" % char + res << Nokogiri::XML::EntityReference.new(d, "#%03d" % char) end res end @@ -748,9 +749,9 @@ of the form `#ff00ff`. #a.attributes.add Attribute.new('href',Text.new( #"mailto:"+obfuscate(email),false,nil,true)) # Sorry, for the moment it doesn't work - a.attributes['href'] = "mailto:#{email}" + a['href'] = "mailto:#{email}" - a << Nokogiri::XML::Text.new(obfuscate(email), d) + a << obfuscate(email) a end diff --git a/vendor/plugins/maruku/spec/block_docs/email.md b/vendor/plugins/maruku/spec/block_docs/email.md index ad4d4661..02fc128a 100644 --- a/vendor/plugins/maruku/spec/block_docs/email.md +++ b/vendor/plugins/maruku/spec/block_docs/email.md @@ -11,7 +11,7 @@ md_el(:document,[ md_par(["This is an email address: ", md_email("andrea@invalid.it")]) ],{},[]) *** Output of to_html *** -

This is an email address: andrea@invalid.it

+

This is an email address: andrea@invalid.it

*** Output of to_latex *** This is an email address: \href{mailto:andrea@invalid.it}{andrea\char64invalid\char46it} *** Output of to_md *** diff --git a/vendor/plugins/maruku/spec/block_docs/hrule.md b/vendor/plugins/maruku/spec/block_docs/hrule.md index 61daa8e5..e4cad07e 100644 --- a/vendor/plugins/maruku/spec/block_docs/hrule.md +++ b/vendor/plugins/maruku/spec/block_docs/hrule.md @@ -22,7 +22,7 @@ md_el(:document,[ md_el(:hrule,[],{},[]) ],{},[]) *** Output of to_html *** -




+




*** Output of to_latex *** \vspace{.5em} \hrule \vspace{.5em} diff --git a/vendor/plugins/maruku/spec/block_docs/ie.md b/vendor/plugins/maruku/spec/block_docs/ie.md index 06a0e1ed..3968d6ee 100644 --- a/vendor/plugins/maruku/spec/block_docs/ie.md +++ b/vendor/plugins/maruku/spec/block_docs/ie.md @@ -31,7 +31,7 @@ md_el(:document,[
<p>here's an apostrophe & a quote "</p>
-
<p>here's an apostrophe & a quote "</p>
+
<p>here's an apostrophe & a quote "</p>
<p>here's an apostrophe & a quote "</p>
diff --git a/vendor/plugins/maruku/spec/block_docs/inline_html.md b/vendor/plugins/maruku/spec/block_docs/inline_html.md index 028efb7f..75d03ef1 100644 --- a/vendor/plugins/maruku/spec/block_docs/inline_html.md +++ b/vendor/plugins/maruku/spec/block_docs/inline_html.md @@ -6,13 +6,13 @@ CSS: style.css Input: - Emphasis + Emphasis Result: Emphasis Input: - + Result on span: @@ -25,14 +25,14 @@ Without closing:
- This is *true* markdown text (paragraph) + This is *true* markdown text (paragraph) -

- This is *true* markdown text (no paragraph) -

-

- This is *true* markdown text (block paragraph) -

+

+ This is *true* markdown text (no paragraph) +

+

+ This is *true* markdown text (block paragraph) +

@@ -78,7 +78,7 @@ md_el(:document,[

Result alone:

Without closing:

-
+

This is

@@ -95,7 +95,7 @@ md_el(:document,[

markdown text (no paragraph)

-

+

This is

@@ -106,8 +106,20 @@ md_el(:document,[

- - + +

This is a

true

markdown text. (no par)

This is

true

markdown text. (par)

+

This is a

+ +

true

+
+

markdown text. (no par)

+
+

This is

+ +

true

+
+

markdown text. (par)

+
*** Output of to_latex *** diff --git a/vendor/plugins/maruku/spec/block_docs/links.md b/vendor/plugins/maruku/spec/block_docs/links.md index 7757162f..056d657d 100644 --- a/vendor/plugins/maruku/spec/block_docs/links.md +++ b/vendor/plugins/maruku/spec/block_docs/links.md @@ -102,7 +102,7 @@ md_el(:document,[

If all else fails, ask Google

And now reference-style link ID with spaces

-** Output of to_latex *** +*** Output of to_latex *** Search on \href{http://www.google.com}{Google} Search on \href{http://www.google.com}{Google}