From 71af803e1696cd87177ca3e9b16778288b75c69b Mon Sep 17 00:00:00 2001 From: bptato Date: Thu, 21 Mar 2024 16:35:44 +0100 Subject: ansi2html: add separate switch for "standalone" this way its output can be embedded into documents without a pointless DT declaration --- adapter/format/ansi2html.nim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'adapter/format') diff --git a/adapter/format/ansi2html.nim b/adapter/format/ansi2html.nim index fe8deef4..2906e076 100644 --- a/adapter/format/ansi2html.nim +++ b/adapter/format/ansi2html.nim @@ -1,4 +1,5 @@ import std/options +import std/os import std/selectors import io/posixstream @@ -357,7 +358,10 @@ proc processData(state: var State, buf: openArray[char]) = proc main() = let ps = newPosixStream(stdin.getFileHandle()) var state = State(os: newPosixStream(stdout.getFileHandle())) - state.puts("\n
")
+  let standalone = paramCount() >= 1 and paramStr(1) == "-s"
+  if standalone:
+    state.puts("\n")
+  state.puts("
")
   ps.setBlocking(false)
   var buffer {.noinit.}: array[4096, char]
   var selector = newSelector[int]()
@@ -373,6 +377,8 @@ proc main() =
         selector.registerHandle(ps.fd, {Read}, 0)
         discard selector.select(-1)
         selector.unregister(ps.fd)
+  if standalone:
+    state.puts("")
   state.flushOutbuf()
 
 main()
-- 
cgit 1.4.1-2-gfad0