BlankLines in code blocks should be passed through
Now passing 308/621 spec tests.
@@ -538,12 +538,18 @@ fn parse_new_containers(tree: &mut Tree<Item>, s: &str, mut ix: usize) -> usize
// Mutates tree as needed, and returns the start of the next line.
fn parse_blocks(mut tree: &mut Tree<Item>, s: &str, mut ix: usize) -> usize {
if ix >= s.len() { return ix; }
- let b = s.as_bytes()[ix];
- if b == b'\n' || b == b'\r' {
- // blank line
- ix += scan_eol(&s[ix..]).0;
- return ix
- } else {
+ // if let Some(blankline_size) = scan_blank_line(&s[ix..]) {
+
+ // println!("found blankline at ix: {}", ix);
+ // tree.append(Item {
+ // start: ix,
+ // end: ix + blankline_size,
+ // body: ItemBody::BlankLine,
+ // });
+
+ // ix += blankline_size;
+ // return ix;
+ // } else {
// check if we are in a leaf block
if let Some(parent) = tree.peek_up() {
if let ItemBody::FencedCodeBlock(_, _, indentation) = tree.nodes[parent].item.body {
@@ -554,6 +560,17 @@ fn parse_blocks(mut tree: &mut Tree<Item>, s: &str, mut ix: usize) -> usize {
}
}
+ if let Some(blankline_size) = scan_blank_line(&s[ix..]) {
+ tree.append(Item {
+ start: ix,
+ end: ix + blankline_size,
+ body: ItemBody::BlankLine,
+ });
+
+ ix += blankline_size;
+ return ix;
+ }
+
let (leading_bytes, leading_spaces) = scan_leading_space(&s[ix..], 0);
if leading_spaces >= 4 {
@@ -605,7 +622,7 @@ fn parse_blocks(mut tree: &mut Tree<Item>, s: &str, mut ix: usize) -> usize {
}
return parse_paragraph(&mut tree, s, ix);
- }
+ // }
}
// Root is node 0
