org-ruby 0.5.2 → 0.5.3
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/.bnsignore +18 -0
- data/.gitignore +1 -0
- data/History.txt +4 -0
- data/bin/org-ruby +5 -0
- data/lib/org-ruby.rb +1 -1
- data/lib/org-ruby/html_output_buffer.rb +3 -0
- data/lib/org-ruby/output_buffer.rb +1 -1
- data/lib/org-ruby/regexp_helper.rb +14 -1
- data/spec/html_examples/inline-images.html +10 -0
- data/spec/html_examples/inline-images.org +15 -0
- metadata +7 -2
data/.bnsignore
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# The list of files that should be ignored by Mr Bones.
|
2
|
+
# Lines that start with '#' are comments.
|
3
|
+
#
|
4
|
+
# A .gitignore file can be used instead by setting it as the ignore
|
5
|
+
# file in your Rakefile:
|
6
|
+
#
|
7
|
+
# Bones {
|
8
|
+
# ignore_file '.gitignore'
|
9
|
+
# }
|
10
|
+
#
|
11
|
+
# For a project with a C extension, the following would be a good set of
|
12
|
+
# exclude patterns (uncomment them if you want to use them):
|
13
|
+
# *.[oa]
|
14
|
+
# *~
|
15
|
+
announcement.txt
|
16
|
+
coverage
|
17
|
+
doc
|
18
|
+
pkg
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.tmproj
|
data/History.txt
CHANGED
data/bin/org-ruby
CHANGED
@@ -17,6 +17,10 @@ options_parser = OptionParser.new do |opts|
|
|
17
17
|
options[:help] = true
|
18
18
|
end
|
19
19
|
|
20
|
+
opts.on("-d", "--debug", "Run with $DEBUG true") do |v|
|
21
|
+
options[:debug] = true
|
22
|
+
end
|
23
|
+
|
20
24
|
opts.on("-t", "--translate FORMAT", [:html, :textile],
|
21
25
|
"Translate the ORG file to the specified format.") do |v|
|
22
26
|
options[:format] = v
|
@@ -30,6 +34,7 @@ begin
|
|
30
34
|
else
|
31
35
|
data = IO.read(ARGV[0])
|
32
36
|
p = Orgmode::Parser.new(data)
|
37
|
+
$DEBUG = true if options[:debug]
|
33
38
|
puts p.to_html if options[:format] == :html
|
34
39
|
puts p.to_textile if options[:format] == :textile
|
35
40
|
end
|
data/lib/org-ruby.rb
CHANGED
@@ -145,6 +145,9 @@ module Orgmode
|
|
145
145
|
str = @re_help.rewrite_emphasis(str) do |marker, s|
|
146
146
|
"#{Tags[marker][:open]}#{s}#{Tags[marker][:close]}"
|
147
147
|
end
|
148
|
+
str = @re_help.rewrite_images(str) do |link|
|
149
|
+
"<img src=\"#{link}\" />"
|
150
|
+
end
|
148
151
|
str = @re_help.rewrite_links(str) do |link, text|
|
149
152
|
text ||= link
|
150
153
|
link = link.sub(/^file:(.*)::(.*?)$/) do
|
@@ -14,6 +14,9 @@ module Orgmode
|
|
14
14
|
#
|
15
15
|
# * Use +rewrite_links+ to get a chance to rewrite all org-mode
|
16
16
|
# links with suitable markup for the output.
|
17
|
+
#
|
18
|
+
# * Use +rewrite_images+ to rewrite all inline image links with suitable
|
19
|
+
# markup for the output.
|
17
20
|
class RegexpHelper
|
18
21
|
|
19
22
|
######################################################################
|
@@ -121,7 +124,7 @@ module Orgmode
|
|
121
124
|
# +http://www.hotmail.com+. In both cases, the block returns an
|
122
125
|
# HTML-style link, and that is how things will get recorded in
|
123
126
|
# +result+.
|
124
|
-
def rewrite_links(str)
|
127
|
+
def rewrite_links(str) # :yields: link, text
|
125
128
|
i = str.gsub(@org_link_regexp) do |match|
|
126
129
|
yield $1, nil
|
127
130
|
end
|
@@ -129,6 +132,13 @@ module Orgmode
|
|
129
132
|
yield $1, $2
|
130
133
|
end
|
131
134
|
end
|
135
|
+
|
136
|
+
# Rewrites all of the inline image tags.
|
137
|
+
def rewrite_images(str) # :yields: image_link
|
138
|
+
str.gsub(@org_img_regexp) do |match|
|
139
|
+
yield $1
|
140
|
+
end
|
141
|
+
end
|
132
142
|
|
133
143
|
private
|
134
144
|
|
@@ -146,6 +156,9 @@ module Orgmode
|
|
146
156
|
@org_link_regexp = /\[\[
|
147
157
|
([^\]]*) # This is the URL
|
148
158
|
\]\]/x
|
159
|
+
@org_img_regexp = /\[\[
|
160
|
+
([^\]]*\.(jpg|jpeg|gif|png)) # Like a normal URL, but must end with a specified extension
|
161
|
+
\]\]/xi
|
149
162
|
@org_link_text_regexp = /\[\[
|
150
163
|
([^\]]*) # This is the URL
|
151
164
|
\]\[
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<p class="title">Inline Images</p>
|
2
|
+
<p>Per the org-mode <a href="http://orgmode.org/manual/Images-and-tables.html#Images-and-tables">spec</a>, you can include inline images as links without any descriptive link text, like this:</p>
|
3
|
+
<p><img src="http://farm5.static.flickr.com/4049/4358074549_5efb8b4903.jpg" /></p>
|
4
|
+
<p>I currently do not support the caption/link syntax, but I can include the inline image. I recognize the following image file types:</p>
|
5
|
+
<ul>
|
6
|
+
<li>.jpg</li>
|
7
|
+
<li>.png</li>
|
8
|
+
<li>.gif</li>
|
9
|
+
<li>.jpeg</li>
|
10
|
+
</ul>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Inline Images
|
2
|
+
|
3
|
+
Per the org-mode [[http://orgmode.org/manual/Images-and-tables.html#Images-and-tables][spec]], you can include inline images as links without
|
4
|
+
any descriptive link text, like this:
|
5
|
+
|
6
|
+
[[http://farm5.static.flickr.com/4049/4358074549_5efb8b4903.jpg]]
|
7
|
+
|
8
|
+
I currently do not support the caption/link syntax, but I can include
|
9
|
+
the inline image. I recognize the following image file types:
|
10
|
+
|
11
|
+
- .jpg
|
12
|
+
- .png
|
13
|
+
- .gif
|
14
|
+
- .jpeg
|
15
|
+
|
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.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Dewey
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-02-15 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -47,6 +47,8 @@ extra_rdoc_files:
|
|
47
47
|
- README.rdoc
|
48
48
|
- bin/org-ruby
|
49
49
|
files:
|
50
|
+
- .bnsignore
|
51
|
+
- .gitignore
|
50
52
|
- History.txt
|
51
53
|
- README.rdoc
|
52
54
|
- Rakefile
|
@@ -60,6 +62,7 @@ files:
|
|
60
62
|
- lib/org-ruby/parser.rb
|
61
63
|
- lib/org-ruby/regexp_helper.rb
|
62
64
|
- lib/org-ruby/textile_output_buffer.rb
|
65
|
+
- org-ruby.tmproj
|
63
66
|
- spec/data/freeform-example.org
|
64
67
|
- spec/data/freeform.org
|
65
68
|
- spec/data/hyp-planning.org
|
@@ -97,6 +100,8 @@ files:
|
|
97
100
|
- spec/html_examples/html-literal.org
|
98
101
|
- spec/html_examples/inline-formatting.html
|
99
102
|
- spec/html_examples/inline-formatting.org
|
103
|
+
- spec/html_examples/inline-images.html
|
104
|
+
- spec/html_examples/inline-images.org
|
100
105
|
- spec/html_examples/link-features.html
|
101
106
|
- spec/html_examples/link-features.org
|
102
107
|
- spec/html_examples/lists.html
|