tools: Add color to pandoc output by using elinks.

This commit is contained in:
Andrew Hamilton 2019-08-27 15:27:29 +10:00
parent 6dfd095033
commit 76df9366cb
2 changed files with 13 additions and 6 deletions

View file

@ -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

View file

@ -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"