mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 00:08:07 +02:00
renderMarkdownToTerminal: Add _NIX_TEST_RAW_MARKDOWN env var
For testing only.
This commit is contained in:
parent
2b4e3f04a4
commit
97b0114ab8
1 changed files with 19 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include "markdown.hh"
|
#include "markdown.hh"
|
||||||
#include "util.hh"
|
#include "environment-variables.hh"
|
||||||
|
#include "error.hh"
|
||||||
#include "finally.hh"
|
#include "finally.hh"
|
||||||
#include "terminal.hh"
|
#include "terminal.hh"
|
||||||
|
|
||||||
|
@ -10,9 +11,9 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
std::string renderMarkdownToTerminal(std::string_view markdown)
|
|
||||||
{
|
|
||||||
#if HAVE_LOWDOWN
|
#if HAVE_LOWDOWN
|
||||||
|
static std::string doRenderMarkdownToTerminal(std::string_view markdown)
|
||||||
|
{
|
||||||
int windowWidth = getWindowSize().second;
|
int windowWidth = getWindowSize().second;
|
||||||
|
|
||||||
struct lowdown_opts opts
|
struct lowdown_opts opts
|
||||||
|
@ -52,9 +53,21 @@ std::string renderMarkdownToTerminal(std::string_view markdown)
|
||||||
throw Error("allocation error while rendering Markdown");
|
throw Error("allocation error while rendering Markdown");
|
||||||
|
|
||||||
return filterANSIEscapes(std::string(buf->data, buf->size), !isTTY());
|
return filterANSIEscapes(std::string(buf->data, buf->size), !isTTY());
|
||||||
#else
|
|
||||||
return std::string(markdown);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string renderMarkdownToTerminal(std::string_view markdown)
|
||||||
|
{
|
||||||
|
if (auto e = getEnv("_NIX_TEST_RAW_MARKDOWN"); e && *e == "1")
|
||||||
|
return std::string(markdown);
|
||||||
|
else
|
||||||
|
return doRenderMarkdownToTerminal(markdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
std::string renderMarkdownToTerminal(std::string_view markdown)
|
||||||
|
{
|
||||||
|
return std::string(markdown);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace nix
|
||||||
|
|
Loading…
Reference in a new issue