Skip to content

Commit a17ddf6

Browse files
committed
test with code closer to main.rs, update snapshots and claude memory
1 parent c442408 commit a17ddf6

File tree

10 files changed

+92
-11
lines changed

10 files changed

+92
-11
lines changed

CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ The main documentation for this repository is located at:
99
- When fixing bugs using tests, run the failing test before attempting to fix issues. This helps ensuring that tests are exercising the failure as expected, and fixes actually fix the particular issue.
1010
- 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.
1111
- use "cargo run --" instead of trying to find the binary location, which will often be outside of this crate.
12+
- when calling shell scripts, be mindful of the current directory you're operating in. use `pwd` as necessary to avoid confusing yourself over commands that use relative paths.
13+
- use `jq` instead of `python3 -m json.tool` for pretty-printing. When processing JSON in a shell pipeline, prefer `jq` when possible.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: metadata1
3+
---
4+
5+
::: hello
6+
7+
---
8+
nested: meta
9+
---
10+
11+
:::
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: metadata1
3+
---
4+
5+
::: hello
6+
7+
---
8+
_scope: lexical
9+
nested: meta
10+
---
11+
12+
:::
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: abc
3+
format: pdf
4+
---
5+
# Test
6+
7+
:::: {.callout-tip}
8+
To generate random numbers, you can use
9+
10+
::: {.columns}
11+
::: {.column width="50%"}
12+
Standard python
13+
14+
```py
15+
import python
16+
random.randint(0,100)
17+
```
18+
:::
19+
::: {.column width="50%"}
20+
Numpy
21+
22+
```py
23+
import numpy as np
24+
np.random.default_rng().integers(0,100)
25+
```
26+
:::
27+
:::
28+
::::
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"blocks":[{"c":[{"c":"This","l":{"end":{"column":4,"offset":4,"row":0},"filename":null,"start":{"column":0,"offset":0,"row":0}},"t":"Str"},{"l":{"end":{"column":5,"offset":5,"row":0},"filename":null,"start":{"column":4,"offset":4,"row":0}},"t":"Space"},{"c":"is","l":{"end":{"column":7,"offset":7,"row":0},"filename":null,"start":{"column":5,"offset":5,"row":0}},"t":"Str"},{"l":{"end":{"column":8,"offset":8,"row":0},"filename":null,"start":{"column":7,"offset":7,"row":0}},"t":"Space"},{"c":"a","l":{"end":{"column":9,"offset":9,"row":0},"filename":null,"start":{"column":8,"offset":8,"row":0}},"t":"Str"},{"l":{"end":{"column":10,"offset":10,"row":0},"filename":null,"start":{"column":9,"offset":9,"row":0}},"t":"Space"},{"c":[{"c":"bold","l":{"end":{"column":16,"offset":16,"row":0},"filename":null,"start":{"column":12,"offset":12,"row":0}},"t":"Str"}],"l":{"end":{"column":18,"offset":18,"row":0},"filename":null,"start":{"column":10,"offset":10,"row":0}},"t":"Strong"},{"l":{"end":{"column":19,"offset":19,"row":0},"filename":null,"start":{"column":18,"offset":18,"row":0}},"t":"Space"},{"c":"test.","l":{"end":{"column":24,"offset":24,"row":0},"filename":null,"start":{"column":19,"offset":19,"row":0}},"t":"Str"}],"l":{"end":{"column":24,"offset":24,"row":0},"filename":null,"start":{"column":0,"offset":0,"row":0}},"t":"Para"}],"meta":{},"pandoc-api-version":[1,23,1]}
1+
{"blocks":[{"c":[{"c":"This","l":{"end":{"column":4,"offset":4,"row":0},"filename":null,"start":{"column":0,"offset":0,"row":0}},"t":"Str"},{"l":{"end":{"column":5,"offset":5,"row":0},"filename":null,"start":{"column":4,"offset":4,"row":0}},"t":"Space"},{"c":"is","l":{"end":{"column":7,"offset":7,"row":0},"filename":null,"start":{"column":5,"offset":5,"row":0}},"t":"Str"},{"l":{"end":{"column":8,"offset":8,"row":0},"filename":null,"start":{"column":7,"offset":7,"row":0}},"t":"Space"},{"c":"a","l":{"end":{"column":9,"offset":9,"row":0},"filename":null,"start":{"column":8,"offset":8,"row":0}},"t":"Str"},{"l":{"end":{"column":10,"offset":10,"row":0},"filename":null,"start":{"column":9,"offset":9,"row":0}},"t":"Space"},{"c":[{"c":"bold","l":{"end":{"column":16,"offset":16,"row":0},"filename":null,"start":{"column":12,"offset":12,"row":0}},"t":"Str"}],"l":{"end":{"column":18,"offset":18,"row":0},"filename":null,"start":{"column":10,"offset":10,"row":0}},"t":"Strong"},{"l":{"end":{"column":19,"offset":19,"row":0},"filename":null,"start":{"column":18,"offset":18,"row":0}},"t":"Space"},{"c":"test.","l":{"end":{"column":24,"offset":24,"row":0},"filename":null,"start":{"column":19,"offset":19,"row":0}},"t":"Str"}],"l":{"end":{"column":0,"offset":25,"row":1},"filename":null,"start":{"column":0,"offset":0,"row":0}},"t":"Para"}],"meta":{},"pandoc-api-version":[1,23,1]}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: metadata1
3+
---
4+
5+
::: hello
6+
7+
---
8+
nested: meta
9+
---
10+
11+
:::
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"blocks":[{"c":[["",["hello"],[]],[]],"l":{"end":{"column":0,"offset":63,"row":11},"filename":null,"start":{"column":0,"offset":26,"row":4}},"t":"Div"}],"meta":{"nested":{"c":[{"c":"meta","l":{"end":{"column":4,"offset":4,"row":0},"filename":null,"start":{"column":0,"offset":0,"row":0}},"t":"Str"}],"t":"MetaInlines"},"title":{"c":[{"c":"metadata1","l":{"end":{"column":9,"offset":9,"row":0},"filename":null,"start":{"column":0,"offset":0,"row":0}},"t":"Str"}],"t":"MetaInlines"}},"pandoc-api-version":[1,23,1]}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: metadata1
3+
---
4+
5+
::: hello
6+
7+
---
8+
_scope: lexical
9+
nested: meta
10+
---
11+
12+
:::
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"blocks":[{"c":[["",["hello"],[]],[{"c":{"_scope":{"c":[{"c":"lexical","l":{"end":{"column":7,"offset":7,"row":0},"filename":null,"start":{"column":0,"offset":0,"row":0}},"t":"Str"}],"t":"MetaInlines"},"nested":{"c":[{"c":"meta","l":{"end":{"column":4,"offset":4,"row":0},"filename":null,"start":{"column":0,"offset":0,"row":0}},"t":"Str"}],"t":"MetaInlines"}},"l":{"end":{"column":0,"offset":74,"row":10},"filename":null,"start":{"column":0,"offset":37,"row":6}},"t":"BlockMetadata"}]],"l":{"end":{"column":0,"offset":79,"row":12},"filename":null,"start":{"column":0,"offset":26,"row":4}},"t":"Div"}],"meta":{"title":{"c":[{"c":"metadata1","l":{"end":{"column":9,"offset":9,"row":0},"filename":null,"start":{"column":0,"offset":0,"row":0}},"t":"Str"}],"t":"MetaInlines"}},"pandoc-api-version":[1,23,1]}

crates/quarto-markdown-pandoc/tests/test.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
use glob::glob;
77
use quarto_markdown_pandoc::errors::parse_is_good;
88
use quarto_markdown_pandoc::pandoc::treesitter_to_pandoc;
9+
use quarto_markdown_pandoc::utils::output::VerboseOutput;
910
use quarto_markdown_pandoc::{readers, writers};
10-
use std::io::Write;
11+
use std::io::{self, Write};
1112
use std::process::{Command, Stdio};
1213
use tree_sitter_qmd::MarkdownParser;
1314

@@ -242,18 +243,20 @@ where
242243
match entry {
243244
Ok(path) => {
244245
eprintln!("Opening file: {}", path.display());
245-
let input = std::fs::read_to_string(&path).expect("Failed to read file");
246246
let snapshot_path = path.with_extension("qmd.snapshot");
247247
let mut buffer = Vec::new();
248-
249-
let pandoc = treesitter_to_pandoc(
250-
&mut std::io::sink(),
251-
&MarkdownParser::default()
252-
.parse(input.as_bytes(), None)
253-
.unwrap(),
248+
let mut input = std::fs::read_to_string(&path).expect("Failed to read file");
249+
if !input.ends_with("\n") {
250+
input.push('\n'); // ensure the input ends with a newline
251+
}
252+
let mut output_stream = VerboseOutput::Sink(io::sink());
253+
let pandoc = readers::qmd::read(
254254
input.as_bytes(),
255-
)
256-
.unwrap();
255+
false,
256+
&path.to_string_lossy(),
257+
&mut output_stream,
258+
None::<fn(&[u8], &quarto_markdown_pandoc::utils::tree_sitter_log_observer::TreeSitterLogObserver, &str) -> Vec<String>>,
259+
).unwrap();
257260

258261
writer(&pandoc, &mut buffer).unwrap();
259262
let output = String::from_utf8(buffer).expect("Invalid UTF-8 in output");

0 commit comments

Comments
 (0)