instant-markdown / instant-markdown-d

Small instant Markdown preview server
https://instant-markdown.github.io
Other
189 stars 103 forks source link

Live preview is not available #63

Closed xdewx closed 3 years ago

xdewx commented 5 years ago

Problem summary

Expected

Live preview is not available with instant-markdown-d@0.2.0.rc1 . If I rollback to lower version ,it works very well except that no mathjax support.

Environment Information

Provide the output of test command (required)

Run npm test&; sleep 5; npm stop or at least equivalent of cd tests; cat test_math.md | instant-markdown-d --mathjax --debug and paste the console output here:

Generate logfiles if appropriate

  1. package-lock.json / yarn.lock
  2. minimal ~/.vimrc or ~/.config/nvim/init.vim where variables for vim-instant-markdown defined
  3. debug.html

Steps to reproduce the issue (required)

Start with command you used to install instant-markdown-d

1.sudo npm install -g instant-markdown-d@0.2.0.rc1 2. 3.

Screen shot (if possible)

ashwinvis commented 5 years ago

By "live preview" do you mean while

  1. editing the markdown file or
  2. while simply opening the file

Have you tried to preview the test file?

xdewx commented 5 years ago

I mean it works out of expectation when editing the markdown file.

The result of testing is :

user@15:51:00>instant-markdown-d$ sudo cat tests/test_math.md | instant-markdown-d --mathjax --debug
instant-mardown-d version: v0.2.0-rc.1
nodejs version: v8.10.0
Run the following to manually open browser: 
    xdg-open http://localhost:8090/
Rendered html saved as debug.html
Error: Uncaught [Error: EACCES: permission denied, open 'debug.html']
   .......
   .......
    at Function.WAITEXECUTE (file:///usr/local/lib/node_modules/instant-markdown-d/node_modules/mathjax/unpacked/MathJax.js:348:50)
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: 'debug.html' }
ashwinvis commented 5 years ago

Don't use sudo to run the test. Also, copy the test file and run it in your home directory, so you have permissions. Then attach the debug.html that you get.

xdewx commented 5 years ago

{ Error: EACCES: permission denied, open 'debug.html'} This problem is solved by run sudo chmod 777 -R ./*

Then,I rerun sudo cat tests/test_math.md | instant-markdown-d --mathjax --debug,debug.html is generated normally.However,it seems normal.

The debug.html is not supported file type ,so,I rename it to debug.txt .

And,I attached a .png file which is grasp from Firefox. debug.txt 2019-07-23 16-09-36屏幕截图

ashwinvis commented 5 years ago

So it works. The message "Live preview is unavailable" will happen when the instant-markdown-d server is stopped.

xdewx commented 5 years ago

So did who stop the instant-markdown-d server?

I always edit a .md file with vim xx.md,then firefox is opened . If I keep editing the file ,the new content will not appear .This step can't be shown by running cat xx.md | instant-markdown-d --debug.

The formulas are always rendered correctly .

ashwinvis commented 5 years ago

Then it is an issue with how instant-markdown-d is started by Vim. We need a way to debug this in Vim... I will see if it is possible. Thanks for the issue report!

xdewx commented 5 years ago

Ok, thank u!

And add some problems:

  1. If I exit vim,the page in firefox won't close automatically and If I continue to close firefox,the node process still exists which I have to kill -9

All of this problems happen in version 0.2.0-rc.1 ,if I use version 0.1 everything is fine.

ashwinvis commented 5 years ago

Okay that is weird. I thought the node server died while open vim. But now you say it still persists...

Anyways it is a beta release. So keep using the stable one for now. :)

ashwinvis commented 5 years ago

With suan/vim-instant-markdown#161 you should be able to debug this from vim. Do try it.

xdewx commented 5 years ago

Could you tell me how to do it ?

Do you mean :

  1. git clone vim-instant-markdown from master into .vim/bundle/
  2. then vim xx.md
  3. check the log

    Just now, it seems that I found something helpful.

In my .vimrc, there was let g:instant_markdown_port = 10001 . I commented it just now, then I vim xx.md, it is pleasant that the page in browser is changing with my editing. So, I guess if I use custom server port ,the Live preview module still sends content to the default port not the new. Maybe that is just where the problem is. However ,the node process still persists after I exits vim no matter what port I use.

ashwinvis commented 5 years ago

It is mentioned in the readme

If you do not use a plugin manager, copy the after/ftplugin/markdown/instant-markdown.vim file into ~/.vim/after/ftplugin/markdown/ (creating directories as necessary),

And then

For troubleshooting, server startup and curl communication from Vim to the server can be logged into a file.

let g:instant_markdown_logfile = '/tmp/instant_markdown.log'

Then do steps 2 and 3

xdewx commented 5 years ago

Okay, I will try it.

It seems that I am right.

  1. If I remove let g:instant_markdown_port = 10001

    The Live preview is available. The logfile has nothing wrong!

  2. If I add let g:instant_markdown_port = 10001

    % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to localhost port 8090: refuse connection connection established! % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to localhost port 8090: refuse connection

    However ,the node process still persists after I exits vim no matter what port I use.

ashwinvis commented 5 years ago

Thanks for that. I will fix the port option right away.

xdewx commented 5 years ago

Nice, port option has been fixed .

The node process still can't exit automatically after I exit vim and close browser .This can cause that browser can't be started automatically if I vim xx.md after my exiting and closing .

ashwinvis commented 3 years ago

A lot has changed now and a new version is out, so I hope this is no longer an issue. I would close this issue now.