diff --git a/meson.build b/meson.build index 4297703eb..ef28cfd0a 100644 --- a/meson.build +++ b/meson.build @@ -301,6 +301,11 @@ editline = dependency('libeditline', 'editline', version : '>=1.14', required : lowdown = dependency('lowdown', version : '>=0.9.0', required : true, include_type : 'system') +# TODO(sterni): drop the corresponding #ifdef after NixOS 25.05 is EOL which still distributes lowdown < 1.4.0 +if lowdown.version().version_compare('>= 1.4.0') + add_project_arguments('-DLOWDOWN_SEPARATE_TERM_OPTS', language: 'cpp') +endif + # HACK(Qyriad): rapidcheck's pkg-config doesn't include the libs lol # Note: technically we 'check' for rapidcheck twice, for the internal-api-docs handling above, # but Meson will cache the result of the first one, and the required : arguments are different. diff --git a/src/libcmd/markdown.cc b/src/libcmd/markdown.cc index dbaab8c19..c1b32b43c 100644 --- a/src/libcmd/markdown.cc +++ b/src/libcmd/markdown.cc @@ -11,13 +11,28 @@ namespace nix { std::string renderMarkdownToTerminal(std::string_view markdown) { int windowWidth = getWindowSize().second; + size_t lowdown_cols = std::max(windowWidth - 5, 60); - struct lowdown_opts opts { + struct lowdown_opts opts{ .type = LOWDOWN_TERM, +#ifdef LOWDOWN_SEPARATE_TERM_OPTS + .term = + { + .cols = lowdown_cols, + .width = 0, + .hmargin = 0, + .hpadding = 4, + .vmargin = 0, + .centre = 0, + }, + // maxdepth needs to be part of the ifdefs to match declaration order .maxdepth = 20, - .cols = (size_t) std::max(windowWidth - 5, 60), +#else + .maxdepth = 20, + .cols = lowdown_cols, .hmargin = 0, .vmargin = 0, +#endif /* LOWDOWN_SEPARATE_TERM_OPTS */ .feat = LOWDOWN_COMMONMARK | LOWDOWN_FENCED | LOWDOWN_DEFLIST | LOWDOWN_TABLES, .oflags = LOWDOWN_TERM_NOLINK, }; diff --git a/tests/functional/repl_characterization/data/basic_repl.test b/tests/functional/repl_characterization/data/basic_repl.test index a8dea6d7c..51cdb6fec 100644 --- a/tests/functional/repl_characterization/data/basic_repl.test +++ b/tests/functional/repl_characterization/data/basic_repl.test @@ -1,12 +1,11 @@ nix-repl> 1 + 1 2 - nix-repl> :doc builtins.head - Synopsis: builtins.head list + nix-repl> :doc builtins.add + Synopsis: builtins.add e1 e2 + + Return the sum of the numbers e1 and e2. - Return the first element of a list; abort evaluation if - the argument isn’t a list or is an empty list. You can - test whether a list is empty by comparing it with []. nix-repl> f = a: "" + a