Skip to content

Commit 2f13293

Browse files
committed
fix raw reader syntax overprocessing bug
1 parent a66f150 commit 2f13293

File tree

9 files changed

+141
-599
lines changed

9 files changed

+141
-599
lines changed

crates/quarto-markdown-pandoc/src/pandoc/treesitter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ fn process_native_inlines<T: Write>(
390390
}))
391391
} else {
392392
inlines.push(Inline::Str(Str {
393-
text,
393+
text: apply_smart_quotes(text),
394394
source_info: SourceInfo::new(
395395
if context.filenames.is_empty() {
396396
None

crates/quarto-markdown-pandoc/src/pandoc/treesitter_utils/postprocess.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ use crate::filters::{
77
Filter, FilterReturn::FilterResult, FilterReturn::Unchanged, topdown_traverse,
88
};
99
use crate::pandoc::attr::{Attr, is_empty_attr};
10-
use crate::pandoc::block::{Block, Figure, Plain, RawBlock};
10+
use crate::pandoc::block::{Block, Figure, Plain};
1111
use crate::pandoc::caption::Caption;
1212
use crate::pandoc::inline::{Inline, Inlines, Space, Span, Str, Superscript};
1313
use crate::pandoc::location::{Range, SourceInfo, empty_range, empty_source_info};
1414
use crate::pandoc::pandoc::Pandoc;
1515
use crate::pandoc::shortcode::shortcode_to_span;
1616
use crate::utils::autoid;
17-
use once_cell::sync::Lazy;
18-
use regex::Regex;
1917
use std::collections::HashMap;
2018

2119
/// Trim leading and trailing spaces from inlines
@@ -171,8 +169,6 @@ pub fn coalesce_abbreviations(inlines: Vec<Inline>) -> (Vec<Inline>, bool) {
171169
/// Apply post-processing transformations to the Pandoc AST
172170
pub fn postprocess(doc: Pandoc) -> Result<Pandoc, Vec<String>> {
173171
let mut errors = Vec::new();
174-
let raw_reader_format_specifier: Lazy<Regex> =
175-
Lazy::new(|| Regex::new(r"<(?P<reader>.+)").unwrap());
176172
let result = {
177173
// Track seen header IDs to avoid duplicates
178174
let mut seen_ids: HashMap<String, usize> = HashMap::new();
@@ -458,18 +454,6 @@ pub fn postprocess(doc: Pandoc) -> Result<Pandoc, Vec<String>> {
458454

459455
FilterResult(result, true)
460456
})
461-
.with_raw_block(move |raw_block| {
462-
let Some(captures) = raw_reader_format_specifier.captures(&raw_block.text) else {
463-
return Unchanged(raw_block);
464-
};
465-
return FilterResult(
466-
vec![Block::RawBlock(RawBlock {
467-
format: "pandoc-reader:".to_string() + &captures["reader"],
468-
..raw_block
469-
})],
470-
false,
471-
);
472-
})
473457
.with_attr(|attr| {
474458
// TODO in order to do good error messages here, attr will need source mapping
475459
errors.push(format!(
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[User's](#users)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
![User's](image.png)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```{=html}
2+
<iframe class="slide-deck" src="demo/"></iframe>
3+
```

crates/tree-sitter-qmd/tree-sitter-markdown/grammar.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -522,15 +522,6 @@ module.exports = grammar({
522522
$._fenced_code_block_end_backtick,
523523
$._fenced_code_block_end_tilde,
524524

525-
$._html_block_1_start,
526-
$._html_block_1_end,
527-
$._html_block_2_start,
528-
$._html_block_3_start,
529-
$._html_block_4_start,
530-
$._html_block_5_start,
531-
$._html_block_6_start,
532-
$._html_block_7_start,
533-
534525
// Similarly this is used if the closing of a block is not decided by the external parser.
535526
// A `$._block_close` will be emitted at the beginning of the next line. Notice that a
536527
// `$._block_close` can also get emitted if the parent block closes.

crates/tree-sitter-qmd/tree-sitter-markdown/src/grammar.json

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5608,38 +5608,6 @@
56085608
"type": "SYMBOL",
56095609
"name": "_fenced_code_block_end_tilde"
56105610
},
5611-
{
5612-
"type": "SYMBOL",
5613-
"name": "_html_block_1_start"
5614-
},
5615-
{
5616-
"type": "SYMBOL",
5617-
"name": "_html_block_1_end"
5618-
},
5619-
{
5620-
"type": "SYMBOL",
5621-
"name": "_html_block_2_start"
5622-
},
5623-
{
5624-
"type": "SYMBOL",
5625-
"name": "_html_block_3_start"
5626-
},
5627-
{
5628-
"type": "SYMBOL",
5629-
"name": "_html_block_4_start"
5630-
},
5631-
{
5632-
"type": "SYMBOL",
5633-
"name": "_html_block_5_start"
5634-
},
5635-
{
5636-
"type": "SYMBOL",
5637-
"name": "_html_block_6_start"
5638-
},
5639-
{
5640-
"type": "SYMBOL",
5641-
"name": "_html_block_7_start"
5642-
},
56435611
{
56445612
"type": "SYMBOL",
56455613
"name": "_close_block"

0 commit comments

Comments
 (0)