diff --git a/src/config.jl b/src/config.jl
index 0dcf9012..b2c2947e 100644
--- a/src/config.jl
+++ b/src/config.jl
@@ -17,8 +17,9 @@ const _DEFAULT_PARAMS = Dict{Symbol,Any}(
:term => false,
:prompt => "julia>",
:label => nothing,
- :wrap => true,
+ :wrap => false,
:line_width => 75,
+ :displaysize => displaysize(),
:fig_ext => nothing,
:fig_pos => nothing,
:fig_env => nothing,
diff --git a/src/run.jl b/src/run.jl
index b47aa974..60032113 100644
--- a/src/run.jl
+++ b/src/run.jl
@@ -260,7 +260,11 @@ function eval_chunk(doc::WeaveDoc, chunk::CodeChunk, report::Report, mod::Module
chunk.options[:out_width] = report.format.out_width
end
- chunk.result = run_code(doc, chunk, report, mod)
+ # Get the default `displaysize`.
+ lines, cols = chunk.options[:displaysize]
+ chunk.result = withenv("LINES" => lines, "COLUMNS" => cols) do
+ run_code(doc, chunk, report, mod)
+ end
execute_posthooks!(chunk)
diff --git a/test/test_display.jl b/test/test_display.jl
index c8c36b43..0289673f 100644
--- a/test/test_display.jl
+++ b/test/test_display.jl
@@ -23,6 +23,66 @@ DataFrame(a=rand($n))
@test isdefined(doc.chunks[1], :rich_output)
@test count("
", doc.chunks[1].rich_output) < n
+# `displaysize`
+rows = 10 # number of rows in table
+columns = 10 # number of colums in table
+
+displaysize_rows = 1
+displaysize_columns = 1
+displayed_rows = displaysize_rows # number of rows that ends up getting displayed
+displayed_columns = displaysize_columns # number of columns that ends up getting displayed
+
+doc = mock_run("""
+```julia; displaysize=($displaysize_rows, $displaysize_columns)
+using DataFrames
+DataFrame(Dict(Symbol(i) => rand($(rows)) for i = 1:$(columns)))
+```
+"""; doctype = "md2html")
+@test isdefined(doc.chunks[1], :rich_output)
+# Name row: 1
+# Type row: 1
+# Displayed rows: `displaysize_rows`
+# ... row: 1
+@test count("
", doc.chunks[1].rich_output) == displayed_rows + 3
+# Name row: 1 per displayed column + 1 for index column
+# Type row: 1 per displayed column + 1 for index column
+# Displayed rows: 1 per row
+# ... row: 1
+# Mistakenly match ` rand($(rows)) for i = 1:$(columns)))
+```
+"""; doctype = "md2html")
+@test isdefined(doc.chunks[1], :rich_output)
+@test count("", doc.chunks[1].rich_output) == displayed_rows + 3
+@test count(" rand($(rows)) for i = 1:$(columns)))
+```
+"""; doctype = "md2html")
+@test isdefined(doc.chunks[1], :rich_output)
+@test count(" |
", doc.chunks[1].rich_output) == displayed_rows + 3
+@test count(" |