From b470218d9a89bc29116853260a01af6cab450dae Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 6 May 2022 13:14:49 +0200 Subject: [PATCH] renderMarkdownToTerminal(): Avoid line overflow Lowdown doesn't respect '.cols' exactly (maybe because of the whitespace in front of each line), so adjust .cols a bit. --- src/libcmd/markdown.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libcmd/markdown.cc b/src/libcmd/markdown.cc index 29bb4d31e..71f9c8dff 100644 --- a/src/libcmd/markdown.cc +++ b/src/libcmd/markdown.cc @@ -9,10 +9,12 @@ namespace nix { std::string renderMarkdownToTerminal(std::string_view markdown) { + int windowWidth = getWindowSize().second; + struct lowdown_opts opts { .type = LOWDOWN_TERM, .maxdepth = 20, - .cols = std::max(getWindowSize().second, (unsigned short) 80), + .cols = (size_t) std::max(windowWidth - 5, 60), .hmargin = 0, .vmargin = 0, .feat = LOWDOWN_COMMONMARK | LOWDOWN_FENCED | LOWDOWN_DEFLIST | LOWDOWN_TABLES,