[DRE-commits] [ruby-org] 190/303: Fix error when table starts with hline
Jérémy Bobbio
lunar at alioth.debian.org
Fri Aug 9 17:33:55 UTC 2013
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository ruby-org.
commit 551ce19ca0bd4e619e57f09c89f94db48fdc73c0
Author: Tilmann Singer <tils at tils.net>
Date: Sat Oct 6 15:32:37 2012 +0200
Fix error when table starts with hline
---
lib/org-ruby/parser.rb | 13 +++++--------
spec/data/tables.org | 6 ++++++
spec/parser_spec.rb | 9 +++++++++
3 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/lib/org-ruby/parser.rb b/lib/org-ruby/parser.rb
index 1e2ad6d..16ad85a 100644
--- a/lib/org-ruby/parser.rb
+++ b/lib/org-ruby/parser.rb
@@ -99,15 +99,14 @@ module Orgmode
mode = :normal
previous_line = nil
table_header_set = false
- @lines.each do |line|
+ @lines.map { |line| Line.new line, self }.each do |line|
case mode
when :normal
- if (Headline.headline? line) then
- @current_headline = Headline.new line, self, offset
+ if (Headline.headline? line.line) then
+ @current_headline = Headline.new line.line, self, offset
@headlines << @current_headline
else
- line = Line.new line, self
# If there is a setting on this line, remember it.
line.in_buffer_setting? do |key, value|
store_in_buffer_setting key, value
@@ -131,7 +130,7 @@ module Orgmode
end
when :block_comment
- line = Line.new line, self
+
if line.end_block? and line.block_type == "COMMENT"
mode = :normal
else
@@ -142,7 +141,6 @@ module Orgmode
# As long as we stay in code mode, force lines to be either blank or paragraphs.
# Don't try to interpret structural items, like headings and tables.
- line = Line.new line, self
if line.end_block? and line.code_block?
mode = :normal
else
@@ -156,7 +154,6 @@ module Orgmode
when :src_code
- line = Line.new line, self
if line.end_block? and line.code_block?
mode = :normal
else
@@ -170,7 +167,6 @@ module Orgmode
when :property_drawer
- line = Line.new line, self
if line.property_drawer_end_block?
mode = :normal
else
@@ -182,6 +178,7 @@ module Orgmode
@header_lines << line
end
end # case
+
previous_line = line
end # @lines.each
end # initialize
diff --git a/spec/data/tables.org b/spec/data/tables.org
new file mode 100644
index 0000000..0022bef
--- /dev/null
+++ b/spec/data/tables.org
@@ -0,0 +1,6 @@
+* a table with hline at the beginning
+|-----+-----|
+| foo | bar |
+|-----+-----|
+| 1 | 2 |
+* not a table
diff --git a/spec/parser_spec.rb b/spec/parser_spec.rb
index 1ed5e89..7077432 100644
--- a/spec/parser_spec.rb
+++ b/spec/parser_spec.rb
@@ -77,6 +77,15 @@ describe Orgmode::Parser do
p.export_tables?.should be_false
end
+ context "with a table that begins with a separator line" do
+ let(:parser) { Orgmode::Parser.new(data) }
+ let(:data) { Pathname.new(File.dirname(__FILE__)).join('data', 'tables.org').read }
+
+ it "should parse without errors" do
+ parser.headlines.size.should == 2
+ end
+ end
+
describe "Custom keyword parser" do
fname = File.join(File.dirname(__FILE__), %w[html_examples custom-todo.org])
p = Orgmode::Parser.load(fname)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-org.git
More information about the Pkg-ruby-extras-commits
mailing list