[DRE-commits] [ruby-org] 01/02: [patch] add :skip_syntax_highlight option
Cédric Boutillier
boutil at moszumanska.debian.org
Wed Apr 16 14:52:49 UTC 2014
This is an automated email from the git hooks/post-receive script.
boutil pushed a commit to branch master
in repository ruby-org.
commit 2c917f6f7de02d556fc35659fc9ef20e86426309
Author: Cédric Boutillier <boutil at debian.org>
Date: Wed Apr 16 16:50:30 2014 +0200
[patch] add :skip_syntax_highlight option
---
debian/patches/add_skip_syntax_highlight.patch | 149 +++++++++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 150 insertions(+)
diff --git a/debian/patches/add_skip_syntax_highlight.patch b/debian/patches/add_skip_syntax_highlight.patch
new file mode 100644
index 0000000..98110db
--- /dev/null
+++ b/debian/patches/add_skip_syntax_highlight.patch
@@ -0,0 +1,149 @@
+Description: Make it possible to skip-syntax-highlighting explicitly
+From: Waldemar Quevedo <waldemar.quevedo at gmail.com>
+Origin: https://github.com/wallyqs/org-ruby/commit/2cba8d21e2de71b7d5cab212cb1016dbbfddbba8.patch
+Reviewed-by: Cédric Boutillier <boutil at debian.org>
+Last-Update: 2014-04-16
+
+--- a/lib/org-ruby/html_output_buffer.rb
++++ b/lib/org-ruby/html_output_buffer.rb
+@@ -1,14 +1,3 @@
+-begin
+- require 'pygments'
+-rescue LoadError
+- # Pygments is not supported so we try instead with CodeRay
+- begin
+- require 'coderay'
+- rescue LoadError
+- # No code syntax highlighting
+- end
+-end
+-
+ module Orgmode
+
+ class HtmlOutputBuffer < OutputBuffer
+@@ -51,6 +40,19 @@
+ @footnotes = {}
+ @unclosed_tags = []
+ @logger.debug "HTML export options: #{@options.inspect}"
++
++ unless @options[:skip_syntax_highlight]
++ begin
++ require 'pygments'
++ rescue LoadError
++ # Pygments is not supported so we try instead with CodeRay
++ begin
++ require 'coderay'
++ rescue LoadError
++ # No code syntax highlighting
++ end
++ end
++ end
+ end
+
+ # Output buffer is entering a new mode. Use this opportunity to
+@@ -61,7 +63,7 @@
+
+ if HtmlBlockTag[mode]
+ unless ((mode_is_table?(mode) and skip_tables?) or
+- (mode == :src and defined? Pygments))
++ (mode == :src and !@options[:skip_syntax_highlight] and defined? Pygments))
+ css_class = case
+ when (mode == :src and @block_lang.empty?)
+ " class=\"src\""
+@@ -92,7 +94,7 @@
+ m = super(mode)
+ if HtmlBlockTag[m]
+ unless ((mode_is_table?(m) and skip_tables?) or
+- (m == :src and defined? Pygments))
++ (m == :src and !@options[:skip_syntax_highlight] and defined? Pygments))
+ add_paragraph if @new_paragraph
+ @new_paragraph = true
+ @logger.debug "</#{HtmlBlockTag[m]}>"
+@@ -111,6 +113,8 @@
+ # NOTE: CodeRay and Pygments already escape the html once, so
+ # no need to escapeHTML
+ case
++ when (current_mode == :src and @options[:skip_syntax_highlight])
++ @buffer = escapeHTML @buffer
+ when (current_mode == :src and defined? Pygments)
+ lang = normalize_lang @block_lang
+ @output << "\n" unless @new_paragraph == :start
+--- a/lib/org-ruby/parser.rb
++++ b/lib/org-ruby/parser.rb
+@@ -306,7 +306,8 @@
+ :export_todo => export_todo?,
+ :use_sub_superscripts => use_sub_superscripts?,
+ :export_footnotes => export_footnotes?,
+- :link_abbrevs => @link_abbrevs
++ :link_abbrevs => @link_abbrevs,
++ :skip_syntax_highlight => @parser_options[:skip_syntax_highlight]
+ }
+ export_options[:skip_tables] = true if not export_tables?
+ output = ""
+--- a/spec/parser_spec.rb
++++ b/spec/parser_spec.rb
+@@ -195,19 +195,18 @@
+
+ describe "Export to HTML test cases with code syntax highlight" do
+ code_syntax_examples_directory = File.join(File.dirname(__FILE__), "html_code_syntax_highlight_examples")
++ files = []
+
+ # Include the code syntax highlight support tests
+ if defined? CodeRay
+ # Use CodeRay for syntax highlight (pure Ruby solution)
+ org_files = File.expand_path(File.join(code_syntax_examples_directory, "*-coderay.org"))
++ files = Dir.glob(org_files)
+ elsif defined? Pygments
+ # Use pygments (so that it works with Jekyll, Gollum and possibly Github)
+ org_files = File.expand_path(File.join(code_syntax_examples_directory, "*-pygments.org"))
+- else
+- # Do not use syntax coloring for source code blocks
+- org_files = File.expand_path(File.join(code_syntax_examples_directory, "*-no-color.org"))
++ files = Dir.glob(org_files)
+ end
+- files = Dir.glob(org_files)
+
+ files.each do |file|
+ basename = File.basename(file, ".org")
+@@ -227,6 +226,41 @@
+ ENV['ORG_RUBY_ENABLE_INCLUDE_FILES'] = 'true'
+ expected = IO.read(org_filename)
+ template = Tilt.new(file).render
++ template.should == expected
++ ENV['ORG_RUBY_ENABLE_INCLUDE_FILES'] = ''
++ end
++ end
++ end
++
++ describe "Export to HTML test cases with code syntax highlight disabled" do
++ code_syntax_examples_directory = File.join(File.dirname(__FILE__), "html_code_syntax_highlight_examples")
++
++ # Do not use syntax coloring for source code blocks
++ org_files = File.expand_path(File.join(code_syntax_examples_directory, "*-no-color.org"))
++ files = Dir.glob(org_files)
++
++ files.each do |file|
++ basename = File.basename(file, ".org")
++ org_filename = File.join(code_syntax_examples_directory, basename + ".html")
++ org_filename = File.expand_path(org_filename)
++
++ it "should convert #{basename}.org to HTML" do
++ expected = IO.read(org_filename)
++ expected.should be_kind_of(String)
++ parser = Orgmode::Parser.new(IO.read(file), {
++ :allow_include_files => true,
++ :skip_syntax_highlight => true
++ })
++ actual = parser.to_html
++ actual.should be_kind_of(String)
++ actual.should == expected
++ end
++
++ it "should render #{basename}.org to HTML using Tilt templates",
++ :if => (defined? Coderay or defined? Pygments) do
++ ENV['ORG_RUBY_ENABLE_INCLUDE_FILES'] = 'true'
++ expected = IO.read(org_filename)
++ template = Tilt.new(file).render
+ template.should == expected
+ ENV['ORG_RUBY_ENABLE_INCLUDE_FILES'] = ''
+ end
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..804545a
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+add_skip_syntax_highlight.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-org.git
More information about the Pkg-ruby-extras-commits
mailing list