From 2c91c276c10c5328d7e68f3316d66aaecf0aeba6 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Sun, 11 Dec 2011 16:20:04 -0600 Subject: [PATCH] Added RubyPants (the ruby port of John Gruber's smarty pants) to intelligently replace primes with smart quotes in the pullquote plugin, fixes #316 --- plugins/pullquote.rb | 6 +- plugins/rubypants.rb | 489 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 493 insertions(+), 2 deletions(-) create mode 100644 plugins/rubypants.rb diff --git a/plugins/pullquote.rb b/plugins/pullquote.rb index cf8d22f..2b59bad 100644 --- a/plugins/pullquote.rb +++ b/plugins/pullquote.rb @@ -4,7 +4,7 @@ # # Outputs a span with a data-pullquote attribute set from the marked pullquote. Example: # -# {% pullquote %} +# {% pullquote %} # When writing longform posts, I find it helpful to include pullquotes, which help those scanning a post discern whether or not a post is helpful. # It is important to note, {" pullquotes are merely visual in presentation and should not appear twice in the text. "} That is why it is prefered # to use a CSS only technique for styling pullquotes. @@ -33,7 +33,9 @@ module Jekyll def render(context) output = super if output.join =~ /\{"\s*(.+)\s*"\}/ - @quote = $1 + #@quote = $1 + @quote = RubyPants.new($1).to_html + #@quote = CGI.escape($1) "#{output.join.gsub(/\{"\s*|\s*"\}/, '')}" else return "Surround your pullquote like this {\" text to be quoted \"}" diff --git a/plugins/rubypants.rb b/plugins/rubypants.rb new file mode 100644 index 0000000..e4f4502 --- /dev/null +++ b/plugins/rubypants.rb @@ -0,0 +1,489 @@ +# +# = RubyPants -- SmartyPants ported to Ruby +# +# Ported by Christian Neukirchen +# Copyright (C) 2004 Christian Neukirchen +# +# Incooporates ideas, comments and documentation by Chad Miller +# Copyright (C) 2004 Chad Miller +# +# Original SmartyPants by John Gruber +# Copyright (C) 2003 John Gruber +# + +# +# = RubyPants -- SmartyPants ported to Ruby +# +# == Synopsis +# +# RubyPants is a Ruby port of the smart-quotes library SmartyPants. +# +# The original "SmartyPants" is a free web publishing plug-in for +# Movable Type, Blosxom, and BBEdit that easily translates plain ASCII +# punctuation characters into "smart" typographic punctuation HTML +# entities. +# +# +# == Description +# +# RubyPants can perform the following transformations: +# +# * Straight quotes (" and ') into "curly" quote +# HTML entities +# * Backticks-style quotes (``like this'') into "curly" quote +# HTML entities +# * Dashes (-- and ---) into en- and em-dash +# entities +# * Three consecutive dots (... or . . .) into an +# ellipsis entity +# +# This means you can write, edit, and save your posts using plain old +# ASCII straight quotes, plain dashes, and plain dots, but your +# published posts (and final HTML output) will appear with smart +# quotes, em-dashes, and proper ellipses. +# +# RubyPants does not modify characters within
,
+# , ,  or
+#