Skip to content

Commit 0cbfb10

Browse files
committed
Resolve awkward table panics. Fixes #34.
1 parent bbcdf97 commit 0cbfb10

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/parser/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ mod table;
22
mod autolink;
33
mod inlines;
44

5-
65
use arena_tree::Node;
76
use ctype::{isspace, isdigit};
87
use entity;

src/parser/table.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
use nodes::{NodeValue, TableAlignment, AstNode};
1+
use arena_tree::Node;
2+
3+
use nodes::{NodeValue, TableAlignment, AstNode, make_block};
24
use parser::Parser;
35
use scanners;
6+
use std::cell::RefCell;
47
use std::cmp::min;
58
use strings::trim;
69

@@ -21,7 +24,7 @@ pub fn try_opening_block<'a, 'o>(
2124
}
2225
}
2326

24-
pub fn try_opening_header<'a, 'o>(
27+
fn try_opening_header<'a, 'o>(
2528
parser: &mut Parser<'a, 'o>,
2629
container: &'a AstNode<'a>,
2730
line: &str,
@@ -57,7 +60,9 @@ pub fn try_opening_header<'a, 'o>(
5760
}
5861

5962
let start_column = container.data.borrow().start_column;
60-
let table = parser.add_child(container, NodeValue::Table(alignments), start_column);
63+
let child = make_block(NodeValue::Table(alignments), parser.line_number, start_column);
64+
let table = parser.arena.alloc(Node::new(RefCell::new(child)));
65+
container.append(table);
6166

6267
let header = parser.add_child(table, NodeValue::TableRow(true), start_column);
6368
for header_str in header_row {
@@ -72,7 +77,7 @@ pub fn try_opening_header<'a, 'o>(
7277
}
7378

7479

75-
pub fn try_opening_row<'a, 'o>(
80+
fn try_opening_row<'a, 'o>(
7681
parser: &mut Parser<'a, 'o>,
7782
container: &'a AstNode<'a>,
7883
alignments: &[TableAlignment],

0 commit comments

Comments
 (0)