org-ruby 0.9.0 → 0.9.1.gh
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 +4 -0
- data/lib/org-ruby.rb +1 -1
- data/lib/org-ruby/html_output_buffer.rb +43 -16
- data/lib/org-ruby/parser.rb +5 -4
- metadata +7 -11
data/History.txt
CHANGED
data/lib/org-ruby.rb
CHANGED
@@ -1,15 +1,3 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
begin
|
3
|
-
require 'pygments'
|
4
|
-
rescue LoadError
|
5
|
-
# Pygments is not supported so we try instead with CodeRay
|
6
|
-
begin
|
7
|
-
require 'coderay'
|
8
|
-
rescue LoadError
|
9
|
-
# No code syntax highlighting
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
1
|
module Orgmode
|
14
2
|
|
15
3
|
class HtmlOutputBuffer < OutputBuffer
|
@@ -52,6 +40,19 @@ module Orgmode
|
|
52
40
|
@footnotes = {}
|
53
41
|
@unclosed_tags = []
|
54
42
|
@logger.debug "HTML export options: #{@options.inspect}"
|
43
|
+
|
44
|
+
unless @options[:skip_syntax_highlight]
|
45
|
+
begin
|
46
|
+
require 'pygments'
|
47
|
+
rescue LoadError
|
48
|
+
# Pygments is not supported so we try instead with CodeRay
|
49
|
+
begin
|
50
|
+
require 'coderay'
|
51
|
+
rescue LoadError
|
52
|
+
# No code syntax highlighting
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
55
56
|
end
|
56
57
|
|
57
58
|
# Output buffer is entering a new mode. Use this opportunity to
|
@@ -62,7 +63,7 @@ module Orgmode
|
|
62
63
|
|
63
64
|
if HtmlBlockTag[mode]
|
64
65
|
unless ((mode_is_table?(mode) and skip_tables?) or
|
65
|
-
(mode == :src and defined? Pygments))
|
66
|
+
(mode == :src and !@options[:skip_syntax_highlight] and defined? Pygments))
|
66
67
|
css_class = case
|
67
68
|
when (mode == :src and @block_lang.empty?)
|
68
69
|
" class=\"src\""
|
@@ -93,7 +94,7 @@ module Orgmode
|
|
93
94
|
m = super(mode)
|
94
95
|
if HtmlBlockTag[m]
|
95
96
|
unless ((mode_is_table?(m) and skip_tables?) or
|
96
|
-
(m == :src and defined? Pygments))
|
97
|
+
(m == :src and !@options[:skip_syntax_highlight] and defined? Pygments))
|
97
98
|
add_paragraph if @new_paragraph
|
98
99
|
@new_paragraph = true
|
99
100
|
@logger.debug "</#{HtmlBlockTag[m]}>"
|
@@ -112,6 +113,8 @@ module Orgmode
|
|
112
113
|
# NOTE: CodeRay and Pygments already escape the html once, so
|
113
114
|
# no need to escapeHTML
|
114
115
|
case
|
116
|
+
when (current_mode == :src and @options[:skip_syntax_highlight])
|
117
|
+
@buffer = escapeHTML @buffer
|
115
118
|
when (current_mode == :src and defined? Pygments)
|
116
119
|
lang = normalize_lang @block_lang
|
117
120
|
@output << "\n" unless @new_paragraph == :start
|
@@ -140,7 +143,7 @@ module Orgmode
|
|
140
143
|
@new_paragraph = true
|
141
144
|
else
|
142
145
|
# *NOTE* Don't use escape_buffer! through its sensitivity to @<text> forms
|
143
|
-
@buffer =
|
146
|
+
@buffer = escapeHTML @buffer
|
144
147
|
end
|
145
148
|
|
146
149
|
# Whitespace is significant in :code mode. Always output the
|
@@ -275,7 +278,7 @@ module Orgmode
|
|
275
278
|
def inline_formatting(str)
|
276
279
|
@re_help.rewrite_emphasis str do |marker, s|
|
277
280
|
if marker == "=" or marker == "~"
|
278
|
-
s =
|
281
|
+
s = escapeHTML s
|
279
282
|
"<#{Tags[marker][:open]}>#{s}</#{Tags[marker][:close]}>"
|
280
283
|
else
|
281
284
|
"@<#{Tags[marker][:open]}>#{s}@</#{Tags[marker][:close]}>"
|
@@ -371,5 +374,29 @@ module Orgmode
|
|
371
374
|
"#{$2}#{$3}"
|
372
375
|
end
|
373
376
|
end
|
377
|
+
|
378
|
+
# The CGI::escapeHTML function backported from the Ruby standard library
|
379
|
+
# as of commit fd2fc885b43283aa3d76820b2dfa9de19a77012f
|
380
|
+
#
|
381
|
+
# Implementation of the cgi module can change among Ruby versions
|
382
|
+
# so stabilizing on a single one here to avoid surprises.
|
383
|
+
#
|
384
|
+
# https://github.com/ruby/ruby/blob/trunk/lib/cgi/util.rb
|
385
|
+
#
|
386
|
+
# The set of special characters and their escaped values
|
387
|
+
TABLE_FOR_ESCAPE_HTML__ = {
|
388
|
+
"'" => ''',
|
389
|
+
'&' => '&',
|
390
|
+
'"' => '"',
|
391
|
+
'<' => '<',
|
392
|
+
'>' => '>',
|
393
|
+
}
|
394
|
+
# Escape special characters in HTML, namely &\"<>
|
395
|
+
# escapeHTML('Usage: foo "bar" <baz>')
|
396
|
+
# # => "Usage: foo "bar" <baz>"
|
397
|
+
private
|
398
|
+
def escapeHTML(string)
|
399
|
+
string.gsub(/['&\"<>]/, TABLE_FOR_ESCAPE_HTML__)
|
400
|
+
end
|
374
401
|
end # class HtmlOutputBuffer
|
375
402
|
end # module Orgmode
|
data/lib/org-ruby/parser.rb
CHANGED
@@ -303,10 +303,11 @@ module Orgmode
|
|
303
303
|
export_options = {
|
304
304
|
:decorate_title => @in_buffer_settings["TITLE"],
|
305
305
|
:export_heading_number => export_heading_number?,
|
306
|
-
:export_todo
|
307
|
-
:use_sub_superscripts
|
308
|
-
:export_footnotes
|
309
|
-
:link_abbrevs
|
306
|
+
:export_todo => export_todo?,
|
307
|
+
:use_sub_superscripts => use_sub_superscripts?,
|
308
|
+
:export_footnotes => export_footnotes?,
|
309
|
+
:link_abbrevs => @link_abbrevs,
|
310
|
+
:skip_syntax_highlight => @parser_options[:skip_syntax_highlight]
|
310
311
|
}
|
311
312
|
export_options[:skip_tables] = true if not export_tables?
|
312
313
|
output = ""
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: org-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
5
|
-
prerelease:
|
4
|
+
version: 0.9.1.gh
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brian Dewey
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubypants
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70363196176300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,12 +21,7 @@ dependencies:
|
|
21
21
|
version: 0.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 0.2.0
|
24
|
+
version_requirements: *70363196176300
|
30
25
|
description: ! 'An org-mode parser written in Ruby. This gem contains Ruby routines
|
31
26
|
for parsing org-mode files.The most
|
32
27
|
|
@@ -84,8 +79,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
79
|
version: '0'
|
85
80
|
requirements: []
|
86
81
|
rubyforge_project: org-ruby
|
87
|
-
rubygems_version: 1.8.
|
82
|
+
rubygems_version: 1.8.10
|
88
83
|
signing_key:
|
89
84
|
specification_version: 3
|
90
85
|
summary: This gem contains Ruby routines for parsing org-mode files.
|
91
86
|
test_files: []
|
87
|
+
has_rdoc:
|