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
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
{
"column": 17,
"row": 0,
"state": 1201,
"state": 1133,
"sym": "end",
"errorInfo": {
"title": "Unclosed Span",
"message": "I reached the end of the block before finding a closing ']' for the span or link.",
"captures": [
{
"column": 3,
"lrState": 67,
"lrState": 241,
"row": 0,
"size": 1,
"sym": "[",
Expand All @@ -30,23 +30,23 @@
{
"column": 20,
"row": 0,
"state": 2520,
"state": 2557,
"sym": "class_specifier",
"errorInfo": {
"title": "Key-value Pair Before Class Specifier in Attribute",
"message": "This class specifier appears after the key-value pair.",
"captures": [
{
"column": 10,
"lrState": 2632,
"lrState": 2618,
"row": 0,
"size": 3,
"sym": "key_value_key",
"label": "key-value-begin"
},
{
"column": 14,
"lrState": 2473,
"lrState": 2464,
"row": 0,
"size": 5,
"sym": "key_value_value_token1",
Expand All @@ -67,15 +67,15 @@
{
"column": 18,
"row": 0,
"state": 1902,
"state": 1926,
"sym": "_error",
"errorInfo": {
"title": "Mismatched Delimiter in Attribute Specifier",
"message": "I expected a '}', language specifier, an identifier, a class specifier, or a key-value pair.",
"captures": [
{
"column": 17,
"lrState": 1902,
"lrState": 1926,
"row": 0,
"size": 1,
"sym": "{",
Expand All @@ -95,23 +95,23 @@
{
"column": 3,
"row": 0,
"state": 772,
"state": 932,
"sym": "{",
"errorInfo": {
"title": "Missing Space After Div Fence",
"message": "A space is required after ':::' when specifying div attributes.",
"captures": [
{
"column": 0,
"lrState": 772,
"lrState": 932,
"row": 0,
"size": 3,
"sym": "_fenced_div_start",
"label": "fence-start"
},
{
"column": 3,
"lrState": 582,
"lrState": 689,
"row": 0,
"size": 1,
"sym": "{",
Expand Down
22 changes: 12 additions & 10 deletions crates/quarto-markdown-pandoc/src/readers/qmd_error_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,16 +411,18 @@ pub fn produce_error_message_json(
}));
}

// when erroring, produce the errors only for the
// first failing state.
return serde_json::to_string_pretty(&serde_json::json!({
"tokens": tokens,
"errorStates": error_states,
}))
.unwrap()
.lines()
.map(|s| s.to_string())
.collect();
if error_states.len() > 0 {
// when erroring, produce the errors only for the
// first failing state.
return serde_json::to_string_pretty(&serde_json::json!({
"tokens": tokens,
"errorStates": error_states,
}))
.unwrap()
.lines()
.map(|s| s.to_string())
.collect();
}
}
}
vec![]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,27 @@ pub struct TreeSitterParseLog {
#[derive(Debug)]
pub struct TreeSitterProcessLog {
pub found_accept: bool,
pub found_bad_message: bool,
pub error_states: Vec<ProcessMessage>,
pub current_message: Option<ProcessMessage>,
}

impl TreeSitterProcessLog {
pub fn is_good(&self) -> bool {
self.found_accept && self.error_states.is_empty()
self.found_accept && self.error_states.is_empty() && !self.found_bad_message
}
}

impl TreeSitterParseLog {
pub fn is_good(&self) -> bool {
// for every process, there needs to be at least one version that reached an accept state
// with no error states
// for every process, there can't be any version that reached a state
// with error states
for (_, process) in &self.processes {
if process.is_good() {
return true;
if !process.is_good() {
return false;
}
}
false
true
}
}

Expand Down Expand Up @@ -165,6 +166,7 @@ impl TreeSitterLogObserver {
let current_process = current_parse.processes.entry(version).or_insert_with(|| {
TreeSitterProcessLog {
found_accept: false,
found_bad_message: false,
error_states: vec![],
current_message: None,
}
Expand All @@ -179,7 +181,7 @@ impl TreeSitterLogObserver {
});
current_parse.current_process = Some(version);
}
"detect_error" | "skip_token" | "recover_to_previous" => {
"detect_error" => {
let current_parse = self
.parses
.last_mut()
Expand Down Expand Up @@ -245,6 +247,19 @@ impl TreeSitterLogObserver {
sym: current_process_message.sym.clone(), // TODO would prefer not to clone here
})
}
"skip_token" | "recover_to_previous" => {
// we want to mark these processes as bad, but we don't want to record the state here
// because we only care about states we find via "detect_error"
let current_parse = self
.parses
.last_mut()
.expect("No current parse to log process to");
let current_process = current_parse
.processes
.get_mut(&current_parse.current_process.expect("No current process"))
.expect("No current process message");
current_process.found_bad_message = true;
}
"lex_external" | "lex_internal" | "reduce" => {}
"accept" => {
let current_parse = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ module.exports = grammar(add_inline_rules({
"--",
"---",
"...",
common.punctuation_without($, ['[', '{', '}', ']', "@", "_"]),
common.punctuation_without($, ['[', '{', '}', ']', "@", "_", "*"]),
$._whitespace,
)),
_code_span_text_base: $ => prec.right(choice(
Expand Down Expand Up @@ -461,12 +461,6 @@ function add_inline_rules(grammar) {
alias($['_emphasis_underscore' + suffix_link], $.emphasis),
alias($['_strong_emphasis_underscore' + suffix_link], $.strong_emphasis),
];
if (delimiter !== "star") {
elements.push($._emphasis_open_star);
}
if (delimiter !== "underscore") {
elements.push($._emphasis_open_underscore);
}
if (link) {
elements = elements.concat([
$.inline_link,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3936,10 +3936,6 @@
"type": "STRING",
"value": ")"
},
{
"type": "STRING",
"value": "*"
},
{
"type": "STRING",
"value": "+"
Expand Down Expand Up @@ -4237,14 +4233,6 @@
"named": true,
"value": "strong_emphasis"
},
{
"type": "SYMBOL",
"name": "_emphasis_open_star"
},
{
"type": "SYMBOL",
"name": "_emphasis_open_underscore"
},
{
"type": "SYMBOL",
"name": "inline_link"
Expand Down Expand Up @@ -4301,10 +4289,6 @@
"named": true,
"value": "strong_emphasis"
},
{
"type": "SYMBOL",
"name": "_emphasis_open_underscore"
},
{
"type": "SYMBOL",
"name": "inline_link"
Expand Down Expand Up @@ -4361,10 +4345,6 @@
"named": true,
"value": "strong_emphasis"
},
{
"type": "SYMBOL",
"name": "_emphasis_open_star"
},
{
"type": "SYMBOL",
"name": "inline_link"
Expand Down Expand Up @@ -4421,14 +4401,6 @@
"named": true,
"value": "strong_emphasis"
},
{
"type": "SYMBOL",
"name": "_emphasis_open_star"
},
{
"type": "SYMBOL",
"name": "_emphasis_open_underscore"
},
{
"type": "SYMBOL",
"name": "inline_link"
Expand Down Expand Up @@ -4632,14 +4604,6 @@
},
"named": true,
"value": "strong_emphasis"
},
{
"type": "SYMBOL",
"name": "_emphasis_open_star"
},
{
"type": "SYMBOL",
"name": "_emphasis_open_underscore"
}
]
},
Expand Down Expand Up @@ -4692,10 +4656,6 @@
},
"named": true,
"value": "strong_emphasis"
},
{
"type": "SYMBOL",
"name": "_emphasis_open_underscore"
}
]
},
Expand Down Expand Up @@ -4748,10 +4708,6 @@
},
"named": true,
"value": "strong_emphasis"
},
{
"type": "SYMBOL",
"name": "_emphasis_open_star"
}
]
},
Expand Down Expand Up @@ -4804,14 +4760,6 @@
},
"named": true,
"value": "strong_emphasis"
},
{
"type": "SYMBOL",
"name": "_emphasis_open_star"
},
{
"type": "SYMBOL",
"name": "_emphasis_open_underscore"
}
]
},
Expand Down
Loading