[DRE-commits] [ruby-gollum-lib] 01/04: use rouge 2.x (Closes: #830095)

Cédric Boutillier boutil at moszumanska.debian.org
Sat Jul 9 08:57:39 UTC 2016


This is an automated email from the git hooks/post-receive script.

boutil pushed a commit to branch master
in repository ruby-gollum-lib.

commit dced24c8064966c4690bef7bccabfa6f148549c9
Author: Cédric Boutillier <boutil at debian.org>
Date:   Sat Jul 9 10:45:23 2016 +0200

    use rouge 2.x (Closes: #830095)
---
 debian/patches/rouge2.patch | 56 +++++++++++++++++++++++++++++++++++++++++++++
 debian/patches/series       |  1 +
 2 files changed, 57 insertions(+)

diff --git a/debian/patches/rouge2.patch b/debian/patches/rouge2.patch
new file mode 100644
index 0000000..590da36
--- /dev/null
+++ b/debian/patches/rouge2.patch
@@ -0,0 +1,56 @@
+From: "http://jneen.net/" <jneen at jneen.net>
+Origin: https://github.com/gollum/gollum-lib/commit/f43f905ca952ee9f55376d990921de147dbaa8be
+Date: Tue, 14 Jun 2016 16:23:22 -0700
+Subject: [PATCH] use rouge 2.0 and manual wrapping
+
+---
+ gemspec.rb                    |  2 +-
+ lib/gollum-lib/filter/code.rb | 18 +++++++++++-------
+ 2 files changed, 12 insertions(+), 8 deletions(-)
+
+diff --git a/gemspec.rb b/gemspec.rb
+index 02f2d70..3dd3438 100644
+--- a/gemspec.rb
++++ b/gemspec.rb
+@@ -25,7 +25,7 @@ def specification(version, default_adapter, platform = nil)
+     s.extra_rdoc_files = %w(README.md LICENSE)
+ 
+     s.add_dependency *default_adapter
+-    s.add_dependency 'rouge', '~> 1.10'
++    s.add_dependency 'rouge', '~> 2.0'
+     s.add_dependency 'nokogiri', '~> 1.6.4'
+     s.add_dependency 'stringex', '~> 2.5.1'
+     s.add_dependency 'sanitize', '~> 2.1.0'
+diff --git a/lib/gollum-lib/filter/code.rb b/lib/gollum-lib/filter/code.rb
+index 9236814..088e15b 100644
+--- a/lib/gollum-lib/filter/code.rb
++++ b/lib/gollum-lib/filter/code.rb
+@@ -82,17 +82,21 @@ def process(data)
+         hl_code = lexer.highlight(code, :options => { :encoding => encoding.to_s, :startinline => true })
+       else # Rouge
+         begin
++          lexer = Rouge::Lexer.find_fancy(lang || 'plaintext')
++          formatter = Rouge::Formatters::HTML.new
++
+           # if `lang` was not defined then assume plaintext
+           # if `lang` is defined but cannot be found then wrap it and escape it
+-          lang ||= 'plaintext'
+-          if Rouge::Lexer.find(lang).nil?
+-            lexer     = Rouge::Lexers::PlainText.new
+-            formatter = Rouge::Formatters::HTML.new(:wrap => false)
+-            hl_code   = formatter.format(lexer.lex(code))
+-            hl_code   = "<pre class='highlight'><span class='err'>#{CGI.escapeHTML(hl_code)}</span></pre>"
++          if lexer.nil?
++            lexer = Rouge::Lexers::PlainText
++            wrap_template = '<pre class="highlight"><span class="err">%s</span></pre>'
+           else
+-            hl_code = Rouge.highlight(code, lang, 'html')
++            wrap_template = '<pre class="highlight"><code>%s</code></pre>'
+           end
++
++          formatted = formatter.format(lexer.lex(code))
++
++          hl_code = Kernel.sprintf(wrap_template, formatted)
+         rescue
+           hl_code = code
+         end
diff --git a/debian/patches/series b/debian/patches/series
index a10fb80..ff1b1c7 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 use-rugged.patch
+rouge2.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-gollum-lib.git



More information about the Pkg-ruby-extras-commits mailing list