Skip to content

Commit

Permalink
Merge pull request NixOS#12115 from trofi/libcmd-lowdown-1.4-support
Browse files Browse the repository at this point in the history
libcmd: update to support lowdown-1.4 API
  • Loading branch information
roberth authored Dec 30, 2024
2 parents a7f5563 + edbfe86 commit 61c3559
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/libcmd/markdown.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 2 additions & 0 deletions src/libcmd/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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'
Expand Down

0 comments on commit 61c3559

Please sign in to comment.