Merge "libcmd/markdown: avoid stripping ANSI escapes" into main

This commit is contained in:
Linus Heckemann
2025-03-10 21:05:40 +00:00
committed by Gerrit Code Review
2 changed files with 13 additions and 1 deletions
+9
View File
@@ -0,0 +1,9 @@
---
synopsis: "Fix `--help` formatting"
issues: [fj#622]
cls: [2776]
category: "Fixes"
credits: ["lheckemann"]
---
The help printed when invoking `nix` or `nix-store` and subcommands with `--help` previously contained garbled terminal escapes. These have been removed.
+4 -1
View File
@@ -21,6 +21,9 @@ std::string renderMarkdownToTerminal(std::string_view markdown)
.feat = LOWDOWN_COMMONMARK | LOWDOWN_FENCED | LOWDOWN_DEFLIST | LOWDOWN_TABLES,
.oflags = LOWDOWN_TERM_NOLINK,
};
if (!shouldANSI()) {
opts.oflags |= LOWDOWN_TERM_NOANSI;
}
auto doc = lowdown_doc_new(&opts);
if (!doc)
@@ -47,7 +50,7 @@ std::string renderMarkdownToTerminal(std::string_view markdown)
if (!rndr_res)
throw Error("allocation error while rendering Markdown");
return filterANSIEscapes(std::string(buf->data, buf->size), !shouldANSI());
return std::string(buf->data, buf->size);
}
}