From 76df9366cb03ade8e62a624ac10eb76dd3be80fc Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Tue, 27 Aug 2019 15:27:29 +1000 Subject: [PATCH] tools: Add color to pandoc output by using elinks. --- eris/tools.py | 12 ++++++++++++ eris/tools.toml | 7 +------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/eris/tools.py b/eris/tools.py index 3a5a2fb..54b0768 100644 --- a/eris/tools.py +++ b/eris/tools.py @@ -392,6 +392,18 @@ def html_syntax(path): return status, stderr +@deps(deps={"pandoc", "elinks"}, url="pandoc", + executables={"pandoc", "elinks"}) +def pandoc(path): + with tempfile.TemporaryDirectory() as temp_dir: + temp_path = os.path.join(temp_dir, "temp.html") + _do_command(["pandoc", "-t", "html", "-o", temp_path, path]) + return _run_command( + ["elinks", "-no-numbering", "-no-references", + "-dump-color-mode", "1", "-dump", temp_path], + has_color=True, success_status=Status.normal) + + MAX_IMAGE_SIZE = 200 diff --git a/eris/tools.toml b/eris/tools.toml index 1bfa843..b2b387c 100644 --- a/eris/tools.toml +++ b/eris/tools.toml @@ -21,7 +21,7 @@ tools_for_extensions = [ [["bash", "sh", "dash", "ksh"], ["shellcheck"]], [["wasm"], ["wasm_validate", "wasm_objdump"]], [["pdf"], ["pdf2txt"]], - [["html", "htm"], ["html_syntax", "html2text", "pandoc", "elinks"]], + [["html", "htm"], ["html_syntax", "html2text", "elinks"]], [["yaml", "yml"], ["yamllint"]], [["md", "epub", "docx", "odt", "rst"], ["pandoc"]], [["zip", "jar", "apk", "egg", "whl"], ["zipinfo"]], @@ -206,11 +206,6 @@ tools_for_extensions = [ command = "html2text" success_status = "normal" -[pandoc] - dependencies = ["pandoc"] - command = "pandoc -t plain" - success_status = "normal" - [elinks] dependencies = ["elinks"] command = "elinks -dump-color-mode 1 -dump"