org-ruby 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/.bnsignore +18 -0
  2. data/History.txt +40 -32
  3. data/README.txt +66 -66
  4. data/Rakefile +27 -26
  5. data/bin/org-ruby +40 -40
  6. data/lib/org-ruby.rb +50 -50
  7. data/lib/org-ruby/headline.rb +80 -75
  8. data/lib/org-ruby/html_output_buffer.rb +105 -81
  9. data/lib/org-ruby/line.rb +173 -173
  10. data/lib/org-ruby/output_buffer.rb +172 -154
  11. data/lib/org-ruby/parser.rb +80 -76
  12. data/lib/org-ruby/regexp_helper.rb +156 -156
  13. data/lib/org-ruby/textile_output_buffer.rb +67 -67
  14. data/spec/data/freeform.org +111 -111
  15. data/spec/data/hyp-planning.org +335 -335
  16. data/spec/data/remember.org +53 -53
  17. data/spec/headline_spec.rb +55 -55
  18. data/spec/html_examples/advanced-lists.html +31 -0
  19. data/spec/html_examples/advanced-lists.org +31 -0
  20. data/spec/html_examples/block_code.html +30 -30
  21. data/spec/html_examples/block_code.org +35 -35
  22. data/spec/html_examples/blockquote.html +7 -7
  23. data/spec/html_examples/blockquote.org +13 -13
  24. data/spec/html_examples/escape-pre.html +7 -7
  25. data/spec/html_examples/escape-pre.org +6 -6
  26. data/spec/html_examples/inline-formatting.html +10 -10
  27. data/spec/html_examples/inline-formatting.org +17 -17
  28. data/spec/html_examples/lists.html +19 -19
  29. data/spec/html_examples/lists.org +36 -36
  30. data/spec/html_examples/only-list.html +5 -5
  31. data/spec/html_examples/only-list.org +3 -3
  32. data/spec/html_examples/only-table.html +6 -6
  33. data/spec/html_examples/only-table.org +5 -5
  34. data/spec/html_examples/tables.html +20 -20
  35. data/spec/html_examples/tables.org +26 -26
  36. data/spec/html_examples/text.html +2 -2
  37. data/spec/html_examples/text.org +16 -16
  38. data/spec/line_spec.rb +89 -89
  39. data/spec/parser_spec.rb +86 -86
  40. data/spec/regexp_helper_spec.rb +57 -57
  41. data/spec/spec_helper.rb +20 -20
  42. data/spec/textile_examples/block_code.org +35 -35
  43. data/spec/textile_examples/block_code.textile +29 -29
  44. data/spec/textile_examples/blockquote.org +13 -13
  45. data/spec/textile_examples/blockquote.textile +11 -11
  46. data/spec/textile_examples/keywords.org +13 -13
  47. data/spec/textile_examples/keywords.textile +11 -11
  48. data/spec/textile_examples/links.org +11 -11
  49. data/spec/textile_examples/links.textile +10 -10
  50. data/spec/textile_examples/lists.org +36 -36
  51. data/spec/textile_examples/lists.textile +20 -20
  52. data/spec/textile_examples/single-space-plain-list.org +13 -13
  53. data/spec/textile_examples/single-space-plain-list.textile +10 -10
  54. data/spec/textile_examples/tables.org +26 -26
  55. data/spec/textile_examples/tables.textile +23 -23
  56. data/spec/textile_output_buffer_spec.rb +21 -21
  57. data/tasks/test_case.rake +49 -49
  58. metadata +5 -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/History.txt CHANGED
@@ -1,32 +1,40 @@
1
- == 0.3.0 / 2009-12-27
2
-
3
- * Uses rubypants to get better typography (smart quotes, elipses, etc.).
4
- * Fixed bugs:
5
- * Tables and lists did not get properly closed at the end of file
6
- * You couldn't do inline formatting inside table cells
7
- * Characters in PRE blocks were not HTML escaped.
8
-
9
- == 0.2.0 / 2009-12-26
10
-
11
- * Renamed the gem to org-ruby
12
- * Added +to_html+ for HTML output
13
- * Now supports the following inline markup:
14
- * bold
15
- * italic
16
- * code
17
- * verbatim
18
- * underline
19
- * strikethrough
20
- * Continued code cleanup and refactoring
21
-
22
- == 0.1.0 / 2009-12-23
23
-
24
- * Added support for block code
25
- * Added support for list items that wrap in the org source
26
- * Major code cleanup:
27
- Added +OutputBuffer+ class that should make the code more maintainable.
28
-
29
- == 0.0.2 / 2009-12-21
30
-
31
- * Initial version. Handles tables (but not headers), headlines,
32
- paragraphs, block quotes, strong & emphasis formatting.
1
+ == 0.4.0 / 2009-12-28
2
+
3
+ * The first thing output in HTML gets the class "title"
4
+ * HTML output is now indented
5
+ * Proper support for multi-paragraph list items.
6
+ * Fixed bugs:
7
+ * "rake spec" wouldn't work on Linux. Needed "require 'rubygems'".
8
+
9
+ == 0.3.0 / 2009-12-27
10
+
11
+ * Uses rubypants to get better typography (smart quotes, elipses, etc.).
12
+ * Fixed bugs:
13
+ * Tables and lists did not get properly closed at the end of file
14
+ * You couldn't do inline formatting inside table cells
15
+ * Characters in PRE blocks were not HTML escaped.
16
+
17
+ == 0.2.0 / 2009-12-26
18
+
19
+ * Renamed the gem to org-ruby
20
+ * Added +to_html+ for HTML output
21
+ * Now supports the following inline markup:
22
+ * bold
23
+ * italic
24
+ * code
25
+ * verbatim
26
+ * underline
27
+ * strikethrough
28
+ * Continued code cleanup and refactoring
29
+
30
+ == 0.1.0 / 2009-12-23
31
+
32
+ * Added support for block code
33
+ * Added support for list items that wrap in the org source
34
+ * Major code cleanup:
35
+ Added +OutputBuffer+ class that should make the code more maintainable.
36
+
37
+ == 0.0.2 / 2009-12-21
38
+
39
+ * Initial version. Handles tables (but not headers), headlines,
40
+ paragraphs, block quotes, strong & emphasis formatting.
data/README.txt CHANGED
@@ -1,66 +1,66 @@
1
- org-ruby
2
- by Brian Dewey
3
- http://github.com/bdewey/org-ruby
4
-
5
- == DESCRIPTION:
6
-
7
- This gem contains Ruby routines for parsing org-mode files.The most
8
- significant thing this library does today is convert org-mode files to
9
- HTML or textile. Currently, you cannot do much to customize the
10
- conversion. The supplied textile conversion is optimized for
11
- extracting "content" from the orgfile as opposed to "metadata."
12
-
13
- == FEATURES/PROBLEMS:
14
-
15
- * Converts org-mode files to HTML or Textile
16
- * Supports tables, block quotes, and block code
17
- * Supports bold, italic, underline, strikethrough, and code inline formatting.
18
- * Supports hyperlinks that are in double-brackets
19
- * Upcoming: Handle export options specified in the org buffer.
20
-
21
- == SYNOPSIS:
22
-
23
- From the command line:
24
-
25
- org-ruby sample.org
26
-
27
- ...will output a HTML version of sample.org.
28
-
29
- org-ruby --translate textile sample.org
30
-
31
- ...will output a textile version of sample.org.
32
-
33
- From Ruby code:
34
-
35
- Orgmode::Parser.new(data)
36
-
37
- ...will construct a new +Parser+ object.
38
-
39
- == INSTALL:
40
-
41
- sudo gem install org-ruby
42
-
43
- == LICENSE:
44
-
45
- (The MIT License)
46
-
47
- Copyright (c) 2009 Brian Dewey
48
-
49
- Permission is hereby granted, free of charge, to any person obtaining
50
- a copy of this software and associated documentation files (the
51
- 'Software'), to deal in the Software without restriction, including
52
- without limitation the rights to use, copy, modify, merge, publish,
53
- distribute, sublicense, and/or sell copies of the Software, and to
54
- permit persons to whom the Software is furnished to do so, subject to
55
- the following conditions:
56
-
57
- The above copyright notice and this permission notice shall be
58
- included in all copies or substantial portions of the Software.
59
-
60
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
61
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
62
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
63
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
64
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
65
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
66
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ org-ruby
2
+ by Brian Dewey
3
+ http://github.com/bdewey/org-ruby
4
+
5
+ == DESCRIPTION:
6
+
7
+ This gem contains Ruby routines for parsing org-mode files.The most
8
+ significant thing this library does today is convert org-mode files to
9
+ HTML or textile. Currently, you cannot do much to customize the
10
+ conversion. The supplied textile conversion is optimized for
11
+ extracting "content" from the orgfile as opposed to "metadata."
12
+
13
+ == FEATURES/PROBLEMS:
14
+
15
+ * Converts org-mode files to HTML or Textile
16
+ * Supports tables, block quotes, and block code
17
+ * Supports bold, italic, underline, strikethrough, and code inline formatting.
18
+ * Supports hyperlinks that are in double-brackets
19
+ * Upcoming: Handle export options specified in the org buffer.
20
+
21
+ == SYNOPSIS:
22
+
23
+ From the command line:
24
+
25
+ org-ruby sample.org
26
+
27
+ ...will output a HTML version of sample.org.
28
+
29
+ org-ruby --translate textile sample.org
30
+
31
+ ...will output a textile version of sample.org.
32
+
33
+ From Ruby code:
34
+
35
+ Orgmode::Parser.new(data)
36
+
37
+ ...will construct a new +Parser+ object.
38
+
39
+ == INSTALL:
40
+
41
+ sudo gem install org-ruby
42
+
43
+ == LICENSE:
44
+
45
+ (The MIT License)
46
+
47
+ Copyright (c) 2009 Brian Dewey
48
+
49
+ Permission is hereby granted, free of charge, to any person obtaining
50
+ a copy of this software and associated documentation files (the
51
+ 'Software'), to deal in the Software without restriction, including
52
+ without limitation the rights to use, copy, modify, merge, publish,
53
+ distribute, sublicense, and/or sell copies of the Software, and to
54
+ permit persons to whom the Software is furnished to do so, subject to
55
+ the following conditions:
56
+
57
+ The above copyright notice and this permission notice shall be
58
+ included in all copies or substantial portions of the Software.
59
+
60
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
61
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
62
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
63
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
64
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
65
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
66
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,26 +1,27 @@
1
-
2
- begin
3
- require 'bones'
4
- rescue LoadError
5
- abort '### Please install the "bones" gem ###'
6
- end
7
-
8
- ensure_in_path 'lib'
9
- require 'org-ruby'
10
-
11
- task :default => 'test:run'
12
- task 'gem:release' => 'test:run'
13
-
14
- Bones {
15
- name 'org-ruby'
16
- authors 'Brian Dewey'
17
- email 'bdewey@gmail.com'
18
- url 'http://github.com/bdewey/org-ruby'
19
- version OrgRuby::VERSION
20
- colorize false # Windows consoles won't colorize
21
- gem.need_tar false # Can't TAR from Windows
22
- depend_on 'rubypants'
23
- }
24
-
25
-
26
- # EOF
1
+
2
+ begin
3
+ require 'bones'
4
+ rescue LoadError
5
+ abort '### Please install the "bones" gem ###'
6
+ end
7
+
8
+ ensure_in_path 'lib'
9
+ require 'org-ruby'
10
+
11
+ task :default => 'test:run'
12
+ task 'gem:release' => 'test:run'
13
+
14
+ Bones {
15
+ name 'org-ruby'
16
+ authors 'Brian Dewey'
17
+ email 'bdewey@gmail.com'
18
+ url 'http://github.com/bdewey/org-ruby'
19
+ version OrgRuby::VERSION
20
+ colorize false # Windows consoles won't colorize
21
+ gem.need_tar false # Can't TAR from Windows
22
+ depend_on 'rubypants'
23
+ spec.opts ['-D', '--color']
24
+ }
25
+
26
+
27
+ # EOF
data/bin/org-ruby CHANGED
@@ -1,40 +1,40 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.expand_path(
4
- File.join(File.dirname(__FILE__), %w[.. lib org-ruby]))
5
- require 'optparse'
6
-
7
- # Put your code here
8
-
9
- options = {}
10
- options_parser = OptionParser.new do |opts|
11
- options[:help] = false
12
- options[:format] = :html
13
-
14
- opts.banner = "Usage: org-ruby <file> [options]"
15
-
16
- opts.on("-h", "--help", "Show this message") do |v|
17
- options[:help] = true
18
- end
19
-
20
- opts.on("-t", "--translate FORMAT", [:html, :textile],
21
- "Translate the ORG file to the specified format.") do |v|
22
- options[:format] = v
23
- end
24
- end
25
-
26
- begin
27
- options_parser.parse!
28
- if (ARGV.length == 0) then
29
- puts options_parser
30
- else
31
- data = IO.read(ARGV[0])
32
- p = Orgmode::Parser.new(data)
33
- puts p.to_html if options[:format] == :html
34
- puts p.to_textile if options[:format] == :textile
35
- end
36
- rescue OptionParser::ParseError
37
- puts options_parser
38
- end
39
-
40
-
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(
4
+ File.join(File.dirname(__FILE__), %w[.. lib org-ruby]))
5
+ require 'optparse'
6
+
7
+ # Put your code here
8
+
9
+ options = {}
10
+ options_parser = OptionParser.new do |opts|
11
+ options[:help] = false
12
+ options[:format] = :html
13
+
14
+ opts.banner = "Usage: org-ruby <file> [options]"
15
+
16
+ opts.on("-h", "--help", "Show this message") do |v|
17
+ options[:help] = true
18
+ end
19
+
20
+ opts.on("-t", "--translate FORMAT", [:html, :textile],
21
+ "Translate the ORG file to the specified format.") do |v|
22
+ options[:format] = v
23
+ end
24
+ end
25
+
26
+ begin
27
+ options_parser.parse!
28
+ if (ARGV.length == 0) then
29
+ puts options_parser
30
+ else
31
+ data = IO.read(ARGV[0])
32
+ p = Orgmode::Parser.new(data)
33
+ puts p.to_html if options[:format] == :html
34
+ puts p.to_textile if options[:format] == :textile
35
+ end
36
+ rescue OptionParser::ParseError
37
+ puts options_parser
38
+ end
39
+
40
+
data/lib/org-ruby.rb CHANGED
@@ -1,50 +1,50 @@
1
- unless defined? ::OrgRuby
2
-
3
- module OrgRuby
4
-
5
- # :stopdoc:
6
- VERSION = '0.3.0'
7
- LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
8
- PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
9
- # :startdoc:
10
-
11
- # Returns the version string for the library.
12
- #
13
- def self.version
14
- VERSION
15
- end
16
-
17
- # Returns the library path for the module. If any arguments are given,
18
- # they will be joined to the end of the libray path using
19
- # <tt>File.join</tt>.
20
- #
21
- def self.libpath( *args )
22
- args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
23
- end
24
-
25
- # Returns the lpath for the module. If any arguments are given,
26
- # they will be joined to the end of the path using
27
- # <tt>File.join</tt>.
28
- #
29
- def self.path( *args )
30
- args.empty? ? PATH : ::File.join(PATH, args.flatten)
31
- end
32
-
33
- # Utility method used to require all files ending in .rb that lie in the
34
- # directory below this file that has the same name as the filename passed
35
- # in. Optionally, a specific _directory_ name can be passed in such that
36
- # the _filename_ does not have to be equivalent to the directory.
37
- #
38
- def self.require_all_libs_relative_to( fname, dir = nil )
39
- dir ||= ::File.basename(fname, '.*')
40
- search_me = ::File.expand_path(
41
- ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
42
-
43
- Dir.glob(search_me).sort.each {|rb| require rb}
44
- end
45
-
46
- end # module OrgmodeParser
47
-
48
- OrgRuby.require_all_libs_relative_to(__FILE__)
49
-
50
- end # unless defined?
1
+ unless defined? ::OrgRuby
2
+
3
+ module OrgRuby
4
+
5
+ # :stopdoc:
6
+ VERSION = '0.4.0'
7
+ LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
8
+ PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
9
+ # :startdoc:
10
+
11
+ # Returns the version string for the library.
12
+ #
13
+ def self.version
14
+ VERSION
15
+ end
16
+
17
+ # Returns the library path for the module. If any arguments are given,
18
+ # they will be joined to the end of the libray path using
19
+ # <tt>File.join</tt>.
20
+ #
21
+ def self.libpath( *args )
22
+ args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
23
+ end
24
+
25
+ # Returns the lpath for the module. If any arguments are given,
26
+ # they will be joined to the end of the path using
27
+ # <tt>File.join</tt>.
28
+ #
29
+ def self.path( *args )
30
+ args.empty? ? PATH : ::File.join(PATH, args.flatten)
31
+ end
32
+
33
+ # Utility method used to require all files ending in .rb that lie in the
34
+ # directory below this file that has the same name as the filename passed
35
+ # in. Optionally, a specific _directory_ name can be passed in such that
36
+ # the _filename_ does not have to be equivalent to the directory.
37
+ #
38
+ def self.require_all_libs_relative_to( fname, dir = nil )
39
+ dir ||= ::File.basename(fname, '.*')
40
+ search_me = ::File.expand_path(
41
+ ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
42
+
43
+ Dir.glob(search_me).sort.each {|rb| require rb}
44
+ end
45
+
46
+ end # module OrgmodeParser
47
+
48
+ OrgRuby.require_all_libs_relative_to(__FILE__)
49
+
50
+ end # unless defined?