neo4j-documentation / asciidoctor-jupyter

A Jupyter converter for Asciidoctor.js. Write your Notebook in AsciiDoc!
16 stars 1 forks source link

asciidoctor-jupyter\src\index.js:352 : ConverterFactory.register(JupyterConverter, ['jupyter']) undefined? #1

Closed dierk42 closed 3 years ago

dierk42 commented 3 years ago

I want to use asciidoctor-jupyter on Windows 8.1 an run into this problem (installation path of node.js is c:\nodejs):

C:\nodejs\node_modules\asciidoctor-jupyter\src\index.js:352
  ConverterFactory.register(JupyterConverter, ['jupyter'])
                   ^

TypeError: Cannot read property 'register' of undefined
    at Function.module.exports.register (C:\nodejs\node_modules\asciidoctor-jupyter\src\index.js:352:20)
    at C:\nodejs\node_modules\asciidoctor\node_modules\@asciidoctor\cli\lib\invoker.js:134:15
    at Array.forEach (<anonymous>)
    at Function.prepareProcessor (C:\nodejs\node_modules\asciidoctor\node_modules\@asciidoctor\cli\lib\invoker.j
s:127:20)
    at Invoker.invoke (C:\nodejs\node_modules\asciidoctor\node_modules\@asciidoctor\cli\lib\invoker.js:22:13)
    at Object.<anonymous> (C:\nodejs\node_modules\asciidoctor\bin\asciidoctor:9:22)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)

I installed asciidoctor-jupyter via npm.

Any ideas?

ggrossetie commented 3 years ago

Hello @dierk42,

Which version of Asciidoctor.js are you using? Could you please type asciidoctor -v?

dierk42 commented 3 years ago

Oops. Quick reply. Thank you.

The output of asciidoctor.cmd (I use this because I also have installed the ruby asciidoctor):

C:\tmp> asciidoctor.cmd -v
Asciidoctor.js 2.2.5 (Asciidoctor 2.0.16) [https://asciidoctor.org]
Runtime Environment (node v14.17.5 on win32)
CLI version 3.4.0
ggrossetie commented 3 years ago

Oh I see, I've updated the register function to make it compatible with Asciidoctor.js 1.5.x (which is used in Antora 2.3) but the code is now incompatible with Asciidoctor.js > 2.

Having said that, it's an easy fix, I will fix this issue and publish a new version.

dierk42 commented 3 years ago

Perhaps these information may help. I used your example from your readme.md saving the script to mist.js. And I created your notebook example. The output is:

C:\tmp> node mist.js
internal/modules/cjs/loader.js:892
  throw err;
  ^

Error: Cannot find module '@asciidoctor/core'
Require stack:
- C:\tmp\mist.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
    at Function.Module._load (internal/modules/cjs/loader.js:745:27)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (C:\tmp\mist.js:1:21)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'C:\\tmp\\mist.js' ]
}

Perhaps there is also an issue with my node.js installation?

EDIT: changed my question

dierk42 commented 3 years ago

My posting crossed yours :-)

I'll watch for the new version. Thank you

ggrossetie commented 3 years ago

Fixed in https://github.com/neo4j-documentation/asciidoctor-jupyter/commit/a16f1ed3a73a80162c8a87482d8652ddbad87cb5

My posting crossed yours :-)

No worries!

I'll watch for the new version. Thank you

Could you please try again with version 0.1.1?

dierk42 commented 3 years ago

It works! Great. Tahnk you very much.

Using it with

asciidoctor -r asciidoctor-jupyter -b jupyter notebook.adoc

gives the desired result. I tried another of my documents (just texts and images, ordinary documentation). Works as well. The only thing which is not so important: I used a footnote in that text. That was not konverted by your program. But thats only a very minor drawback, because Jupyter notebooks don't know footnotes.

The other way to invoke the converter via API still does not work an gives the above mentioned output.

But for myself: This issue is solved because currently I do not intend to use ist via the API.

Thank you very much for your instant reaction!

ggrossetie commented 3 years ago

It works! Great. Tahnk you very much.

Perfect šŸŽ‰

The other way to invoke the converter via API still does not work an gives the above mentioned output.

You probably didn't install the package asciidoctor or @asciidoctor/core in your Node project? If you don't have a Node project you can create one with npm init -y

$ npm init -y

And then, you need to install both asciidoctor and asciidoctor-jupyter:

$ npm i --save-dev asciidoctor asciidoctor-jupyter

Thank you very much for your instant reaction!

Thank you for catching this bug šŸž I'm closing since this issue is fixed and I'm pretty sure it should work using the API when asciidoctor or @asciidoctor/core is installed.