Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,16 @@ pub struct Ast {
pub last_line_blank: bool,
}

#[doc(hidden)]
pub fn make_block(value: NodeValue, start_line: u32) -> Ast {
Ast {
value: value,
content: vec![],
start_line: start_line,
open: true,
last_line_blank: false,
impl Ast {
/// Create a new AST node with the given value.
pub fn new(value: NodeValue) -> Self {
Ast {
value: value,
content: vec![],
start_line: 0,
open: true,
last_line_blank: false,
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ctype::{isdigit, isspace};
use entity;
use nodes;
use nodes::{
make_block, Ast, AstNode, ListDelimType, ListType, NodeCodeBlock, NodeDescriptionItem,
Ast, AstNode, ListDelimType, ListType, NodeCodeBlock, NodeDescriptionItem,
NodeHeading, NodeHtmlBlock, NodeList, NodeValue,
};
use regex::bytes::Regex;
Expand Down Expand Up @@ -1027,7 +1027,8 @@ impl<'a, 'o, 'c> Parser<'a, 'o, 'c> {
parent = self.finalize(parent).unwrap();
}

let child = make_block(value, self.line_number);
let mut child = Ast::new(value);
child.start_line = self.line_number;
let node = self.arena.alloc(Node::new(RefCell::new(child)));
parent.append(node);
node
Expand Down
5 changes: 3 additions & 2 deletions src/parser/table.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use arena_tree::Node;
use nodes::{make_block, AstNode, NodeValue, TableAlignment};
use nodes::{Ast, AstNode, NodeValue, TableAlignment};
use parser::Parser;
use scanners;
use std::cell::RefCell;
Expand Down Expand Up @@ -58,7 +58,8 @@ fn try_opening_header<'a, 'o, 'c>(
});
}

let child = make_block(NodeValue::Table(alignments), parser.line_number);
let mut child = Ast::new(NodeValue::Table(alignments));
child.start_line = parser.line_number;
let table = parser.arena.alloc(Node::new(RefCell::new(child)));
container.append(table);

Expand Down