org-ruby 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/TAGS +133 -128
- data/lib/org-ruby.rb +1 -1
- data/lib/org-ruby/html_output_buffer.rb +5 -3
- data/lib/org-ruby/line.rb +39 -7
- data/lib/org-ruby/output_buffer.rb +18 -3
- data/lib/org-ruby/parser.rb +28 -6
- data/lib/org-ruby/textile_output_buffer.rb +1 -0
- data/spec/html_examples/block_code.html +1 -3
- data/spec/html_examples/code-comment.html +0 -1
- data/spec/html_examples/entities.html +3 -0
- data/spec/html_examples/entities.org +8 -0
- data/spec/html_examples/escape-pre.html +0 -1
- data/spec/html_examples/metadata-comment.html +27 -0
- data/spec/html_examples/{metadata-comment.org-fail → metadata-comment.org} +0 -0
- data/spec/line_spec.rb +20 -0
- metadata +5 -2
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== 0.4.2 / 2009-12-29
|
2
|
+
|
3
|
+
* Got rid of the extraneous newline at the start of code blocks.
|
4
|
+
* Everything now shows up in code blocks, even org-mode metadata.
|
5
|
+
* Fixed bugs:
|
6
|
+
* Regressed smart double quotes with HTML escaping. Added a test
|
7
|
+
case and fixed the regression.
|
8
|
+
|
1
9
|
== 0.4.1 / 2009-12-29
|
2
10
|
|
3
11
|
* HTML is now escaped by default
|
data/TAGS
CHANGED
@@ -1,128 +1,133 @@
|
|
1
|
-
|
2
|
-
./
|
3
|
-
|
4
|
-
./
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
def
|
25
|
-
def
|
26
|
-
def
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
attr_reader :
|
33
|
-
|
34
|
-
|
35
|
-
def
|
36
|
-
def
|
37
|
-
def
|
38
|
-
def
|
39
|
-
def
|
40
|
-
def
|
41
|
-
def
|
42
|
-
def
|
43
|
-
def
|
44
|
-
def
|
45
|
-
def
|
46
|
-
def
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
def
|
72
|
-
def
|
73
|
-
def
|
74
|
-
def
|
75
|
-
def
|
76
|
-
def
|
77
|
-
|
78
|
-
./lib/org-ruby/
|
79
|
-
module Orgmode::Orgmode
|
80
|
-
class
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
def
|
85
|
-
def
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
attr_reader
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
def
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
def
|
109
|
-
def
|
110
|
-
def
|
111
|
-
def
|
112
|
-
def
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
1
|
+
|
2
|
+
./bin/org-ruby,0
|
3
|
+
|
4
|
+
./lib/org-ruby/headline.rb,619
|
5
|
+
module Orgmode::Orgmode3,45
|
6
|
+
class Headline::Orgmode::Headline6,109
|
7
|
+
attr_reader :level::Orgmode::Headline#level9,178
|
8
|
+
attr_reader :headline_text::Orgmode::Headline#headline_text13,325
|
9
|
+
attr_reader :body_lines::Orgmode::Headline#body_lines16,418
|
10
|
+
attr_reader :tags::Orgmode::Headline#tags19,481
|
11
|
+
attr_reader :keyword::Orgmode::Headline#keyword22,567
|
12
|
+
def initialize::Orgmode::Headline#Orgmode::Headline.new35,896
|
13
|
+
def self.headline?::Orgmode::Headline.headline?58,1687
|
14
|
+
def to_textile::Orgmode::Headline#to_textile63,1818
|
15
|
+
def to_html::Orgmode::Headline#to_html69,1939
|
16
|
+
|
17
|
+
./lib/org-ruby/html_output_buffer.rb,591
|
18
|
+
module Orgmode::Orgmode3,54
|
19
|
+
class HtmlOutputBuffer::Orgmode::HtmlOutputBuffer5,72
|
20
|
+
def initialize::Orgmode::HtmlOutputBuffer#Orgmode::HtmlOutputBuffer.new22,417
|
21
|
+
def push_mode::Orgmode::HtmlOutputBuffer#push_mode31,619
|
22
|
+
def pop_mode::Orgmode::HtmlOutputBuffer#pop_mode42,918
|
23
|
+
def flush!::Orgmode::HtmlOutputBuffer#flush!51,1133
|
24
|
+
def escape_buffer!::Orgmode::HtmlOutputBuffer#escape_buffer!78,2163
|
25
|
+
def output_indentation::Orgmode::HtmlOutputBuffer#output_indentation84,2299
|
26
|
+
def inline_formatting::Orgmode::HtmlOutputBuffer#inline_formatting100,2827
|
27
|
+
|
28
|
+
./lib/org-ruby/line.rb,1527
|
29
|
+
module Orgmode::Orgmode1,0
|
30
|
+
class Line::Orgmode::Line4,67
|
31
|
+
attr_reader :line::Orgmode::Line#line7,114
|
32
|
+
attr_reader :indent::Orgmode::Line#indent12,300
|
33
|
+
attr_accessor :assigned_paragraph_type::Orgmode::Line#assigned_paragraph_type19,664
|
34
|
+
def initialize::Orgmode::Line#Orgmode::Line.new21,708
|
35
|
+
def to_s::Orgmode::Line#to_s29,885
|
36
|
+
def comment?::Orgmode::Line#comment?34,966
|
37
|
+
def metadata?::Orgmode::Line#metadata?39,1083
|
38
|
+
def nonprinting?::Orgmode::Line#nonprinting?43,1175
|
39
|
+
def blank?::Orgmode::Line#blank?47,1227
|
40
|
+
def plain_list?::Orgmode::Line#plain_list?51,1279
|
41
|
+
def unordered_list?::Orgmode::Line#unordered_list?57,1394
|
42
|
+
def strip_unordered_list_tag::Orgmode::Line#strip_unordered_list_tag61,1471
|
43
|
+
def ordered_list?::Orgmode::Line#ordered_list?67,1588
|
44
|
+
def strip_ordered_list_tag::Orgmode::Line#strip_ordered_list_tag71,1661
|
45
|
+
def plain_text?::Orgmode::Line#plain_text?75,1729
|
46
|
+
def table_row?::Orgmode::Line#table_row?79,1812
|
47
|
+
def table_separator?::Orgmode::Line#table_separator?85,1959
|
48
|
+
def table?::Orgmode::Line#table?93,2195
|
49
|
+
def begin_block?::Orgmode::Line#begin_block?99,2308
|
50
|
+
def end_block?::Orgmode::Line#end_block?103,2380
|
51
|
+
def block_type::Orgmode::Line#block_type107,2450
|
52
|
+
def paragraph_type::Orgmode::Line#paragraph_type112,2572
|
53
|
+
def self.to_textile::Orgmode::Line.to_textile124,2956
|
54
|
+
def self.to_html::Orgmode::Line.to_html130,3106
|
55
|
+
def self.translate::Orgmode::Line.translate137,3320
|
56
|
+
|
57
|
+
./lib/org-ruby/output_buffer.rb,1282
|
58
|
+
module Orgmode::Orgmode3,18
|
59
|
+
class OutputBuffer::Orgmode::OutputBuffer9,297
|
60
|
+
attr_reader :buffer::Orgmode::OutputBuffer#buffer12,381
|
61
|
+
attr_reader :output::Orgmode::OutputBuffer#output15,446
|
62
|
+
attr_accessor :output_type::Orgmode::OutputBuffer#output_type18,532
|
63
|
+
def initialize::Orgmode::OutputBuffer#Orgmode::OutputBuffer.new22,686
|
64
|
+
def current_mode::Orgmode::OutputBuffer#current_mode40,1138
|
65
|
+
def current_mode_list?::Orgmode::OutputBuffer#current_mode_list?44,1197
|
66
|
+
def push_mode::Orgmode::OutputBuffer#push_mode48,1286
|
67
|
+
def pop_mode::Orgmode::OutputBuffer#pop_mode53,1421
|
68
|
+
def prepare::Orgmode::OutputBuffer#prepare61,1729
|
69
|
+
def enter_table?::Orgmode::OutputBuffer#enter_table?73,2129
|
70
|
+
def exit_table?::Orgmode::OutputBuffer#exit_table?79,2314
|
71
|
+
def <<::Orgmode::OutputBuffer#<<85,2480
|
72
|
+
def list_indent_level::Orgmode::OutputBuffer#list_indent_level90,2585
|
73
|
+
def preserve_whitespace?::Orgmode::OutputBuffer#preserve_whitespace?95,2729
|
74
|
+
def continue_current_list?::Orgmode::OutputBuffer#continue_current_list?106,2991
|
75
|
+
def maintain_list_indent_stack::Orgmode::OutputBuffer#maintain_list_indent_stack109,3037
|
76
|
+
def should_accumulate_output?::Orgmode::OutputBuffer#should_accumulate_output?145,4184
|
77
|
+
|
78
|
+
./lib/org-ruby/parser.rb,473
|
79
|
+
module Orgmode::Orgmode4,40
|
80
|
+
class Parser::Orgmode::Parser10,125
|
81
|
+
attr_reader :lines::Orgmode::Parser#lines13,186
|
82
|
+
attr_reader :headlines::Orgmode::Parser#headlines16,253
|
83
|
+
attr_reader :header_lines::Orgmode::Parser#header_lines19,333
|
84
|
+
def initialize::Orgmode::Parser#Orgmode::Parser.new23,505
|
85
|
+
def self.load::Orgmode::Parser.load73,2075
|
86
|
+
def to_textile::Orgmode::Parser#to_textile79,2241
|
87
|
+
def to_html::Orgmode::Parser#to_html89,2477
|
88
|
+
|
89
|
+
./lib/org-ruby/regexp_helper.rb,1014
|
90
|
+
module Orgmode::Orgmode3,18
|
91
|
+
class RegexpHelper::Orgmode::RegexpHelper17,456
|
92
|
+
attr_reader :pre_emphasis::Orgmode::RegexpHelper#pre_emphasis42,1785
|
93
|
+
attr_reader :post_emphasis::Orgmode::RegexpHelper#post_emphasis43,1817
|
94
|
+
attr_reader :border_forbidden::Orgmode::RegexpHelper#border_forbidden44,1850
|
95
|
+
attr_reader :body_regexp::Orgmode::RegexpHelper#body_regexp45,1886
|
96
|
+
attr_reader :markers::Orgmode::RegexpHelper#markers46,1917
|
97
|
+
attr_reader :org_emphasis_regexp::Orgmode::RegexpHelper#org_emphasis_regexp48,1945
|
98
|
+
def initialize::Orgmode::RegexpHelper#Orgmode::RegexpHelper.new50,1999
|
99
|
+
def match_all::Orgmode::RegexpHelper#match_all65,2476
|
100
|
+
def rewrite_emphasis::Orgmode::RegexpHelper#rewrite_emphasis92,3413
|
101
|
+
def rewrite_links::Orgmode::RegexpHelper#rewrite_links124,4523
|
102
|
+
def build_org_emphasis_regexp::Orgmode::RegexpHelper#build_org_emphasis_regexp135,4759
|
103
|
+
def build_org_link_regexp::Orgmode::RegexpHelper#build_org_link_regexp145,5326
|
104
|
+
|
105
|
+
./lib/org-ruby/textile_output_buffer.rb,454
|
106
|
+
module Orgmode::Orgmode3,20
|
107
|
+
class TextileOutputBuffer::Orgmode::TextileOutputBuffer5,38
|
108
|
+
def initialize::Orgmode::TextileOutputBuffer#Orgmode::TextileOutputBuffer.new7,84
|
109
|
+
def push_mode::Orgmode::TextileOutputBuffer#push_mode12,169
|
110
|
+
def pop_mode::Orgmode::TextileOutputBuffer#pop_mode17,262
|
111
|
+
def inline_formatting::Orgmode::TextileOutputBuffer#inline_formatting34,585
|
112
|
+
def flush!::Orgmode::TextileOutputBuffer#flush!48,973
|
113
|
+
|
114
|
+
./lib/org-ruby.rb,243
|
115
|
+
module OrgRuby::OrgRuby3,27
|
116
|
+
def self.version::OrgRuby.version13,277
|
117
|
+
def self.libpath::OrgRuby.libpath21,476
|
118
|
+
def self.path::OrgRuby.path29,721
|
119
|
+
def self.require_all_libs_relative_to::OrgRuby.require_all_libs_relative_to38,1108
|
120
|
+
|
121
|
+
./spec/headline_spec.rb,0
|
122
|
+
|
123
|
+
./spec/line_spec.rb,0
|
124
|
+
|
125
|
+
./spec/parser_spec.rb,0
|
126
|
+
|
127
|
+
./spec/regexp_helper_spec.rb,0
|
128
|
+
|
129
|
+
./spec/spec_helper.rb,0
|
130
|
+
|
131
|
+
./spec/textile_output_buffer_spec.rb,0
|
132
|
+
|
133
|
+
./test/test_orgmode_parser.rb,0
|
data/lib/org-ruby.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require OrgRuby.libpath(*%w[org-ruby output_buffer])
|
2
|
-
require 'cgi'
|
3
2
|
|
4
3
|
module Orgmode
|
5
4
|
|
@@ -51,7 +50,7 @@ module Orgmode
|
|
51
50
|
|
52
51
|
def flush!
|
53
52
|
escape_buffer!
|
54
|
-
if
|
53
|
+
if @buffer_mode == :code then
|
55
54
|
# Whitespace is significant in :code mode. Always output the buffer
|
56
55
|
# and do not do any additional translation.
|
57
56
|
#
|
@@ -70,6 +69,7 @@ module Orgmode
|
|
70
69
|
end
|
71
70
|
end
|
72
71
|
@buffer = ""
|
72
|
+
@buffer_mode = nil
|
73
73
|
end
|
74
74
|
|
75
75
|
######################################################################
|
@@ -77,7 +77,9 @@ module Orgmode
|
|
77
77
|
|
78
78
|
# Escapes any HTML content in the output accumulation buffer @buffer.
|
79
79
|
def escape_buffer!
|
80
|
-
@buffer
|
80
|
+
@buffer.gsub!(/&/, "&")
|
81
|
+
@buffer.gsub!(/</, "<")
|
82
|
+
@buffer.gsub!(/>/, ">")
|
81
83
|
end
|
82
84
|
|
83
85
|
def output_indentation
|
data/lib/org-ruby/line.rb
CHANGED
@@ -11,10 +11,18 @@ module Orgmode
|
|
11
11
|
# TODO 2009-12-20 bdewey: Handle tabs
|
12
12
|
attr_reader :indent
|
13
13
|
|
14
|
+
# A line can have its type assigned instead of inferred from its
|
15
|
+
# content. For example, something that parses as a "table" on its
|
16
|
+
# own ("| one | two|\n") may just be a paragraph if it's inside
|
17
|
+
# #+BEGIN_EXAMPLE. Set this property on the line to assign its
|
18
|
+
# type. This will then affect the value of +paragraph_type+.
|
19
|
+
attr_accessor :assigned_paragraph_type
|
20
|
+
|
14
21
|
def initialize(line)
|
15
22
|
@line = line
|
16
23
|
@indent = 0
|
17
24
|
@line =~ /\s*/
|
25
|
+
@assigned_paragraph_type = nil
|
18
26
|
@indent = $&.length unless blank?
|
19
27
|
end
|
20
28
|
|
@@ -24,12 +32,12 @@ module Orgmode
|
|
24
32
|
|
25
33
|
# Tests if a line is a comment.
|
26
34
|
def comment?
|
27
|
-
|
35
|
+
check_assignment_or_regexp(:comment, /^\s*#/)
|
28
36
|
end
|
29
37
|
|
30
38
|
# Tests if a line contains metadata instead of actual content.
|
31
39
|
def metadata?
|
32
|
-
|
40
|
+
check_assignment_or_regexp(:metadata, /^\s*(CLOCK|DEADLINE|START|CLOSED|SCHEDULED):/)
|
33
41
|
end
|
34
42
|
|
35
43
|
def nonprinting?
|
@@ -37,7 +45,7 @@ module Orgmode
|
|
37
45
|
end
|
38
46
|
|
39
47
|
def blank?
|
40
|
-
|
48
|
+
check_assignment_or_regexp(:blank, /^\s*$/)
|
41
49
|
end
|
42
50
|
|
43
51
|
def plain_list?
|
@@ -47,7 +55,7 @@ module Orgmode
|
|
47
55
|
UnorderedListRegexp = /^\s*(-|\+)\s*/
|
48
56
|
|
49
57
|
def unordered_list?
|
50
|
-
|
58
|
+
check_assignment_or_regexp(:unordered_list, UnorderedListRegexp)
|
51
59
|
end
|
52
60
|
|
53
61
|
def strip_unordered_list_tag
|
@@ -57,7 +65,7 @@ module Orgmode
|
|
57
65
|
OrderedListRegexp = /^\s*\d+(\.|\))\s*/
|
58
66
|
|
59
67
|
def ordered_list?
|
60
|
-
|
68
|
+
check_assignment_or_regexp(:ordered_list, OrderedListRegexp)
|
61
69
|
end
|
62
70
|
|
63
71
|
def strip_ordered_list_tag
|
@@ -71,7 +79,7 @@ module Orgmode
|
|
71
79
|
def table_row?
|
72
80
|
# for an org-mode table, the first non-whitespace character is a
|
73
81
|
# | (pipe).
|
74
|
-
|
82
|
+
check_assignment_or_regexp(:table_row, /^\s*\|/)
|
75
83
|
end
|
76
84
|
|
77
85
|
def table_separator?
|
@@ -79,7 +87,7 @@ module Orgmode
|
|
79
87
|
# character as a | (pipe), then consists of nothing else other
|
80
88
|
# than pipes, hyphens, and pluses.
|
81
89
|
|
82
|
-
|
90
|
+
check_assignment_or_regexp(:table_separator, /^\s*\|[-\|\+]*\s*$/)
|
83
91
|
end
|
84
92
|
|
85
93
|
def table?
|
@@ -174,5 +182,29 @@ module Orgmode
|
|
174
182
|
output_buffer.pop_mode until output_buffer.current_mode == :normal
|
175
183
|
output_buffer.output
|
176
184
|
end
|
185
|
+
|
186
|
+
######################################################################
|
187
|
+
private
|
188
|
+
|
189
|
+
# This function is an internal helper for determining the paragraph
|
190
|
+
# type of a line... for instance, if the line is a comment or contains
|
191
|
+
# metadata. It's used in routines like blank?, plain_list?, etc.
|
192
|
+
#
|
193
|
+
# What's tricky is lines can have assigned types, so you need to check
|
194
|
+
# the assigned type, if present, or see if the characteristic regexp
|
195
|
+
# for the paragraph type matches if not present.
|
196
|
+
#
|
197
|
+
# call-seq:
|
198
|
+
# check_assignment_or_regexp(assignment, regexp) => boolean
|
199
|
+
#
|
200
|
+
# assignment:: if the paragraph has an assigned type, it will be
|
201
|
+
# checked to see if it equals +assignment+.
|
202
|
+
# regexp:: If the paragraph does not have an assigned type,
|
203
|
+
# the contents of the paragraph will be checked against
|
204
|
+
# this regexp.
|
205
|
+
def check_assignment_or_regexp(assignment, regexp)
|
206
|
+
return @assigned_paragraph_type == assignment if @assigned_paragraph_type
|
207
|
+
return @line =~ regexp
|
208
|
+
end
|
177
209
|
end # class Line
|
178
210
|
end # module Orgmode
|
@@ -8,9 +8,14 @@ module Orgmode
|
|
8
8
|
# add a newline character prior emitting the output.
|
9
9
|
class OutputBuffer
|
10
10
|
|
11
|
-
# This is the
|
11
|
+
# This is the accumulation buffer. It's a holding pen so
|
12
|
+
# consecutive lines of the right type can get stuck together
|
13
|
+
# without intervening newlines.
|
12
14
|
attr_reader :buffer
|
13
15
|
|
16
|
+
# This is the output mode of the accumulation buffer.
|
17
|
+
attr_reader :buffer_mode
|
18
|
+
|
14
19
|
# This is the overall output buffer
|
15
20
|
attr_reader :output
|
16
21
|
|
@@ -22,17 +27,22 @@ module Orgmode
|
|
22
27
|
def initialize(output)
|
23
28
|
@output = output
|
24
29
|
@buffer = ""
|
30
|
+
@buffer_mode = nil
|
25
31
|
@output_type = :start
|
26
32
|
@list_indent_stack = []
|
27
33
|
@paragraph_modifier = nil
|
28
34
|
@cancel_modifier = false
|
29
35
|
@mode_stack = []
|
30
|
-
push_mode(:normal)
|
31
36
|
|
32
37
|
@logger = Logger.new(STDERR)
|
33
|
-
|
38
|
+
if ENV['DEBUG']
|
39
|
+
@logger.level = Logger::DEBUG
|
40
|
+
else
|
41
|
+
@logger.level = Logger::WARN
|
42
|
+
end
|
34
43
|
|
35
44
|
@re_help = RegexpHelper.new
|
45
|
+
push_mode(:normal)
|
36
46
|
end
|
37
47
|
|
38
48
|
Modes = [:normal, :ordered_list, :unordered_list, :blockquote, :code, :table]
|
@@ -83,6 +93,11 @@ module Orgmode
|
|
83
93
|
|
84
94
|
# Accumulate the string @str@.
|
85
95
|
def << (str)
|
96
|
+
if @buffer_mode && @buffer_mode != current_mode then
|
97
|
+
raise "Accumulation buffer is mixing modes: @buffer_mode == #{@buffer_mode}, current_mode == #{current_mode}"
|
98
|
+
else
|
99
|
+
@buffer_mode = current_mode
|
100
|
+
end
|
86
101
|
@buffer << str
|
87
102
|
end
|
88
103
|
|
data/lib/org-ruby/parser.rb
CHANGED
@@ -32,20 +32,42 @@ module Orgmode
|
|
32
32
|
@headlines = Array.new
|
33
33
|
@current_headline = nil
|
34
34
|
@header_lines = []
|
35
|
+
mode = :normal
|
35
36
|
@lines.each do |line|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
case mode
|
38
|
+
when :normal
|
39
|
+
|
40
|
+
if (Headline.headline? line) then
|
41
|
+
@current_headline = Headline.new line
|
42
|
+
@headlines << @current_headline
|
43
|
+
else
|
44
|
+
line = Line.new line
|
45
|
+
mode = :code if line.begin_block? and line.block_type == "EXAMPLE"
|
46
|
+
if (@current_headline) then
|
47
|
+
@current_headline.body_lines << line
|
48
|
+
else
|
49
|
+
@header_lines << line
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
when :code
|
54
|
+
|
55
|
+
# As long as we stay in code mode, force lines to be either blank or paragraphs.
|
56
|
+
# Don't try to interpret structural items, like headings and tables.
|
40
57
|
line = Line.new line
|
58
|
+
if line.end_block? and line.block_type == "EXAMPLE"
|
59
|
+
mode = :normal
|
60
|
+
else
|
61
|
+
line.assigned_paragraph_type = :paragraph unless line.blank?
|
62
|
+
end
|
41
63
|
if (@current_headline) then
|
42
64
|
@current_headline.body_lines << line
|
43
65
|
else
|
44
66
|
@header_lines << line
|
45
67
|
end
|
46
|
-
end
|
68
|
+
end # case
|
47
69
|
end
|
48
|
-
end
|
70
|
+
end # initialize
|
49
71
|
|
50
72
|
# Creates a new parser from the data in a given file
|
51
73
|
def self.load(fname)
|
@@ -2,10 +2,9 @@
|
|
2
2
|
<p>I need to get block code examples working. In <code>orgmode</code>, they look like this:</p>
|
3
3
|
<pre>
|
4
4
|
|
5
|
-
|
6
5
|
def initialize(output)
|
7
6
|
@output = output
|
8
|
-
@buffer =
|
7
|
+
@buffer = ""
|
9
8
|
@output_type = :start
|
10
9
|
@list_indent_stack = []
|
11
10
|
@paragraph_modifier = nil
|
@@ -19,7 +18,6 @@
|
|
19
18
|
<p>Putting in another paragraph for good measure.</p>
|
20
19
|
<p>Code should also get cancelled by a list, thus:</p>
|
21
20
|
<pre>
|
22
|
-
|
23
21
|
This is my code!
|
24
22
|
|
25
23
|
Another line!
|
@@ -0,0 +1,3 @@
|
|
1
|
+
<p class="title">ENTITIES</p>
|
2
|
+
<p><code>Org-ruby</code> supports “smart double quotes,” ‘smart single quotes,’ apostrophes for contractions like won’t and can’t, and other things… like elipses. Oh – and dashes.</p>
|
3
|
+
<p>Question: What does org-mode do for ampersands, like R&R? or &lt;? Answer: Those get escaped, too.</p>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
ENTITIES
|
2
|
+
|
3
|
+
=Org-ruby= supports "smart double quotes," 'smart single quotes,'
|
4
|
+
apostrophes for contractions like won't and can't, and other
|
5
|
+
things... like elipses. Oh -- and dashes.
|
6
|
+
|
7
|
+
Question: What does org-mode do for ampersands, like R&R? or <?
|
8
|
+
Answer: Those get escaped, too.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<h1 class="title">Metadata, etc.</h1>
|
2
|
+
<p>I normally filter out things that look like metadata. Can’t do it any more. I need to see all of the following:</p>
|
3
|
+
<pre>
|
4
|
+
* DONE Handle inline formatting
|
5
|
+
CLOSED: [2009-12-26 Sat 21:41]
|
6
|
+
:PROPERTIES:
|
7
|
+
:ARCHIVE_TIME: 2009-12-26 Sat 22:16
|
8
|
+
:ARCHIVE_FILE: ~/brians-brain/content/projects/orgmode_parser.org
|
9
|
+
:ARCHIVE_OLPATH: <%= @page.title %>/Future Development
|
10
|
+
:ARCHIVE_CATEGORY: orgmode_parser
|
11
|
+
:ARCHIVE_TODO: DONE
|
12
|
+
:END:
|
13
|
+
|
14
|
+
I still need to handle:
|
15
|
+
|
16
|
+
- [ ] =Inline code=
|
17
|
+
|
18
|
+
How does the =emacs= HTML parser handle *inline* formatting? Ah,
|
19
|
+
it looks like it defines everything in =org-emphasis-alist= (line
|
20
|
+
2855 of =org.el=).
|
21
|
+
|
22
|
+
And then look at =org-emphasis-regexp-components=, line 2828 of
|
23
|
+
=org.el=. It looks like they just use a crazy regexp for inline
|
24
|
+
formatting. Which is good, because it means I can copy!
|
25
|
+
|
26
|
+
|
27
|
+
</pre>
|
File without changes
|
data/spec/line_spec.rb
CHANGED
@@ -86,4 +86,24 @@ describe Orgmode::Line do
|
|
86
86
|
line.block_type.should eql(end_examples[str])
|
87
87
|
end
|
88
88
|
end
|
89
|
+
|
90
|
+
it "should accept assigned types" do
|
91
|
+
cases = {
|
92
|
+
"# this looks like a comment" => :comment,
|
93
|
+
" 1. This looks like an ordered list" => :ordered_list,
|
94
|
+
" - this looks like an # unordered list" => :unordered_list,
|
95
|
+
" | one | two | table! | \n" => :table_row,
|
96
|
+
"\n" => :blank,
|
97
|
+
" |-----+-----+--------| \n" => :table_separator
|
98
|
+
}
|
99
|
+
|
100
|
+
cases.each_pair do |key, value|
|
101
|
+
l = Orgmode::Line.new key
|
102
|
+
l.paragraph_type.should eql(value)
|
103
|
+
l.assigned_paragraph_type = :paragraph
|
104
|
+
l.paragraph_type.should eql(:paragraph)
|
105
|
+
l.assigned_paragraph_type = nil
|
106
|
+
l.paragraph_type.should eql(value)
|
107
|
+
end
|
108
|
+
end
|
89
109
|
end
|
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.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Dewey
|
@@ -72,6 +72,8 @@ files:
|
|
72
72
|
- spec/html_examples/blockquote.org
|
73
73
|
- spec/html_examples/code-comment.html
|
74
74
|
- spec/html_examples/code-comment.org
|
75
|
+
- spec/html_examples/entities.html
|
76
|
+
- spec/html_examples/entities.org
|
75
77
|
- spec/html_examples/escape-pre.html
|
76
78
|
- spec/html_examples/escape-pre.org
|
77
79
|
- spec/html_examples/html-literal.html
|
@@ -80,7 +82,8 @@ files:
|
|
80
82
|
- spec/html_examples/inline-formatting.org
|
81
83
|
- spec/html_examples/lists.html
|
82
84
|
- spec/html_examples/lists.org
|
83
|
-
- spec/html_examples/metadata-comment.
|
85
|
+
- spec/html_examples/metadata-comment.html
|
86
|
+
- spec/html_examples/metadata-comment.org
|
84
87
|
- spec/html_examples/only-list.html
|
85
88
|
- spec/html_examples/only-list.org
|
86
89
|
- spec/html_examples/only-table.html
|