org-ruby 0.8.0 → 0.8.1
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/html_output_buffer.rb +20 -10
- data/lib/org-ruby/line.rb +1 -4
- data/lib/org-ruby/output_buffer.rb +6 -4
- data/lib/org-ruby/parser.rb +3 -3
- data/lib/org-ruby/regexp_helper.rb +11 -7
- data/lib/org-ruby.rb +1 -1
- metadata +6 -5
data/History.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'cgi'
|
1
2
|
begin
|
2
3
|
require 'pygments'
|
3
4
|
rescue LoadError
|
@@ -110,11 +111,12 @@ module Orgmode
|
|
110
111
|
strip_code_block! if mode_is_code? current_mode
|
111
112
|
|
112
113
|
# NOTE: CodeRay and Pygments already escape the html once, so
|
113
|
-
# no need to
|
114
|
+
# no need to escapeHTML
|
114
115
|
case
|
115
116
|
when (current_mode == :src and defined? Pygments)
|
116
117
|
lang = normalize_lang @block_lang
|
117
118
|
@output << "\n" unless @new_paragraph == :start
|
119
|
+
@new_paragraph = true
|
118
120
|
|
119
121
|
begin
|
120
122
|
@buffer = Pygments.highlight(@buffer, :lexer => lang)
|
@@ -138,7 +140,8 @@ module Orgmode
|
|
138
140
|
@buffer.gsub!(/\A\n/, "") if @new_paragraph == :start
|
139
141
|
@new_paragraph = true
|
140
142
|
else
|
141
|
-
|
143
|
+
# *NOTE* Don't use escape_buffer! through its sensitivity to @<text> forms
|
144
|
+
@buffer = CGI::escapeHTML @buffer
|
142
145
|
end
|
143
146
|
|
144
147
|
# Whitespace is significant in :code mode. Always output the
|
@@ -201,8 +204,9 @@ module Orgmode
|
|
201
204
|
@output << "\n<div id=\"footnotes\">\n<h2 class=\"footnotes\">Footnotes:</h2>\n<div id=\"text-footnotes\">\n"
|
202
205
|
|
203
206
|
@footnotes.each do |name, defi|
|
207
|
+
@buffer = defi
|
204
208
|
@output << "<p class=\"footnote\"><sup><a class=\"footnum\" name=\"fn.#{name}\" href=\"#fnr.#{name}\">#{name}</a></sup>" \
|
205
|
-
<< inline_formatting(
|
209
|
+
<< inline_formatting(@buffer) \
|
206
210
|
<< "</p>\n"
|
207
211
|
end
|
208
212
|
|
@@ -229,21 +233,21 @@ module Orgmode
|
|
229
233
|
end
|
230
234
|
|
231
235
|
# Escapes any HTML content in the output accumulation buffer @buffer.
|
232
|
-
def
|
233
|
-
|
236
|
+
def escape_buffer!
|
237
|
+
@buffer.gsub!(/&/, "&")
|
234
238
|
# Escapes the left and right angular brackets but construction
|
235
239
|
# @<text> which is formatted to <text>
|
236
|
-
|
240
|
+
@buffer.gsub! /<([^<>\n]*)/ do |match|
|
237
241
|
if $`[-1..-1] == "@" and $'[0..0] == ">" then $&
|
238
242
|
else "<#{$1}"
|
239
243
|
end
|
240
244
|
end
|
241
|
-
|
245
|
+
@buffer.gsub! /([^<>\n]*)>/ do |match|
|
242
246
|
if $`[-2..-1] == "@<" then $&
|
243
247
|
else "#{$1}>"
|
244
248
|
end
|
245
249
|
end
|
246
|
-
|
250
|
+
@buffer.gsub!(/@(<[^<>\n]*>)/, "\\1")
|
247
251
|
end
|
248
252
|
|
249
253
|
def buffer_indentation
|
@@ -269,7 +273,12 @@ module Orgmode
|
|
269
273
|
# Applies inline formatting rules to a string.
|
270
274
|
def inline_formatting(str)
|
271
275
|
@re_help.rewrite_emphasis str do |marker, s|
|
272
|
-
"
|
276
|
+
if marker == "=" or marker == "~"
|
277
|
+
s = CGI::escapeHTML s
|
278
|
+
"<#{Tags[marker][:open]}>#{s}</#{Tags[marker][:close]}>"
|
279
|
+
else
|
280
|
+
"@<#{Tags[marker][:open]}>#{s}@</#{Tags[marker][:close]}>"
|
281
|
+
end
|
273
282
|
end
|
274
283
|
if @options[:use_sub_superscripts] then
|
275
284
|
@re_help.rewrite_subp str do |type, text|
|
@@ -319,7 +328,7 @@ module Orgmode
|
|
319
328
|
"@<sup>@<a class=\"footref\" name=\"fnr.#{name}\" href=\"#fn.#{name}\">#{name}@</a>@</sup>"
|
320
329
|
end
|
321
330
|
end
|
322
|
-
|
331
|
+
escape_buffer!
|
323
332
|
Orgmode.special_symbols_to_html str
|
324
333
|
str = @re_help.restore_code_snippets str
|
325
334
|
end
|
@@ -346,6 +355,7 @@ module Orgmode
|
|
346
355
|
end
|
347
356
|
|
348
357
|
def strip_code_block!
|
358
|
+
@code_block_indent ||= 0
|
349
359
|
strip_regexp = Regexp.new("^" + " " * @code_block_indent)
|
350
360
|
@buffer.gsub!(strip_regexp, "")
|
351
361
|
@code_block_indent = nil
|
data/lib/org-ruby/line.rb
CHANGED
@@ -3,9 +3,6 @@ module Orgmode
|
|
3
3
|
# Represents a single line of an orgmode file.
|
4
4
|
class Line
|
5
5
|
|
6
|
-
# This is the line itself.
|
7
|
-
attr_reader :line
|
8
|
-
|
9
6
|
# The indent level of this line. this is important to properly translate
|
10
7
|
# nested lists from orgmode to textile.
|
11
8
|
# TODO 2009-12-20 bdewey: Handle tabs
|
@@ -125,7 +122,7 @@ module Orgmode
|
|
125
122
|
return strip_unordered_list_tag if unordered_list?
|
126
123
|
return @line.sub(InlineExampleRegexp, "") if inline_example?
|
127
124
|
return strip_raw_text_tag if raw_text?
|
128
|
-
return line
|
125
|
+
return @line
|
129
126
|
end
|
130
127
|
|
131
128
|
def plain_text?
|
@@ -91,10 +91,12 @@ module Orgmode
|
|
91
91
|
if mode_is_code? current_mode and not line.block_type
|
92
92
|
# Determines the amount of whitespaces to be stripped at the
|
93
93
|
# beginning of each line in code block.
|
94
|
-
if
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
if line.paragraph_type != :blank
|
95
|
+
if @code_block_indent
|
96
|
+
@code_block_indent = [@code_block_indent, line.indent].min
|
97
|
+
else
|
98
|
+
@code_block_indent = line.indent
|
99
|
+
end
|
98
100
|
end
|
99
101
|
end
|
100
102
|
|
data/lib/org-ruby/parser.rb
CHANGED
@@ -106,8 +106,8 @@ module Orgmode
|
|
106
106
|
|
107
107
|
case mode
|
108
108
|
when :normal, :quote, :center
|
109
|
-
if Headline.headline? line.
|
110
|
-
line = Headline.new line.
|
109
|
+
if Headline.headline? line.to_s
|
110
|
+
line = Headline.new line.to_s, self, offset
|
111
111
|
elsif line.table_separator?
|
112
112
|
if previous_line and previous_line.paragraph_type == :table_row and !table_header_set
|
113
113
|
previous_line.assigned_paragraph_type = :table_header
|
@@ -123,7 +123,7 @@ module Orgmode
|
|
123
123
|
end
|
124
124
|
|
125
125
|
if mode == :normal
|
126
|
-
@headlines << @current_headline = line if Headline.headline? line.
|
126
|
+
@headlines << @current_headline = line if Headline.headline? line.to_s
|
127
127
|
# If there is a setting on this line, remember it.
|
128
128
|
line.in_buffer_setting? do |key, value|
|
129
129
|
store_in_buffer_setting key.upcase, value
|
@@ -95,14 +95,18 @@ module Orgmode
|
|
95
95
|
str.gsub!(/%/, "%%")
|
96
96
|
format_str = "%s"
|
97
97
|
str.gsub! @org_emphasis_regexp do |match|
|
98
|
+
pre = $1
|
98
99
|
# preserve the code snippet from further formatting
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
100
|
+
if $2 == "=" or $2 == "~"
|
101
|
+
inner = yield $2, $3
|
102
|
+
# code is not formatted, so turn to single percent signs
|
103
|
+
inner.gsub!(/%%/, "%")
|
104
|
+
@code_snippet_stack.push inner
|
105
|
+
"#{pre}#{format_str}"
|
106
|
+
else
|
107
|
+
inner = yield $2, $3
|
108
|
+
"#{pre}#{inner}"
|
109
|
+
end
|
106
110
|
end
|
107
111
|
end
|
108
112
|
|
data/lib/org-ruby.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.8.
|
4
|
+
version: 0.8.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-17 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubypants
|
16
|
-
requirement: &
|
16
|
+
requirement: &70245565801460 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,8 +21,9 @@ dependencies:
|
|
21
21
|
version: 0.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
-
description: ! 'This gem contains Ruby routines
|
24
|
+
version_requirements: *70245565801460
|
25
|
+
description: ! 'An org-mode parser written in Ruby. This gem contains Ruby routines
|
26
|
+
for parsing org-mode files.The most
|
26
27
|
|
27
28
|
significant thing this library does today is convert org-mode files to
|
28
29
|
|