ianwillie / ianasciidocpreview-active-editor-info

asciidoc preview alternative that will work in pulsar-edit (& atom-edit v1.61 and later hopefully)
MIT License
3 stars 1 forks source link

Missing files #1

Closed dadreggors closed 7 months ago

dadreggors commented 7 months ago

I have just pulled the latest code, and following instructions I installed asciidoctor via npm.

When toggling your preview I get an error in pulsar (1.113.0):

Uncaught Error: ENOENT: no such file or directory, open './temp/XXXasciidocInputFromEditor_words'

At internal/fs/utils.js:307

Error: ENOENT: no such file or directory, open './temp/XXXasciidocInputFromEditor_words'
    at Object.openSync (fs.js:476:3)
    at Object.func [as openSync] (electron/js2c/asar_bundle.js:5:1846)
    at Object.writeFileSync (fs.js:1467:35)
    at getTextOpenWrite (ianasciidocpreview-active-editor-info-view.js:136:12)
    at ianasciidocpreview-active-editor-info-view.js:408:52
    at Function.simpleDispatch (/app.asar/node_modules/event-kit/dist/emitter.js:64:14)
    at Emitter.emit (/app.asar/node_modules/event-kit/dist/emitter.js:257:28)
    at Workspace.didChangeActivePaneItemOnPaneContainer (/app.asar/src/workspace.js:536:22)
    at /app.asar/src/workspace-center.js:17:14
    at Function.simpleDispatch (/app.asar/node_modules/event-kit/dist/emitter.js:64:14)
    at Emitter.emit (/app.asar/node_modules/event-kit/dist/emitter.js:257:28)
    at PaneContainer.didChangeActiveItemOnPane (/app.asar/src/pane-container.js:333:20)
    at Pane.setActiveItem (/app.asar/src/pane.js:466:24)
    at Pane.activateItem (/app.asar/src/pane.js:618:12)
    at TabBarView.onClick (/app.asar/node_modules/tabs/lib/tab-bar-view.js:603:24)

Commands

     -5:06.2.0 settings-view:view-installed-packages (input.hidden-input)
  3x -4:07.6.0 core:backspace (input.hidden-input)
     -4:03.6.0 markdown-writer:insert-new-line (input.hidden-input)
     -4:03.6.0 editor:newline (input.hidden-input)
     -4:03.5.0 markdown-writer:insert-new-line (input.hidden-input)
     -4:03.5.0 editor:newline (input.hidden-input)
     -3:49.5.0 ianasciidocpreview-active-editor-info:toggle (input.hidden-input)
     -3:25.7.0 core:save-as (input.hidden-input)
     -2:57.8.0 core:select-all (input.hidden-input)
     -2:53.3.0 ianasciidocpreview-active-editor-info:toggle (input.hidden-input)

Non-Core Packages

asciidoc-assistant 0.2.3 
asciidoc-image-helper 1.0.1 
asciidoc-preview 2.13.1 
atom-html-preview 0.2.7 
atom-yamljson 0.2.4 
autocomplete-asciidoc 0.1.2 
emmet 2.4.3 
git-menu 3.2.9 
git-status 0.3.4 
ianasciidocpreview-active-editor-info 0.0.0 
json-sort 1.6.0 
language-ansible 0.2.2 
language-asciidoc 1.11.0 
markdown-preview-plus 4.11.3 
markdown-writer 2.11.12 
platformio-ide-terminal 2.10.1 
pretty-json 2.1.2 
print-code 0.7.1 
sort-lines 0.19.0 
ianwillie commented 7 months ago

I wonder if you have asciidoctor.js installed? The nodejs package asciidoctor.js is required. In terminal cd to your project directory where the asciidoc (.adoc) file you wish to preview exists. Then one of npm asciidoctor or npm asciidoctor -g should show asciidoctor as presence.

Mine shows: npm list <currentPath> ├── @asciidoctor/reveal.js@5.0.0-rc.1 └── asciidoctor@2.2.6

Then asciidoctor <inputFile>.adoc -o - should show the html output, or asciidoctor <inputFile>.adoc will write .html file which can be opened with a browser.

If asciidoctor.js is not installed look at https://docs.asciidoctor.org/asciidoctor.js/latest/setup/install/ for guidance.

A caveat: I am very new to javascript, node and this is the first pulsar package that I have created. So please bear with my learning how to work these problems out. At the moment there are no test programmes to test for simple problems with paths and the like.

Please let me know how you get on.

dadreggors commented 7 months ago

I wonder if you have asciidoctor.js installed? The nodejs package asciidoctor.js is required.

As I mentioned in my initial comment, I do have asciidoctor installed as directed in your instructions.

I have just pulled the latest code, and following instructions I installed asciidoctor via npm.

$ npm list          
ddreggors@ /home/ddreggors
└── asciidoctor@3.0.3

I have tested asciidoctor test.adoc -o - and it does show html output for the test document.

dadreggors commented 7 months ago

I am also not very knowledgeable on node OR atom/pulsar packages so we will muddle through lol.

I noted that the missing file seems to be ./temp/XXXasciidocInputFromEditor_words so it seems the package expects to make a temporary file from the editor input (what you have open in your tab?) to be able to build the preview from the temporary file. That file is either not getting created or the code is looking in the wrong path for it

dadreggors commented 7 months ago

ok so looking at your source code I see this:

        fs.writeFileSync(htmloutputDir + "temp/XXXasciidocInputFromEditor_words", asciidocInputFromEditor_words);  // file with original .adoc which is in string words the original asciidoc file - just to check

      // write out raw file created by asciidoctor.js that can be read by browser
      fs.writeFileSync(htmloutputDir + htmloutputFileRawFromAsciidoc, htmloutput);
      console.log(`Just written htmloutputFileRawFromAsciidoc = ${htmloutputFileRawFromAsciidoc}` );

So I created a new folder and file under lib (templ/XXXasciidocInputFromEditor_words) and the error now goes away. However, nothing happens now at all. I do not see anything change and I am not sure where that console.log line is supposed to log to but I do not see that text appear anywhere. Also the new file I created has nothing in it.

I will dig deeper and see if I can figure out where htmloutputDir + htmloutputFileRawFromAsciidoc and also the console.log is showing up.

EDIT: I now have created both files:

$ ls -l lib/temp                                 
total 0
-rw-r--r--. 1 ddreggors ddreggors 0 Jan 29 10:18 iansasciidocpreviewhtmloutput.html
-rw-r--r--. 1 ddreggors ddreggors 0 Jan 29 09:47 XXXasciidocInputFromEditor_words

However, they remain at 0 size and nothing happens in the editor when I toggle the package.

I still do not see a way to see the console.log output anywhere, I have installed several console packages and they do not appear to capture your console.log output. Probably me not understanding where I am supposed to see this.

dadreggors commented 7 months ago

I got console.log working (ctrl-shift-i) finally by adding --no-sandbox

Now I see the errors:

  1. missing folder/files error... we are NOT looking in ianasciidocpreview-active-editor-info/lib but rather in same folder as your adoc file (~/tmp in my case)
  2. Once ^^ that was solved I now see undefined errors
Uncaught (in promise) ReferenceError: previewWidth is not defined
    at getTextOpenWrite (ianasciidocpreview-active-editor-info-view.js:187)
    at ianasciidocpreview-active-editor-info-view.js:408
    at Workspace.observeActiveTextEditor (/opt/Pulsar/resources/app.asar/src/workspace.js:866)
    at new IanasciidocpreviewActiveEditorInfoView (ianasciidocpreview-active-editor-info-view.js:57)
    at ianasciidocpreview-active-editor-info.js:28
    at Workspace.createItemForURI (/opt/Pulsar/resources/app.asar/src/workspace.js:1408)
    at Workspace.open (/opt/Pulsar/resources/app.asar/src/workspace.js:1171)
getTextOpenWrite @ ianasciidocpreview-active-editor-info-view.js? [sm]:187
(anonymous) @ ianasciidocpreview-active-editor-info-view.js? [sm]:408
observeActiveTextEditor @ /opt/Pulsar/resources/app.asar/src/workspace.js:866
IanasciidocpreviewActiveEditorInfoView @ ianasciidocpreview-active-editor-info-view.js? [sm]:57
(anonymous) @ ianasciidocpreview-active-editor-info.js? [sm]:28
createItemForURI @ /opt/Pulsar/resources/app.asar/src/workspace.js:1408
open @ /opt/Pulsar/resources/app.asar/src/workspace.js:1171
async function (async)
open @ /opt/Pulsar/resources/app.asar/src/workspace.js:1107
toggle @ /opt/Pulsar/resources/app.asar/src/workspace.js:1336
toggle @ ianasciidocpreview-active-editor-info.js? [sm]:384
ianasciidocpreview-active-editor-info:toggle @ ianasciidocpreview-active-editor-info.js? [sm]:62
handleCommandEvent @ /app/Pulsar/resources/app.asar/src/command-registry.js:405
module.exports.KeymapManager.dispatchCommandEvent @ /app/Pulsar/resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:617
module.exports.KeymapManager.handleKeyboardEvent @ /app/Pulsar/resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:408
handleDocumentKeyEvent @ /app/Pulsar/resources/app.asar/src/window-event-handler.js:153
dadreggors commented 7 months ago

undefined error is caused here

if (consprint) {console.log(transformScale); console.log(previewHeight); console.log(previewWidth); }

which should be previewPaneWidth not previewWidth

dadreggors commented 7 months ago

I will try to create a merge request for this. Also, the path for temp file should be contained under package not under any given folder the user may have stored there asciidoc files. I will try to include that change in my merge request as well.

dadreggors commented 7 months ago

@ianwillie please review my merge request. This removed all but 1 'File not found' error and also creates the temp folder in the correct location (under package install path).

dadreggors commented 7 months ago

I would add that 1 file remains missing (atom-browser.less) which I cannot see how you pull that one in

ianwillie commented 7 months ago

EDIT: Solved this one. From CHANGELOG.md: atom-browser.less missing colsole. message sorted. Link below removed from ...view file. atom-browser was explored to look at its interesting Zoom bar. Removed from lib/...view.js: hN += <link rel="stylesheet" href="/home/ian/.pulsar/packages/ianasciidocpreview-active-editor-info/styles/atom-browser.less">\n ;

From memory atom-browser is one of the packages based on, is it webview, or something similar.: it is a well written and useful viewer, I recall. Whatever that "webview" package in eclipse is called, it is deprecated and will be removed in some future version of eclipse, I recall. That will mean that most of the pulsar preview packages will stop working. I think if atom-browser package is uninstalled, or perhaps inactivated, the error will vanish.

That is why I have tried to create a package which uses pretty basic html5 which is unlikely to change. To some degree I have been successful, but the limitations on the capabilities of the package are a major drawback.

ianwillie commented 7 months ago

I hope that I have resolved the issues with missing files, so I am closing this. I have also created a branch "Test_Changing_htmloutputDir" which addresses a related issue and puts the temp directory is /home/ instead of the project directory.

ianwillie commented 7 months ago

I hope that I have resolved the issues with missing files, so I am closing this. I have also created a branch "Test_Changing_htmloutputDir" which addresses a related issue and puts the temp directory is /home/ instead of the project directory.