org-ruby 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/History.txt +45 -40
  2. data/{README.txt → README.rdoc} +66 -66
  3. data/Rakefile +28 -27
  4. data/bin/org-ruby +40 -40
  5. data/lib/org-ruby.rb +50 -50
  6. data/lib/org-ruby/headline.rb +80 -80
  7. data/lib/org-ruby/html_output_buffer.rb +117 -105
  8. data/lib/org-ruby/line.rb +178 -173
  9. data/lib/org-ruby/output_buffer.rb +172 -172
  10. data/lib/org-ruby/parser.rb +80 -80
  11. data/lib/org-ruby/regexp_helper.rb +156 -156
  12. data/lib/org-ruby/textile_output_buffer.rb +67 -67
  13. data/spec/data/freeform.org +111 -111
  14. data/spec/data/hyp-planning.org +335 -335
  15. data/spec/data/remember.org +53 -53
  16. data/spec/headline_spec.rb +55 -55
  17. data/spec/html_examples/advanced-lists.html +31 -31
  18. data/spec/html_examples/advanced-lists.org +31 -31
  19. data/spec/html_examples/block_code.html +30 -30
  20. data/spec/html_examples/block_code.org +35 -35
  21. data/spec/html_examples/blockquote.html +7 -7
  22. data/spec/html_examples/blockquote.org +13 -13
  23. data/spec/html_examples/code-comment.html +19 -0
  24. data/spec/html_examples/code-comment.org +22 -0
  25. data/spec/html_examples/escape-pre.html +7 -7
  26. data/spec/html_examples/escape-pre.org +6 -6
  27. data/spec/html_examples/html-literal.html +2 -0
  28. data/spec/html_examples/html-literal.org +6 -0
  29. data/spec/html_examples/inline-formatting.html +10 -10
  30. data/spec/html_examples/inline-formatting.org +17 -17
  31. data/spec/html_examples/lists.html +19 -19
  32. data/spec/html_examples/lists.org +36 -36
  33. data/spec/html_examples/metadata-comment.org-fail +30 -0
  34. data/spec/html_examples/only-list.html +5 -5
  35. data/spec/html_examples/only-list.org +3 -3
  36. data/spec/html_examples/only-table.html +6 -6
  37. data/spec/html_examples/only-table.org +5 -5
  38. data/spec/html_examples/tables.html +20 -20
  39. data/spec/html_examples/tables.org +26 -26
  40. data/spec/html_examples/text.html +2 -2
  41. data/spec/html_examples/text.org +16 -16
  42. data/spec/line_spec.rb +89 -89
  43. data/spec/parser_spec.rb +86 -86
  44. data/spec/regexp_helper_spec.rb +57 -57
  45. data/spec/spec_helper.rb +20 -20
  46. data/spec/textile_examples/block_code.org +35 -35
  47. data/spec/textile_examples/block_code.textile +29 -29
  48. data/spec/textile_examples/blockquote.org +13 -13
  49. data/spec/textile_examples/blockquote.textile +11 -11
  50. data/spec/textile_examples/keywords.org +13 -13
  51. data/spec/textile_examples/keywords.textile +11 -11
  52. data/spec/textile_examples/links.org +11 -11
  53. data/spec/textile_examples/links.textile +10 -10
  54. data/spec/textile_examples/lists.org +36 -36
  55. data/spec/textile_examples/lists.textile +20 -20
  56. data/spec/textile_examples/single-space-plain-list.org +13 -13
  57. data/spec/textile_examples/single-space-plain-list.textile +10 -10
  58. data/spec/textile_examples/tables.org +26 -26
  59. data/spec/textile_examples/tables.textile +23 -23
  60. data/spec/textile_output_buffer_spec.rb +21 -21
  61. data/tasks/test_case.rake +49 -49
  62. metadata +10 -6
  63. data/.bnsignore +0 -18
data/History.txt CHANGED
@@ -1,40 +1,45 @@
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.
1
+ == 0.4.1 / 2009-12-29
2
+
3
+ * HTML is now escaped by default
4
+ * org-mode comments will show up in a code block.
5
+
6
+ == 0.4.0 / 2009-12-28
7
+
8
+ * The first thing output in HTML gets the class "title"
9
+ * HTML output is now indented
10
+ * Proper support for multi-paragraph list items.
11
+ * Fixed bugs:
12
+ * "rake spec" wouldn't work on Linux. Needed "require 'rubygems'".
13
+
14
+ == 0.3.0 / 2009-12-27
15
+
16
+ * Uses rubypants to get better typography (smart quotes, elipses, etc.).
17
+ * Fixed bugs:
18
+ * Tables and lists did not get properly closed at the end of file
19
+ * You couldn't do inline formatting inside table cells
20
+ * Characters in PRE blocks were not HTML escaped.
21
+
22
+ == 0.2.0 / 2009-12-26
23
+
24
+ * Renamed the gem to org-ruby
25
+ * Added +to_html+ for HTML output
26
+ * Now supports the following inline markup:
27
+ * bold
28
+ * italic
29
+ * code
30
+ * verbatim
31
+ * underline
32
+ * strikethrough
33
+ * Continued code cleanup and refactoring
34
+
35
+ == 0.1.0 / 2009-12-23
36
+
37
+ * Added support for block code
38
+ * Added support for list items that wrap in the org source
39
+ * Major code cleanup:
40
+ Added +OutputBuffer+ class that should make the code more maintainable.
41
+
42
+ == 0.0.2 / 2009-12-21
43
+
44
+ * Initial version. Handles tables (but not headers), headlines,
45
+ paragraphs, block quotes, strong & emphasis formatting.
@@ -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,27 +1,28 @@
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
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
+ readme_file 'README.rdoc'
16
+ name 'org-ruby'
17
+ authors 'Brian Dewey'
18
+ email 'bdewey@gmail.com'
19
+ url 'http://github.com/bdewey/org-ruby'
20
+ version OrgRuby::VERSION
21
+ colorize false # Windows consoles won't colorize
22
+ gem.need_tar false # Can't TAR from Windows
23
+ depend_on 'rubypants'
24
+ spec.opts ['-D', '--color']
25
+ }
26
+
27
+
28
+ # 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.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?
1
+ unless defined? ::OrgRuby
2
+
3
+ module OrgRuby
4
+
5
+ # :stopdoc:
6
+ VERSION = '0.4.1'
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?