diff options
Diffstat (limited to 'lib/plugins/link/pdf.ex')
-rw-r--r-- | lib/plugins/link/pdf.ex | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/plugins/link/pdf.ex b/lib/plugins/link/pdf.ex index e91dcc2..bb14594 100644 --- a/lib/plugins/link/pdf.ex +++ b/lib/plugins/link/pdf.ex @@ -6,7 +6,7 @@ defmodule Nola.Plugins.Link.PDF do def match(_, _), do: false @impl true - def post_match(_url, "application/pdf"<>_, _header, _opts) do + def post_match(_url, "application/pdf" <> _, _header, _opts) do {:file, nil} end @@ -16,24 +16,32 @@ defmodule Nola.Plugins.Link.PDF do def post_expand(url, file, _, _) do case System.cmd("pdftitle", ["-p", file]) do {text, 0} -> - text = text - |> String.trim() + text = + text + |> String.trim() if text == "" do :error else basename = Path.basename(url, ".pdf") - text = "[#{basename}] " <> text - |> String.split("\n") + + text = + ("[#{basename}] " <> text) + |> String.split("\n") + {:ok, text} end + {_, 127} -> - Logger.error("dependency `pdftitle` is missing, please install it: `pip3 install pdftitle`.") + Logger.error( + "dependency `pdftitle` is missing, please install it: `pip3 install pdftitle`." + ) + :error + {error, code} -> - Logger.warn("command `pdftitle` exited with status code #{code}:\n#{inspect error}") + Logger.warn("command `pdftitle` exited with status code #{code}:\n#{inspect(error)}") :error end end - end |