Commit 2e1afeb3b04204bcc4cdb7f8aa765fdb774aa99f

Thomas de Grivel 2022-05-26T18:48:17

remove pygmentize

diff --git a/lib/pygmentize.ex b/lib/pygmentize.ex
deleted file mode 100644
index 301c730..0000000
--- a/lib/pygmentize.ex
+++ /dev/null
@@ -1,56 +0,0 @@
-defmodule Pygmentize do
-
-  require Logger
-
-  def random_string() do
-    :crypto.strong_rand_bytes(16)
-    |> Base.url_encode64()
-  end
-
-  def lexer(filename) do
-    cmd = "pygmentize"
-    args = ["-N", filename |> String.replace(~r/ /, "_")]
-    Logger.info(inspect([cmd | args]))
-    {out, status} = System.cmd(cmd, args)
-    case status do
-      0 -> out |> String.trim()
-      _ -> ""
-    end
-  end
-
-  @deprecated "use prismjs"
-  def html(content, filename) do
-    lexer = lexer(filename)
-    cmd = "./bin/size #{byte_size(content)} pygmentize -l #{lexer} -f html"
-    Logger.info("EXEC #{cmd}")
-    port = Port.open({:spawn, cmd}, [:binary, :use_stdio, :exit_status, :stderr_to_stdout])
-    Port.monitor(port)
-    send(port, {self(), {:command, content}})
-    html_port(content, port, [])
-  end
-
-  def html_port(content, port, acc) do
-    receive do
-      {^port, {:exit_status, 0}} ->
-        acc |> Enum.reverse() |> Enum.join()
-      {^port, {:exit_status, _status}} ->
-        #IO.inspect("pygmentize exited with status #{status}")
-        nil
-      {^port, {:data, data}} ->
-        html_port(content, port, [data | acc])
-      {:DOWN, _, :port, ^port, _reason} ->
-        #IO.inspect({:down, reason})
-        acc |> Enum.reverse() |> Enum.join()
-      _x ->
-        #IO.inspect(x)
-        html_port(content, port, acc)
-    after 1000 ->
-        result = acc |> Enum.reverse() |> Enum.join()
-        if result == "" do
-          nil
-        else
-          result
-        end
-    end
-  end
-end