vscode-markdown-preview-enhanced icon indicating copy to clipboard operation
vscode-markdown-preview-enhanced copied to clipboard

“Extend Markdown Parser” not working any more

Open Viktor-Earth opened this issue 1 year ago • 1 comments

Describe the bug Up to version v0.6.10, any code in the "parser.js" file before the line "module.exports = {" did work. In particular, I need external modules that I could load with "require" up to v0.6.10. Example: "const XRegExp = require('./xregexp-all.js');" did work. How can I use "require" to load modules in the "parser.js" file with the current version v0.8.10? This is definitely needed for more demanding tasks. Is there a solution for this?

Environment

  • OS: MacOS 14.1.1
  • VSCode: 1.84.2
  • Markdown Preview Enhanced: 0.8.10

To Reproduce Steps to reproduce the behavior:

  1. Open file "parser.js"
  2. Add any valid "require" on top (Example for a module that has been installed with this path: "const XRegExp = require('./xregexp-all.js');").
  3. Restart VSC, open a *.md file, nothing works, if you remove the Test-Line you have to restart VSC, otherwise Markdown Preview enhanced won't work again.
  4. It looks like any code within the "parser.js" file before the first line starting with "({" does not work any more. A solution is needed to use "require" within the "parser.js" file.

Expected behavior Any code at the beginning of the "parser.js" file should work, especially "require". Otherwise a solution is needed to import modules for usage within the "parser.js"

Markdown file any, it does not depend on the content, it is about the usage of "require" within the "parser.js" file.

Screenshots none

Additional context none

Viktor-Earth avatar Nov 29 '23 13:11 Viktor-Earth

We will consider bringing it back in the future. Right now to support the extension in the browser, require is disabled and all javascript code is run in the sandbox now.

shd101wyy avatar Dec 10 '23 08:12 shd101wyy