Repository: PumasAI/QuartoNotebookRunner.jl (julia)

Issue:
Support truncation of output of large data structures
With QuartoNotebookRunner 0.4.0,

     ```{julia}
     v = rand(10^7)
     ```

produces $10^7$ output lines. IJulia truncates in a way similar to the REPL, see the third cell here:
https://www.math.uni-leipzig.de/~hellmund/juliabook/chapters/numerictypes.html#der-datentyp-bigint

Pull request description:
Fixes #57, similar behaviour to IJulia and REPL.

Patch:
diff --git a/src/worker.jl b/src/worker.jl
index 1dbf3d9e..9d00eec3 100644
--- a/src/worker.jl
+++ b/src/worker.jl
@@ -243,6 +243,7 @@ function worker_init(f::File)
                 io,
                 :module => WORKSPACE[],
                 :color => true,
+                :limit => true,
                 # This allows a `show` method implementation to check for
                 # metadata that may be of relevance to it's rendering. For
                 # example, if a `typst` table is rendered with a caption


Test patch:
diff --git a/test/examples/limit_output.qmd b/test/examples/limit_output.qmd
new file mode 100644
index 00000000..544c4111
--- /dev/null
+++ b/test/examples/limit_output.qmd
@@ -0,0 +1,7 @@
+---
+title: Limit output
+---
+
+```{julia}
+ones(1000, 1000)
+```
diff --git a/test/testsets/limit_output.jl b/test/testsets/limit_output.jl
new file mode 100644
index 00000000..a6650fb7
--- /dev/null
+++ b/test/testsets/limit_output.jl
@@ -0,0 +1,9 @@
+include("../utilities/prelude.jl")
+
+test_example(joinpath(@__DIR__, "../examples/limit_output.qmd")) do json
+    cells = json["cells"]
+    text = cells[2]["outputs"][1]["data"]["text/plain"]
+    @test contains(text, "…")
+    @test contains(text, "⋮")
+    @test contains(text, "⋱")
+end