libcmd: use correct stream for ANSI testing for markdown

Rendering markdown tests if ANSI is supported in order to tell lowdown
to disable ANSI escapes. Unfortunately it was testing stderr and yet
nearly all rendered markdown output was printed to stdout.

Change-Id: Id0000000f0e667d235239c095330d355a9b7714a
This commit is contained in:
Lily Ballard
2025-05-11 17:55:44 -07:00
parent 18aebab9b6
commit 530532ca8a
3 changed files with 5 additions and 4 deletions
+2 -2
View File
@@ -8,7 +8,7 @@
namespace nix {
std::string renderMarkdownToTerminal(std::string_view markdown)
std::string renderMarkdownToTerminal(std::string_view markdown, StandardOutputStream fileno)
{
int windowWidth = getWindowSize().second;
@@ -21,7 +21,7 @@ std::string renderMarkdownToTerminal(std::string_view markdown)
.feat = LOWDOWN_COMMONMARK | LOWDOWN_FENCED | LOWDOWN_DEFLIST | LOWDOWN_TABLES,
.oflags = LOWDOWN_TERM_NOLINK,
};
if (!shouldANSI()) {
if (!shouldANSI(fileno)) {
opts.oflags |= LOWDOWN_TERM_NOANSI;
}
+2 -1
View File
@@ -1,10 +1,11 @@
#pragma once
///@file
#include "lix/libutil/terminal.hh"
#include "lix/libutil/types.hh"
namespace nix {
std::string renderMarkdownToTerminal(std::string_view markdown);
std::string renderMarkdownToTerminal(std::string_view markdown, StandardOutputStream fileno = StandardOutputStream::Stdout);
}
+1 -1
View File
@@ -927,7 +927,7 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
auto welcomeText = cursor->maybeGetAttr(*evalState, "welcomeText");
if (welcomeText) {
notice("\n");
notice(renderMarkdownToTerminal(welcomeText->getString(*evalState)));
notice(renderMarkdownToTerminal(welcomeText->getString(*evalState), StandardOutputStream::Stderr));
}
if (!conflictedFiles.empty())