Skip to content
Open
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
7 changes: 6 additions & 1 deletion src/parser/block/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pub struct BlockState<'a, 'b> where 'b: 'a {
pub list_indent: Option<u32>,

pub level: u32,

pub current_rule: Option<String>,
}

/// Holds start/end/etc. positions for a specific source text line.
Expand Down Expand Up @@ -112,6 +114,7 @@ impl<'a, 'b> BlockState<'a, 'b> {
tight: false,
list_indent: None,
level: 0,
current_rule: None,
};

result.generate_caches();
Expand Down Expand Up @@ -170,12 +173,14 @@ impl<'a, 'b> BlockState<'a, 'b> {
}

#[must_use]
pub fn test_rules_at_line(&mut self) -> bool {
pub fn test_rules_at_line(&mut self, name: &str) -> bool {
for rule in self.md.block.ruler.iter() {
self.current_rule = Some(name.to_owned());
if rule.0(self).is_some() {
return true;
}
}
self.current_rule = None;
false
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/cmark/block/blockquote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl BlockRule for BlockquoteScanner {
// Case 3: another tag found.
state.line = next_line;

if state.test_rules_at_line() {
if state.test_rules_at_line("blockquote") {
// Quirk to enforce "hard termination mode" for paragraphs;
// normally if you call `nodeize(state, startLine, nextLine)`,
// paragraphs will look below nextLine for paragraph continuation,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/cmark/block/lheading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl BlockRule for LHeadingScanner {
// Some tags can terminate paragraph without empty line.
let old_state_line = state.line;
state.line = next_line;
if state.test_rules_at_line() {
if state.test_rules_at_line("lheading") {
state.line = old_state_line;
break 'outer;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/cmark/block/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl BlockRule for ListScanner {
if state.line_indent(next_line) >= 4 { break; }

// fail if terminating block found
if state.test_rules_at_line() { break; }
if state.test_rules_at_line("list") { break; }

current_line = state.get_line(state.line).to_owned();

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/cmark/block/paragraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl BlockRule for ParagraphScanner {
// Some tags can terminate paragraph without empty line.
let old_state_line = state.line;
state.line = next_line;
if state.test_rules_at_line() {
if state.test_rules_at_line("paragraph") {
state.line = old_state_line;
break 'outer;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/cmark/block/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ impl BlockRule for ReferenceScanner {
// Some tags can terminate paragraph without empty line.
let old_state_line = state.line;
state.line = next_line;
if state.test_rules_at_line() {
if state.test_rules_at_line("reference") {
state.line = old_state_line;
break 'outer;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/extra/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ impl BlockRule for TableScanner {
if state.is_empty(state.line) { break; }

// fail if terminating block found
if state.test_rules_at_line() { break; }
if state.test_rules_at_line("table") { break; }

let mut row_node = Node::new(TableRow);
row_node.srcmap = state.get_map(state.line, state.line);
Expand Down