markdown-to-json
markdown-to-json copied to clipboard
Suggestion: Pass directory and possibly with a recursive option
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'
.
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.
On Windows, if you have Git Bash, you can run something like ./node_modules/.bin/m2j -o index.json ./mddata/*.md
just fine
That seems like a solid work-around. Can you test with WSL as well on Windows? Then I can close this issue.
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.
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.
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 The solution above did not work for you?