libcmd/markdown: avoid stripping ANSI escapes
Instead, we instruct lowdown not to emit them in the first place. Fixes #622. Change-Id: I596bb873943c2c0b5067c5357a90457f01307cfa
This commit is contained in:
@@ -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.
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user