org-ruby 0.9.3 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +5 -0
- data/lib/org-ruby.rb +1 -0
- data/lib/org-ruby/html_output_buffer.rb +17 -13
- data/lib/org-ruby/line.rb +4 -0
- data/lib/org-ruby/output_buffer.rb +3 -3
- data/lib/org-ruby/parser.rb +13 -2
- data/lib/org-ruby/version.rb +1 -1
- metadata +5 -4
data/History.txt
CHANGED
data/lib/org-ruby.rb
CHANGED
@@ -1,14 +1,3 @@
|
|
1
|
-
begin
|
2
|
-
require 'pygments'
|
3
|
-
rescue LoadError
|
4
|
-
# Pygments is not supported so we try instead with CodeRay
|
5
|
-
begin
|
6
|
-
require 'coderay'
|
7
|
-
rescue LoadError
|
8
|
-
# No code syntax highlighting
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
1
|
module Orgmode
|
13
2
|
|
14
3
|
class HtmlOutputBuffer < OutputBuffer
|
@@ -47,6 +36,19 @@ module Orgmode
|
|
47
36
|
@footnotes = {}
|
48
37
|
@unclosed_tags = []
|
49
38
|
@logger.debug "HTML export options: #{@options.inspect}"
|
39
|
+
|
40
|
+
unless @options[:skip_syntax_highlight]
|
41
|
+
begin
|
42
|
+
require 'pygments'
|
43
|
+
rescue LoadError
|
44
|
+
# Pygments is not supported so we try instead with CodeRay
|
45
|
+
begin
|
46
|
+
require 'coderay'
|
47
|
+
rescue LoadError
|
48
|
+
# No code syntax highlighting
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
50
52
|
end
|
51
53
|
|
52
54
|
# Output buffer is entering a new mode. Use this opportunity to
|
@@ -57,7 +59,7 @@ module Orgmode
|
|
57
59
|
|
58
60
|
if HtmlBlockTag[mode]
|
59
61
|
unless ((mode_is_table?(mode) and skip_tables?) or
|
60
|
-
(mode == :src and defined? Pygments))
|
62
|
+
(mode == :src and !@options[:skip_syntax_highlight] and defined? Pygments))
|
61
63
|
css_class = case
|
62
64
|
when (mode == :src and @block_lang.empty?)
|
63
65
|
" class=\"src\""
|
@@ -88,7 +90,7 @@ module Orgmode
|
|
88
90
|
m = super(mode)
|
89
91
|
if HtmlBlockTag[m]
|
90
92
|
unless ((mode_is_table?(m) and skip_tables?) or
|
91
|
-
(m == :src and defined? Pygments))
|
93
|
+
(m == :src and !@options[:skip_syntax_highlight] and defined? Pygments))
|
92
94
|
add_paragraph if @new_paragraph
|
93
95
|
@new_paragraph = true
|
94
96
|
@logger.debug "</#{HtmlBlockTag[m]}>"
|
@@ -107,6 +109,8 @@ module Orgmode
|
|
107
109
|
# NOTE: CodeRay and Pygments already escape the html once, so
|
108
110
|
# no need to escapeHTML
|
109
111
|
case
|
112
|
+
when (current_mode == :src and @options[:skip_syntax_highlight])
|
113
|
+
@buffer = escapeHTML @buffer
|
110
114
|
when (current_mode == :src and defined? Pygments)
|
111
115
|
lang = normalize_lang @block_lang
|
112
116
|
@output << "\n" unless @new_paragraph == :start
|
data/lib/org-ruby/line.rb
CHANGED
@@ -24,12 +24,16 @@ module Orgmode
|
|
24
24
|
# type. This will then affect the value of +paragraph_type+.
|
25
25
|
attr_accessor :assigned_paragraph_type
|
26
26
|
|
27
|
+
# In case more contextual info is needed we can put here
|
28
|
+
attr_accessor :properties
|
29
|
+
|
27
30
|
def initialize(line, parser=nil, assigned_paragraph_type=nil)
|
28
31
|
@parser = parser
|
29
32
|
@line = line
|
30
33
|
@indent = 0
|
31
34
|
@line =~ /\s*/
|
32
35
|
@assigned_paragraph_type = assigned_paragraph_type
|
36
|
+
@properties = { }
|
33
37
|
determine_paragraph_type
|
34
38
|
determine_major_mode
|
35
39
|
@indent = $&.length unless blank?
|
data/lib/org-ruby/parser.rb
CHANGED
@@ -183,7 +183,10 @@ module Orgmode
|
|
183
183
|
table_header_set = false if !line.table?
|
184
184
|
|
185
185
|
when :example, :html, :src
|
186
|
-
|
186
|
+
if previous_line
|
187
|
+
set_name_for_code_block(previous_line, line)
|
188
|
+
set_mode_for_results_block_contents(previous_line, line)
|
189
|
+
end
|
187
190
|
|
188
191
|
# As long as we stay in code mode, force lines to be code.
|
189
192
|
# Don't try to interpret structural items, like headings and tables.
|
@@ -200,6 +203,7 @@ module Orgmode
|
|
200
203
|
mode = line.paragraph_type if line.begin_block?
|
201
204
|
|
202
205
|
if previous_line
|
206
|
+
set_name_for_code_block(previous_line, line)
|
203
207
|
set_mode_for_results_block_contents(previous_line, line)
|
204
208
|
|
205
209
|
mode = :property_drawer if previous_line.property_drawer_begin_block?
|
@@ -274,6 +278,12 @@ module Orgmode
|
|
274
278
|
include_data
|
275
279
|
end
|
276
280
|
|
281
|
+
def set_name_for_code_block(previous_line, line)
|
282
|
+
previous_line.in_buffer_setting? do |key, value|
|
283
|
+
line.properties['block_name'] = value if key.downcase == 'name'
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
277
287
|
def set_mode_for_results_block_contents(previous_line, line)
|
278
288
|
if previous_line.start_of_results_code_block? \
|
279
289
|
or previous_line.assigned_paragraph_type == :comment
|
@@ -331,7 +341,8 @@ module Orgmode
|
|
331
341
|
:export_todo => export_todo?,
|
332
342
|
:use_sub_superscripts => use_sub_superscripts?,
|
333
343
|
:export_footnotes => export_footnotes?,
|
334
|
-
:link_abbrevs => @link_abbrevs
|
344
|
+
:link_abbrevs => @link_abbrevs,
|
345
|
+
:skip_syntax_highlight => @parser_options[:skip_syntax_highlight]
|
335
346
|
}
|
336
347
|
export_options[:skip_tables] = true if not export_tables?
|
337
348
|
output = ""
|
data/lib/org-ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: org-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-04-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubypants
|
17
|
-
requirement: &
|
17
|
+
requirement: &70356891100960 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: 0.2.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70356891100960
|
26
26
|
description: An Org mode parser written in Ruby.
|
27
27
|
email: waldemar.quevedo@gmail.com
|
28
28
|
executables:
|
@@ -75,3 +75,4 @@ signing_key:
|
|
75
75
|
specification_version: 3
|
76
76
|
summary: This gem contains Ruby routines for parsing org-mode files.
|
77
77
|
test_files: []
|
78
|
+
has_rdoc:
|