diff --git a/src/libcmd/markdown.cc b/src/libcmd/markdown.cc index 6a0d05d9fba..4566e6ba63c 100644 --- a/src/libcmd/markdown.cc +++ b/src/libcmd/markdown.cc @@ -16,13 +16,25 @@ static std::string doRenderMarkdownToTerminal(std::string_view markdown) { int windowWidth = getWindowSize().second; +#if HAVE_LOWDOWN_1_4 + struct lowdown_opts_term opts_term { + .cols = (size_t) std::max(windowWidth - 5, 60), + .hmargin = 0, + .vmargin = 0, + }; +#endif struct lowdown_opts opts { .type = LOWDOWN_TERM, +#if HAVE_LOWDOWN_1_4 + .term = opts_term, +#endif .maxdepth = 20, +#if !HAVE_LOWDOWN_1_4 .cols = (size_t) std::max(windowWidth - 5, 60), .hmargin = 0, .vmargin = 0, +#endif .feat = LOWDOWN_COMMONMARK | LOWDOWN_FENCED | LOWDOWN_DEFLIST | LOWDOWN_TABLES, .oflags = LOWDOWN_TERM_NOLINK, }; diff --git a/src/libcmd/meson.build b/src/libcmd/meson.build index c484cf998aa..f1a5a56c8e6 100644 --- a/src/libcmd/meson.build +++ b/src/libcmd/meson.build @@ -38,6 +38,8 @@ deps_public += nlohmann_json lowdown = dependency('lowdown', version : '>= 0.9.0', required : get_option('markdown')) deps_private += lowdown configdata.set('HAVE_LOWDOWN', lowdown.found().to_int()) +# The API changed slightly around terminal initialization. +configdata.set('HAVE_LOWDOWN_1_4', lowdown.version().version_compare('>= 1.4.0').to_int()) readline_flavor = get_option('readline-flavor') if readline_flavor == 'editline'