markdown-to-json icon indicating copy to clipboard operation
markdown-to-json copied to clipboard

Suggestion: Pass directory and possibly with a recursive option

Open ClydeDz opened this issue 5 years ago • 7 comments

Currently, I've written a PowerShell script to loop thru all markdown files in a directory and sub-directories and then pass the list of files. Would be great to have a built in option to do this instead.

P.S. I've tried the command ./node_modules/.bin/m2j -o index.json ./mddata/*.md but I get this error: Error: ENOENT: no such file or directory, lstat './mddata/*.md'.

ClydeDz avatar Jun 04 '19 10:06 ClydeDz

Hmm. This looks like a glob star expansion issue on Windows. I have a Parallels VM with Windows on it that I can test on. Adding this to the stack of issues to fix.

scottstanfield avatar Jan 03 '20 14:01 scottstanfield

On Windows, if you have Git Bash, you can run something like ./node_modules/.bin/m2j -o index.json ./mddata/*.md just fine

go-diego avatar Feb 19 '20 21:02 go-diego

That seems like a solid work-around. Can you test with WSL as well on Windows? Then I can close this issue.

scottstanfield avatar Feb 20 '20 22:02 scottstanfield

Here is what I found:

Assuming you have defined an npm script like this:

 "scripts": {
    "start": "node_modules/.bin/m2j -p -c -o output.json ./input/*.md"
  }

Opening a git bash terminal (or setting it up as the integrated terminal on vs code) and running npm start will not work and will throw the error the OP reports.

However, if in the git bash terminal you run node_modules/.bin/m2j -p -c -o output.json ./input/*.md, this will work.

With WSL, both npm start and node_modules/.bin/m2j -p -c -o output.json ./input/*.md will work.

Note: With WSL, as a first time user just for this test, I had to solve a path issue and install npm and nodejs again on my Linux distro.

go-diego avatar Feb 21 '20 00:02 go-diego

Suggestion for now: rather than add a recursive feature, do that in the outer controlling shell either with setopt -s extglob and maybe with GNU parallel.

Try:

shopt -s extglob
ls **/*.sh

Will recursively list all the *.sh files under your path. Just a thought. Still leaving this open until a workaround.

scottstanfield avatar Mar 01 '20 17:03 scottstanfield

Hi! I'm seeking too to have nested jsons, based on the folder structure on which I'm using m2a. Can you suggest me a way to achieve this?

ph1-xyz avatar Mar 15 '20 14:03 ph1-xyz

@ph1-xyz The solution above did not work for you?

go-diego avatar Mar 23 '20 20:03 go-diego