timofurrer / pandoc-mermaid-filter

Pandoc filter for mermaid code blocks
MIT License
75 stars 21 forks source link

Could not create directory "mermaid-images" #20

Closed Bartrcarlson closed 7 months ago

Bartrcarlson commented 1 year ago

I am assuming this is an issue with having a hyphenated directory name.

Could not create directory "mermaid-images"
Traceback (most recent call last):
  File "/home/bart/.local/bin/pandoc-mermaid", line 8, in <module>
    sys.exit(main())
  File "/home/bart/.local/lib/python3.10/site-packages/pandoc_mermaid_filter.py", line 38, in main
    toJSONFilter(mermaid)
  File "/home/bart/.local/lib/python3.10/site-packages/pandocfilters.py", line 148, in toJSONFilter
    toJSONFilters([action])
  File "/home/bart/.local/lib/python3.10/site-packages/pandocfilters.py", line 182, in toJSONFilters
    sys.stdout.write(applyJSONFilters(actions, source, format))
  File "/home/bart/.local/lib/python3.10/site-packages/pandocfilters.py", line 213, in applyJSONFilters
    altered = walk(altered, action, format, meta)
  File "/home/bart/.local/lib/python3.10/site-packages/pandocfilters.py", line 141, in walk
    return {k: walk(v, action, format, meta) for k, v in x.items()}
  File "/home/bart/.local/lib/python3.10/site-packages/pandocfilters.py", line 141, in <dictcomp>
    return {k: walk(v, action, format, meta) for k, v in x.items()}
  File "/home/bart/.local/lib/python3.10/site-packages/pandocfilters.py", line 128, in walk
    res = action(item['t'],
  File "/home/bart/.local/lib/python3.10/site-packages/pandoc_mermaid_filter.py", line 31, in mermaid
    subprocess.check_call([MERMAID_BIN, "-i", src, "-o", dest])
  File "/usr/lib/python3.10/subprocess.py", line 364, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/usr/lib/python3.10/subprocess.py", line 345, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.10/subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1845, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'mermaid'
Error running filter pandoc-mermaid:
Filter returned error status 1

I get the same result running native windows and WSL ubuntu

oysstu commented 1 year ago

Replace os.mkdir(imagedir) with os.makedirs(imagedir, exist_ok=True) in pandocfilters.py

AlexAltea commented 7 months ago

This is fixed in the latest version of pandocfilters.

@timofurrer This issue can be closed now.

Bartrcarlson commented 7 months ago

Great thank you