org-ruby 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.7.1 / 2012-08-04
2
+
3
+ * Make source code blocks from lisp dialects use Pygments scheme lexer
4
+ * Bugfix: Make Coderay fallback to text lexer when unsupported lang is set
5
+
1
6
  == 0.7.0 / 2012-07-08
2
7
 
3
8
  * Highlight source code blocks using Pygments or CodeRay when available
data/lib/org-ruby.rb CHANGED
@@ -21,7 +21,7 @@ require 'org-ruby/tilt'
21
21
  module OrgRuby
22
22
 
23
23
  # :stopdoc:
24
- VERSION = '0.7.0'
24
+ VERSION = '0.7.1'
25
25
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
26
26
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
27
27
  # :startdoc:
@@ -110,18 +110,25 @@ module Orgmode
110
110
  # Only try to colorize #+BEGIN_SRC blocks with a specified language,
111
111
  # but we still have to catch the cases when a lexer for the language was not available
112
112
  if not @block_lang.empty? and (defined? Pygments or defined? CodeRay)
113
+ lang = normalize_lang(@block_lang)
114
+
113
115
  # NOTE: CodeRay and Pygments already escape the html once, so no need to escape_buffer!
114
116
  if defined? Pygments
115
117
  begin
116
- @buffer = Pygments.highlight(@buffer, :lexer => @block_lang)
118
+ @buffer = Pygments.highlight(@buffer, :lexer => lang)
117
119
  rescue ::RubyPython::PythonError
118
120
  # Not supported lexer from Pygments, we fallback on using the text lexer
119
121
  @buffer = Pygments.highlight(@buffer, :lexer => 'text')
120
122
  end
121
123
  elsif defined? CodeRay
122
- # CodeRay might throw a warning when unsupported lang is set
124
+ # CodeRay might throw a warning when unsupported lang is set,
125
+ # then fallback to using the text lexer
123
126
  silence_warnings do
124
- @buffer = CodeRay.scan(@buffer, @block_lang).html(:wrap => nil, :css => :style)
127
+ begin
128
+ @buffer = CodeRay.scan(@buffer, lang).html(:wrap => nil, :css => :style)
129
+ rescue ArgumentError
130
+ @buffer = CodeRay.scan(@buffer, 'text').html(:wrap => nil, :css => :style)
131
+ end
125
132
  end
126
133
  end
127
134
  else
@@ -336,6 +343,15 @@ module Orgmode
336
343
  end
337
344
  end
338
345
 
346
+ def normalize_lang(lang)
347
+ case lang
348
+ when 'emacs-lisp', 'common-lisp', 'lisp'
349
+ 'scheme'
350
+ else
351
+ lang
352
+ end
353
+ end
354
+
339
355
  # Helper method taken from Rails
340
356
  # https://github.com/rails/rails/blob/c2c8ef57d6f00d1c22743dc43746f95704d67a95/activesupport/lib/active_support/core_ext/kernel/reporting.rb#L10
341
357
  def silence_warnings
data/lib/org-ruby/line.rb CHANGED
@@ -146,7 +146,7 @@ module Orgmode
146
146
  table_row? or table_separator? or table_header?
147
147
  end
148
148
 
149
- BlockRegexp = /^\s*#\+(BEGIN|END)_(\w*)\s*(\w*)?/i
149
+ BlockRegexp = /^\s*#\+(BEGIN|END)_(\w*)\s*([0-9A-Za-z_\-]*)?/i
150
150
 
151
151
  def begin_block?
152
152
  @line =~ BlockRegexp && $1 =~ /BEGIN/i
metadata CHANGED
@@ -1,69 +1,56 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: org-ruby
3
- version: !ruby/object:Gem::Version
4
- hash: 3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 7
9
- - 0
10
- version: 0.7.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Brian Dewey
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-07-08 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-07-08 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rubypants
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70185642496880 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 23
29
- segments:
30
- - 0
31
- - 2
32
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
33
21
  version: 0.2.0
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: bones
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70185642496880
25
+ - !ruby/object:Gem::Dependency
26
+ name: bones
27
+ requirement: &70185642496060 !ruby/object:Gem::Requirement
40
28
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 39
45
- segments:
46
- - 3
47
- - 8
48
- - 0
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
49
32
  version: 3.8.0
50
33
  type: :development
51
- version_requirements: *id002
52
- description: "This gem contains Ruby routines for parsing org-mode files.The most\n\
53
- significant thing this library does today is convert org-mode files to\n\
54
- HTML or textile. Currently, you cannot do much to customize the\n\
55
- conversion. The supplied textile conversion is optimized for\n\
56
- extracting \"content\" from the orgfile as opposed to \"metadata.\" "
34
+ prerelease: false
35
+ version_requirements: *70185642496060
36
+ description: ! 'This gem contains Ruby routines for parsing org-mode files.The most
37
+
38
+ significant thing this library does today is convert org-mode files to
39
+
40
+ HTML or textile. Currently, you cannot do much to customize the
41
+
42
+ conversion. The supplied textile conversion is optimized for
43
+
44
+ extracting "content" from the orgfile as opposed to "metadata." '
57
45
  email: bdewey@gmail.com
58
- executables:
46
+ executables:
59
47
  - org-ruby
60
48
  extensions: []
61
-
62
- extra_rdoc_files:
49
+ extra_rdoc_files:
63
50
  - History.txt
64
51
  - README.rdoc
65
52
  - bin/org-ruby
66
- files:
53
+ files:
67
54
  - History.txt
68
55
  - README.rdoc
69
56
  - bin/org-ruby
@@ -78,40 +65,30 @@ files:
78
65
  - lib/org-ruby/textile_output_buffer.rb
79
66
  - lib/org-ruby/textile_symbol_replace.rb
80
67
  - lib/org-ruby/tilt.rb
81
- - test/test_orgmode_parser.rb
82
68
  homepage: http://github.com/bdewey/org-ruby
83
69
  licenses: []
84
-
85
70
  post_install_message:
86
- rdoc_options:
71
+ rdoc_options:
87
72
  - --main
88
73
  - README.rdoc
89
- require_paths:
74
+ require_paths:
90
75
  - lib
91
- required_ruby_version: !ruby/object:Gem::Requirement
76
+ required_ruby_version: !ruby/object:Gem::Requirement
92
77
  none: false
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- hash: 3
97
- segments:
98
- - 0
99
- version: "0"
100
- required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
83
  none: false
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- hash: 3
106
- segments:
107
- - 0
108
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
109
88
  requirements: []
110
-
111
89
  rubyforge_project: org-ruby
112
90
  rubygems_version: 1.8.10
113
91
  signing_key:
114
92
  specification_version: 3
115
93
  summary: This gem contains Ruby routines for parsing org-mode files.
116
- test_files:
117
- - test/test_orgmode_parser.rb
94
+ test_files: []
File without changes