prez icon indicating copy to clipboard operation
prez copied to clipboard

Problems using custom parser

Open flesser opened this issue 8 years ago • 1 comments

I try to use a custom Markdown parser by setting parser = ./custom-markdown-parser in my .prezrc file.

However, I keep getting the following error:

/usr/lib/node_modules/prez/lib/convert.js:32
        throw new Error("Error while loading parser '" + parser + "' (" + e1 + ")");
        ^

Error: Error while loading parser './custom-markdown-parser' (Error: Cannot find module './parsers/./custom-markdown-parser')

The problem seems to be that the script never looks for my custom parser in my local project dir instead of the global prez install path. In convert.js:20, it seems to never enter the // No module: try to load user implementation conditional branch.

If I modify the line to omit the && e1.message.indexOf("'" + parser + "'") !== -1) condition, it works. (But I guess that condition has a reason to be there?)

flesser avatar Mar 30 '16 13:03 flesser

Honestly I feel quite uncomfortable with this condition ;) so I guess you nailed it and there is a bug lying in there. In the first place it was here in case of missing optional dependency. For example, to use "marky" you have to install a prez's peer dependency "marky". But:

  1. This is not well documented
  2. This is hard to detect

I'm not sure how to handle those "default but not enabled parsers" properly, in the meantime your fix is OK and I'll push a version modifying this.

Thanks for your report and fix proposal!

naholyr avatar Mar 30 '16 20:03 naholyr