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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user