RbST 0.0.2 → 0.1.0
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/README.markdown +5 -5
- data/RbST.gemspec +2 -2
- data/VERSION +1 -1
- data/lib/rbst.rb +11 -6
- data/test/test_rbst.rb +8 -0
- metadata +2 -2
data/README.markdown
CHANGED
@@ -22,23 +22,23 @@ RbST is available on [gemcutter](http://gemcutter.org/gems/RbST).
|
|
22
22
|
|
23
23
|
This takes the reStructuredText formatted file and converts it to either HTML or LaTeX. The first argument can be either a file or a string.
|
24
24
|
|
25
|
-
You can also use the
|
25
|
+
You can also use the `convert` class method to output HTML:
|
26
26
|
|
27
27
|
puts RbST.convert('/some/file.rst')
|
28
28
|
|
29
|
-
|
29
|
+
Arguments can be passed to `#to_html`, `#to_latex`, `new` or `convert`, accepting symbols or strings for options without arguments and hashes of strings or symbols for options with arguments.
|
30
30
|
|
31
|
-
puts RbST.
|
31
|
+
puts RbST.new(".. a comment").to_html('strip-comments')
|
32
32
|
# => '<div class="document">\n</div>'
|
33
33
|
|
34
34
|
Options passed as string use hyphens while symbols use underscores. For instance, the above could also be written as:
|
35
35
|
|
36
|
-
puts RbST.
|
36
|
+
puts RbST.new(".. a comment").to_html(:strip_comments)
|
37
37
|
# => '<div class="document">\n</div>'
|
38
38
|
|
39
39
|
Document parts can also be specified with the `:parts` option.
|
40
40
|
|
41
|
-
puts RbST.
|
41
|
+
puts RbST.new("hello world").to_html(:part => :fragment)
|
42
42
|
# => '<p>hello world</p>'
|
43
43
|
|
44
44
|
By default, RbST uses the `html_body` part for HTML and the `whole` part for LaTeX.
|
data/RbST.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{RbST}
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["William Melody"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-20}
|
13
13
|
s.description = %q{A simple Ruby wrapper for processing reStructuredText via Python's Docutils}
|
14
14
|
s.email = %q{wmelody@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/rbst.rb
CHANGED
@@ -24,19 +24,24 @@ class RbST
|
|
24
24
|
@options = args
|
25
25
|
end
|
26
26
|
|
27
|
-
def convert
|
28
|
-
|
27
|
+
def convert # :nodoc:
|
28
|
+
@output_format ||= :html
|
29
|
+
execute "python #{RbST.executable(@output_format)}" + convert_options
|
29
30
|
end
|
30
31
|
alias_method :to_s, :convert
|
31
32
|
|
32
33
|
# Converts the object's input to HTML.
|
33
|
-
def to_html
|
34
|
-
|
34
|
+
def to_html(*args)
|
35
|
+
@output_format = :html
|
36
|
+
@options += args
|
37
|
+
convert
|
35
38
|
end
|
36
39
|
|
37
40
|
# Converts the object's input to LaTeX.
|
38
|
-
def to_latex
|
39
|
-
|
41
|
+
def to_latex(*args)
|
42
|
+
@output_format = :latex
|
43
|
+
@options += args
|
44
|
+
convert
|
40
45
|
end
|
41
46
|
|
42
47
|
# Formats and prints the options from the docutils help in the way they'd be specified in RbST: strings, symbols and hashes.
|
data/test/test_rbst.rb
CHANGED
@@ -27,6 +27,14 @@ class TestRbST < Test::Unit::TestCase
|
|
27
27
|
assert_equal latex, File.read(@latex_file)
|
28
28
|
end
|
29
29
|
|
30
|
+
[:html, :latex].each do |f|
|
31
|
+
should "accept options on #to_#{f}" do
|
32
|
+
converter = RbST.new(@rst_file)
|
33
|
+
converter.expects(:execute).with("python ./test/../lib/rst2parts/rst2#{f}.py --raw-enabled").returns(true)
|
34
|
+
assert converter.send("to_#{f}", :raw_enabled)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
30
38
|
should "recognize strip_comments option" do
|
31
39
|
html_with_comment = RbST.convert(".. comment")
|
32
40
|
assert_equal html_with_comment, %Q{<div class="document">\n<!-- comment -->\n</div>}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: RbST
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Melody
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-21 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|