Skip to content

Commit bee0aae

Browse files
committed
more tight list improvements
1 parent 926c748 commit bee0aae

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

crates/quarto-markdown-pandoc/CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,5 @@ The `quarto-markdown-pandoc` binary accepts the following options:
6060
- If you need to fix parser bugs, you will find use in running the application with "-v", which will provide a large amount of information from the tree-sitter parsing process, including a print of the concrete syntax tree out to stderr.
6161
- use "cargo run --" instead of trying to find the binary location, which will often be outside of this crate.
6262
- If you need to fix parser bugs, you will find use in running the application with "-v", which will provide a large amount of information from the tree-sitter parsing process, including a print of the concrete syntax tree out to stderr.
63+
- When fixing inconsistency bugs, use `pandoc -t json -i <input_file>` to get Pandoc's output, and `cargo run -- -t json -i <input_file>` to get our output.
64+
- When fixing roundtripping bugs, make sure to always add a roundtripping test to `tests/roundtrip_tests/qmd-json-qmd`.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,11 @@ fn process_list(
13551355
// if the first block is not a paragraph, it's not loose
13561356
last_para_range = None;
13571357
}
1358+
} else {
1359+
// if the item has multiple blocks (but not multiple paragraphs,
1360+
// which would have been caught above), we need to reset the
1361+
// last_para_range since this item can't participate in loose detection
1362+
last_para_range = None;
13581363
}
13591364
list_items.push(blocks);
13601365
}

crates/quarto-markdown-pandoc/src/writers/qmd.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ fn write_bulletlist(bulletlist: &BulletList, buf: &mut dyn std::io::Write) -> st
317317
}
318318
let mut item_writer = BulletListContext::new(buf);
319319
for (j, block) in item.iter().enumerate() {
320-
if j > 0 {
321-
// Add a blank line between blocks within a list item
320+
if j > 0 && !is_tight {
321+
// Add a blank line between blocks within a list item in loose lists
322322
writeln!(&mut item_writer)?;
323323
}
324324
write_block(block, &mut item_writer)?;
@@ -348,8 +348,8 @@ fn write_orderedlist(
348348
let current_num = start_num + i;
349349
let mut item_writer = OrderedListContext::new(buf, current_num, delimiter.clone());
350350
for (j, block) in item.iter().enumerate() {
351-
if j > 0 {
352-
// Add a blank line between blocks within a list item
351+
if j > 0 && !is_tight {
352+
// Add a blank line between blocks within a list item in loose lists
353353
writeln!(&mut item_writer)?;
354354
}
355355
write_block(block, &mut item_writer)?;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* a
2+
* b
3+
* c
4+
* d
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* a
2+
* b
3+
* c
4+
* d

0 commit comments

Comments
 (0)