instant-markdown / vim-instant-markdown

Instant Markdown previews from Vim
https://instant-markdown.github.io
Other
2.72k stars 249 forks source link

(bug) Doesn't display content #1

Closed mvanveen closed 12 years ago

mvanveen commented 12 years ago

I installed vim-instant-markdown by invoking the documented gem and npm commands. I also installed the vim plugin with pathogen by moving the .vim file into to a plugin directory within my bundle/ directory.

When I open vim files in both macvim and vim, chrome opens up a new tab to localhost:8090 but doesn't display any content. Writing the buffer doesn't seem to help either.

I'm on mac os x version 10.7.3, running ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.1], running node v0.4.10.

suan commented 12 years ago

Would it be possible for you to upgrade your node.js to v0.6.6 or newer and try again? If not let me know. Thanks.

mvanveen commented 12 years ago

I upgraded to v0.6.11. Still isn't working for me... :persevere:

Any other ideas? Thanks for your help debugging!

suan commented 12 years ago

Alright, from the sound of it you're trying to open an existing, non-empty markdown file, correct?

Also, I assume that you have the latest version of my vim plugin and the node package "instant-markdown-d" version 0.0.2 installed?

Try this from anywhere in your shell: echo "lala" | instant-markdown-d

Does a browser tab open with the text "lala" shown in it?

suan commented 12 years ago

@mvanveen are you still having issues? If so I'd be glad to help, but otherwise I'll be closing this bug.

mvanveen commented 12 years ago

Hi Suan,

I have upgraded node and am still experiencing problems. A chrome window to localhost pops up whenever I edit markdown in vim but nothing is still served.

Sent from my iPhone

Michael Van Veen | Software Engineer @ Getaround | +1 724 VAN-VEEN | mvanveen@getaround.com |

On Mar 12, 2012, at 7:12 PM, suanreply@reply.github.com wrote:

@mvanveen are you still having issues? If so I'd be glad to help, but otherwise I'll be closing this bug.


Reply to this email directly or view it on GitHub: https://github.com/suan/vim-instant-markdown/issues/1#issuecomment-4466241

suan commented 12 years ago

What do you get when you do echo "lala" | instant-markdown-d from your home directory? Do you see anything in the browser window then? You should also see a "connection established" in your terminal.

mvanveen commented 12 years ago

Eureka!

Here's what I get: http://cl.ly/1I0E363F1D1s0h1P1G2E

Best regards,

Michael Van Veen Michael@mvanveen.net

On Mon, Mar 12, 2012 at 9:52 PM, suan < reply@reply.github.com

wrote:

What do you get when you do echo "lala" | instant-markdown-d from your home directory? Do you see anything in the browser window then? You should also see a "connection established" in your terminal.


Reply to this email directly or view it on GitHub: https://github.com/suan/vim-instant-markdown/issues/1#issuecomment-4467499

mvanveen commented 12 years ago

Here's my terminal output.

➜  ~ git:(master) ✗ echo "lala" | instant-markdown-d
   info  - socket.io started
connection established!

Is the problem with vim, then? I don't believe my terminal has ruby compilation, but I'm fairly certain that macvim does.. Neither seem to work.

suan commented 12 years ago

Hmmm a vim problem seems unlikely. Could be a connectivity issue. Try this:

echo "lala" | instant-markdown-d

Then in another terminal window:

echo "abcdefg" | curl -X PUT -T - http://localhost:8090/

You should see the browser window's contents change to "abcdefg" from "lala". If this if fine then we'll try to diagnose vim. This is turning out to be some adventure ;-)

mvanveen commented 12 years ago

It worked! Went from lala to abcdefg. Time to diagnose vim?

Thanks for all of your help so far!

On Tue, Mar 13, 2012 at 7:18 PM, suan < reply@reply.github.com

wrote:

Hmmm a vim problem seems unlikely. Could be a connectivity issue. Try this:

echo "lala" | instant-markdown-d

Then in another terminal window:

echo "abcdefg" | curl -X PUT -T - http://localhost:8090/

You should see the browser window's contents change to "abcdefg" from "lala". If this if fine then we'll try to diagnose vim. This is turning out to be some adventure ;-)


Reply to this email directly or view it on GitHub: https://github.com/suan/vim-instant-markdown/issues/1#issuecomment-4490932

suan commented 12 years ago

When you open either an empty or non-empty markdown file, is the browser window copletely empty? Or do you get a yellow background like in the "lala" case?

Also, maybe your vim can't call out to cURL for some reason. Try executing :exec "!curl -I www.google.com" within vim and see if you get a 200 response.

(Also, your vim doesn't need to have Ruby support for this to work. All it does is execute shell commands)

mvanveen commented 12 years ago

Completely empty.

I get a 200 response when I execute curl :-/

  HTTP/1.1 200 OK
  Date: Wed, 14 Mar 2012 05:13:58 GMT
  Expires: -1
  Cache-Control: private, max-age=0
  Content-Type: text/html; charset=ISO-8859-1
  Set-Cookie:
  PREF=ID=ea81ea09cb681933:FF=0:TM=1331702038:LM=1331702039:S=saOTnmq7PvEwAPSR;
  expires=Fri, 14-Mar-2014 05:13:59 GMT; path=/; domain=.google.com
  Set-Cookie:
  NID=57=l4R-GZD9G5WfKgUweboWwC81LikmDNA1wPWNKl804zVVa9Kmi4WCYa-k5UfykLs0lJC61ijzUltHAwfztr-9SS0Xtao8UWy4RCCOkTCsHWdg2p3qA33PV2iuWQJdHeG2;
  expires=Thu, 13-Sep-2012 05:13:59 GMT; path=/; domain=.google.com; HttpOnly
  P3P: CP="This is not a P3P policy! See
  http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657for
  more info."
  Server: gws
  X-XSS-Protection: 1; mode=block
  X-Frame-Options: SAMEORIGIN
  Transfer-Encoding: chunked
suan commented 12 years ago

Hmmmmmm.... I'll look into it. In the meantime, perhaps you might share your vim --version output? Here's mine for example:

syeo@syeo-mac:~ $ vim --version 
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jan  4 2012 23:59:50)
MacOS X (unix) version
Included patches: 1-353
Compiled by syeo@syeo-mac
Huge version with MacVim GUI.  Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent 
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff 
+digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi 
+file_in_path +find_in_path +float +folding -footer +fork() +fullscreen 
-gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap 
+libcall +linebreak +lispindent +listcmds +localmap -lua +menu +mksession 
+modify_fname +mouse +mouseshape +mouse_dec -mouse_gpm -mouse_jsbterm 
+mouse_netterm -mouse_sysmouse +mouse_xterm +mouse_urxvt +multi_byte 
+multi_lang -mzscheme +netbeans_intg +odbeditor +path_extra +perl 
+persistent_undo +postscript +printer +profile +python -python3 +quickfix 
+reltime +rightleft +ruby +scrollbind +signs +smartindent -sniff +startuptime 
+statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white 
+tcl +terminfo +termresponse +textobjects +title +toolbar +transparency 
+user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace 
+wildignore +wildmenu +windows +writebackup -X11 -xfontset +xim -xsmp 
-xterm_clipboard -xterm_save
suan commented 12 years ago

Alright, serious debug mode!

The fact that you get a completely white screen (without even a border) suggests to me that for some reason the docter markdown parser isn't working properly when invoked from vim. However I can't make sense of it since it works when you call instant-markdown-d from outside... I've also tried it on RVM ruby 1.9.2 and it works. (Are you using RVM or rbenv or anything that might provide a different load path when used in the terminal interactively vs used from elsewhere?)

You can also try this: replace your current instant-markdown.vim with this code:

function! UpdateMarkdown()
  if (b:last_num_changes == "" || b:last_num_changes != b:changedtick)
    let b:last_num_changes = b:changedtick
    let current_buffer = join(getbufline("%", 1, "$"), "\n")
    exec "!echo " . escape(shellescape(current_buffer), "%!#") . " | curl -X PUT -T - http://localhost:8090/ &>/dev/null &"
  endif
endfunction
function! OpenMarkdown()
  let b:last_num_changes = ""
  exec "!echo " . escape(shellescape(join(getbufline("%", 1, "$"), "\n")), "%!#") . " | instant-markdown-d &>/dev/null &"
endfunction
function! CloseMarkdown()
  exec "!curl -s -X DELETE http://localhost:8090/ &>/dev/null &"
endfunction

autocmd CursorMoved,CursorMovedI,CursorHold,CursorHoldI *.{md,mkd,mkdn,mark*} call UpdateMarkdown()
autocmd BufWinLeave *.{md,mkd,mkdn,mark*} call CloseMarkdown()
autocmd BufWinEnter *.{md,mkd,mkdn,mark*} call OpenMarkdown()

It removes all the silent! statements which gobble up errors. Then open an existing markdown file and start modifying it. You'll constantly be interrupted by output at the bottom of the screen, but if they look like the output of curl commands or match the contents of the current buffer then just cancel them and ignore them. What we're hoping to see are things that look like errors.

suan commented 12 years ago

Hey oludiro,

Thanks for the tip. I've since updated the repo to include a plugin/ folder with the .vim file inside. However, when you say "it didn't work at all" for you, did it open a browser window like in @mvanveen's case? If not, then I'm afraid his is a different problem.

On Thu, Mar 15, 2012 at 2:37 AM, oludiro < reply@reply.github.com

wrote:

Hi Suan ... Thank you for building this plugins. this is awesome helper script to edit markdown. I installed your plugin using VimBundle. At first it's not working at all, but then i made a plugin folder inside your bundle folder, and move your .vim file into that plugin folder. Now, your script is working and previewing my md files.

Thanks again, hope this will help you debugging your script.


Reply to this email directly or view it on GitHub: https://github.com/suan/vim-instant-markdown/issues/1#issuecomment-4515128

mvanveen commented 12 years ago

Hey Suan, haven't had a chance to debug this, I'll try to get to it after work today. Thanks for your help debugging!

--mvv

On Thu, Mar 15, 2012 at 10:01 AM, suan < reply@reply.github.com

wrote:

Hey oludiro,

Thanks for the tip. I've since updated the repo to include a plugin/ folder with the .vim file inside. However, when you say "it didn't work at all" for you, did it open a browser window like in @mvanveen's case? If not, then I'm afraid his is a different problem.

  • Suan

On Thu, Mar 15, 2012 at 2:37 AM, oludiro < reply@reply.github.com

wrote:

Hi Suan ... Thank you for building this plugins. this is awesome helper script to edit markdown. I installed your plugin using VimBundle. At first it's not working at all, but then i made a plugin folder inside your bundle folder, and move your .vim file into that plugin folder. Now, your script is working and previewing my md files.

Thanks again, hope this will help you debugging your script.


Reply to this email directly or view it on GitHub:

https://github.com/suan/vim-instant-markdown/issues/1#issuecomment-4515128


Reply to this email directly or view it on GitHub: https://github.com/suan/vim-instant-markdown/issues/1#issuecomment-4523993

oludiro commented 12 years ago

it was not even opening the browser since it never get read by vim as plugin ( I saw your update, including the plugin/ folder). I think I got an older repo in my box. BTW, I am curious on how to make this plugin work with multimarkdown since you are using ruby as the converter and mutimarkdown is a cli http://fletcherpenney.net/multimarkdown/use/

suan commented 12 years ago

@oludiro: I'm actually using Docter, which is basically just a script which is a thin wrapper around redcarpet itself, which I believe is the Markdown parsing library Github uses. I don't believe multimarkdown is involved in any way

panozzaj commented 12 years ago

Maybe this is not the right forum for this, but I am getting similar errors on OS X (Snow Leopard) with Node v0.6.13 and the latest code running under pathogen. My vim configuration is macvim with the following settings:

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Aug 15 2010 22:03:01)
MacOS X (unix) version
Compiled by Bjorn Winckler <bjorn.winckler@gmail.com>
Huge version with MacVim GUI.  Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent 
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff 
+digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi 
+file_in_path +find_in_path +float +folding -footer +fork() +fullscreen 
-gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap 
+libcall +linebreak +lispindent +listcmds +localmap -lua +menu +mksession 
+modify_fname +mouse +mouseshape +mouse_dec -mouse_gpm -mouse_jsbterm 
+mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme 
+netbeans_intg +odbeditor -osfiletype +path_extra +perl +persistent_undo 
+postscript +printer +profile +python -python3 +quickfix +reltime +rightleft 
+ruby +scrollbind +signs +smartindent -sniff +startuptime +statusline 
-sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white -tcl +terminfo
 +termresponse +textobjects +title +toolbar +transparency +user_commands 
+vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore 
+wildmenu +windows +writebackup -X11 -xfontset +xim -xsmp -xterm_clipboard 
-xterm_save 
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X_UNIX -no-cpp-precomp  -g -O2 -arch i386 -arch x86_64 -D_FORTIFY_SOURCE=1      
Linking: gcc   -L.    -L.         -arch i386 -arch x86_64 -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon      -lncurses  -liconv -framework Cocoa    -L/usr/local/lib  -L/System/Library/Perl/5.10.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -framework Python   -framework Ruby  

When I run the lala command above, a browser window opens but I see no text. When I execute the abcdef command, nothing happens in the browser.

However, the same code running on my Ubuntu machine seems to run as desired, and, I might add, quite nicely. :) Hope this adds to the conversation.

suan commented 12 years ago

@panozzaj Your problem is a little different from mvanveen's since the invoking instant-markdown-d directly worked for him. It sounds like it might be a problem with the underlying renderer. Double check that the redcarpet and pygments.rb gems are installed.

After that, try going to <node installation>/node_modules/instant-markdown-d, then run echo "lala" | node_modules/docter/bin/github-flavored-markdown.rb. You should get output that looks like a lot of css followed by <p>lala</p>. If you don't, then something's up with either your gem dependencies instant-markdown-d's npm dependencies.

panozzaj commented 12 years ago

OK I'll check it out. Thanks! On Mar 24, 2012 1:06 AM, "suan" < reply@reply.github.com> wrote:

@panozzaj Your problem is a little different from mvanveen's since the invoking instant-markdown-d directly worked for him. It sounds like it might be a problem with the underlying renderer. Double check that the redcarpet and pygments.rb gems are installed.

After that, try going to <node installation>/node_modules/instant-markdown-d, then run echo "lala" | node_modules/docter/bin/github-flavored-markdown.rb. You should get output that looks like a lot of css followed by <p>lala</p>. If you don't, then something's up with either your gem dependencies instant-markdown-d's npm dependencies.


Reply to this email directly or view it on GitHub: https://github.com/suan/vim-instant-markdown/issues/1#issuecomment-4671678

panozzaj commented 12 years ago

OK, I tried installing those gems and everything works as expected! Thanks for the quick response.

fabiopelosin commented 12 years ago

Hi,

I have an issue similar to @mvanveen. The "lala", "abcdefg" and the curl tests worked for me as well. However, I see an empty window only when I open an existing file. I have no problems for new files. Though if I save it and reopen I still have the issue.

$ vim --version 
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb  2 2012 06:21:20)
MacOS X (unix) version
Included patches: 1-390
Compiled by fabio@Fabios-iMac.local
Huge version with MacVim GUI.  Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent 
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
+conceal +cryptv -cscope +cursorbind +cursorshape +dialog_con_gui +diff 
+digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi 
+file_in_path +find_in_path +float +folding -footer +fork() +fullscreen 
-gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap 
+libcall +linebreak +lispindent +listcmds +localmap -lua +menu +mksession 
+modify_fname +mouse +mouseshape +mouse_dec -mouse_gpm -mouse_jsbterm 
+mouse_netterm -mouse_sysmouse +mouse_xterm +mouse_urxvt +multi_byte 
+multi_lang -mzscheme +netbeans_intg +odbeditor +path_extra +perl 
+persistent_undo +postscript +printer +profile +python -python3 +quickfix 
+reltime +rightleft +ruby +scrollbind +signs +smartindent -sniff +startuptime 
+statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white 
+tcl +terminfo +termresponse +textobjects +title +toolbar +transparency 
+user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace 
+wildignore +wildmenu +windows +writebackup -X11 -xfontset +xim -xsmp 
-xterm_clipboard -xterm_save 
fabiopelosin commented 12 years ago

Hmmm... after testing the code wich removes the silent statements it appears to work, even with the normal version. Like if I would have forgotten restart vim (which I remember to have done). Anyway if I experience the issues again I'll report back.

Thanks for the plug in... it is very nice!

fabiopelosin commented 12 years ago

Unfortunately I still have the bug.

Often when I open a markdown file in vim a new tab in chrome is displayed with the empty page (no box).

$ echo "abcdefg" | curl -X PUT -T - http://localhost:8090/
curl: (7) couldn't connect to host
$ instant-markdown-d
   info  - socket.io started

A this point I can edit the file in vim and everything works perfectly.

So it looks like that in certain conditions the server is not launched. It appears less likely to happen with new files... but once it happens the bug is present for any file that I open.

suan commented 12 years ago

@irrationalfab Do you get the problem for every existing Markdown file? If that's not the case, maybe there's some formatting in those files the backend can't handle, or that they're too large. Maybe you could paste the content of those files here? (if they're not private)

Try creating a really simple file like echo "abc" > test1.md and see if that opens. Then you can try something like echo "# heading 1" and see if that renders.

To aid debugging, you could comment out the silent! exec... line in the OpenMarkdown() section of the plugin, start instant-markdown-d in another terminal window, and then open a file in Vim. That way you can (I hope) see the errors when anything goes wrong.

fabiopelosin commented 12 years ago

It works consistently calling :call OpenMarkdown() manually after opening the file. I guess this rules out any formatting issues (anyway I was testing with one word documents).

I'm not familiar with vim's plugin system, but it looks like it is related to the execution environment where the script is loaded. I added an echo to check the exec string and noticed that calling OpenMarkdown() manually there is a prompt were which aks to press enter to continue, while I only see the echo message briefly appear and be dismissed while opening the file (however, I don't know if it is an intended behavior of vim).

Could it be an interference with another script? I'm using YADR. I observed the issue with vim and MacVim.

fabiopelosin commented 12 years ago

If the file doesn't exit the echo from OpenMarkdown() persists and everything works, otherwise the echo disappears immediately and ps | grep "mark" doesn't show instant-markdown-d.

[EDIT] I had installed "nelstrom-vim-markdown-preview" and tried to remove it to see if it was the cause of the interference but it din't work.

suan commented 12 years ago

At first I thought that the BufWinEnter event was not being triggered, but after your later explanation that doesn't seem to be the case. Still, you might try placing something simple in place of the exec line to ensure that OpenMarkdown() is actually called in the case of opening an existing file.

Interference from another script could very well be the issue - I admit that instant-markdown is not very robustly written (it was something like a 2-day project, and I'm no Vimscript wizard myself). I would try moving all other plugins away and/or use an empty .vimrc and see if it works, especially considering the number of plugins present in YADR.

If that works (or not) we can troubleshoot further.

On Fri, Mar 30, 2012 at 12:38 PM, Fabio Pelosin < reply@reply.github.com

wrote:

It works consistently calling :call OpenMarkdown() manually after opening the file. I guess this rules out any formatting issues (anyway I was testing with one word documents).

I'm not familiar with vim's plugin system, but it looks like it is related to the execution environment where the script is loaded. I added an echo to check the exec string and noticed that calling OpenMarkdown() manually there is a prompt were which aks to press enter to continue, while I only see the echo message briefly appear and be dismissed while opening the file (however, I don't know if it is an intended behavior of vim).

Could it be an interference with another script? I'm using YADR. I observed the issue with vim and MacVim.


Reply to this email directly or view it on GitHub: https://github.com/suan/vim-instant-markdown/issues/1#issuecomment-4847429

xbot commented 12 years ago

Doesn't work under Archlinux 64bit.

Everything is the newest version, but when I start to edit a mkd file, a new tab is created in firefox only shows "Firefox can't establish a connection to the server at localhost:8090."

echo lala|instant-markdown-d only opens an empty tab.

fabiopelosin commented 12 years ago

I think that, OpenMarkdown() is always being called otherwise the empty page would not open.

I quickly hacked a dirty version that seems to solve this issue (I have no knowledge of vim internals). Basically it delays the call to instant-markdown-d.

function! UpdateMarkdown()
  if (b:im_needs_init)
    let b:im_needs_init = 0
    silent! exec "silent! !echo " . escape(shellescape(join(getbufline("%", 1, "$"), "\n")), "%!#") . " | instant-markdown-d &>/dev/null &"
  endif
  if (b:last_number_of_changes == "" || b:last_number_of_changes != b:changedtick)
    let b:last_number_of_changes = b:changedtick
    let current_buffer = join(getbufline("%", 1, "$"), "\n")
    silent! exec "silent! !echo " . escape(shellescape(current_buffer), "%!#") . " | curl -X PUT -T - http://localhost:8090/ &>/dev/null &"
  endif
endfunction
function! OpenMarkdown()
  let b:last_number_of_changes = ""
  let b:im_needs_init = 1
endfunction
function! CloseMarkdown()
  silent! exec "silent! !curl -s -X DELETE http://localhost:8090/ &>/dev/null &"
endfunction

autocmd CursorMoved,CursorMovedI,CursorHold,CursorHoldI *.{md,mkd,mkdn,mark*} silent call UpdateMarkdown()
autocmd BufWinLeave *.{md,mkd,mkdn,mark*} silent call CloseMarkdown()
autocmd BufWinEnter *.{md,mkd,mkdn,mark*} silent call OpenMarkdown()
suan commented 12 years ago

@xbot First, double check that the redcarpet and pygments.rb gems are installed. Also make sure that there isn't anything else listening on port 8090.

Then, kill all existing instant-markdown-d processes, and try the echo lala | instant-markdown-d command again.

If it still doesn't work, goto the npm directory where instant-markdown-d is installed, and do echo "lala" | node_modules/docter/bin/github-flavored-markdown.rb --unstyled. You should see the translated HTML printed out.

bytesource commented 12 years ago

When I type

$ echo lala | instant-markdown-d

a new browser window opens with lala as its content.

So that seems to work in fact.

suan commented 12 years ago

@bytesource Hmm could you try if this works? https://github.com/suan/vim-instant-markdown/issues/1#issuecomment-4490932

bytesource commented 12 years ago

echo "lala" | instant-markdown-d in one terminal window, followed by echo "abcdefg" | curl -X PUT -T - http://localhost:8090/ in another one does also work.

Besides, my problem seems to be a little bit different, as I also experience extreme unresponsiveness when editing a markdown file with the plugin installed.

nkoehring commented 12 years ago

Hi, I (at least thought to) had the same issue than discussed at the beginning. I found out following:

Opening a browser window doesn't works for me (Linux, xdg-utils installed, but no desktop environment and the like is in usage) but I can open localhost:8090 directly and it works.

...at least until I use code tags. I fiddled around a bit and this is my last discovery in the adventure:

%> echo '# foo
quote>
quote> ```javascript
quote> var foo = "bar"
quote> ```
quote>
quote> end of code ;)' | node_modules/docter/bin/github-flavored-markdown.rb
  File "<string>", line 1
    import sys; print sys.executable
                        ^
SyntaxError: invalid syntax
sh: - : Ungültige Option
Benutzung:      sh [Lange GNU Option] [Option] ...
                sh [Lange GNU Option] [Option] Script-Datei ...
Lange GNU Optionen:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --protected
        --rcfile
        --restricted
        --verbose
        --version
Shell-Optionen:
        -irsD oder -c Kommando          (Nur Aufruf)
        -abefhkmnptuvxBCHP oder Option -o
sh: - : Ungültige Option
Benutzung:      sh [Lange GNU Option] [Option] ...
                sh [Lange GNU Option] [Option] Script-Datei ...
Lange GNU Optionen:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --protected
        --rcfile
        --restricted
        --verbose
        --version
Shell-Optionen:
        -irsD oder -c Kommando          (Nur Aufruf)
        -abefhkmnptuvxBCHP oder Option -o
/usr/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/lib/ffi/library.rb:121:in `block in ffi_lib': Could not open library 'lib.so': lib.so: cannot open shared object file: No such file or directory (LoadError)
        from /usr/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/lib/ffi/library.rb:88:in `map'
        from /usr/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/lib/ffi/library.rb:88:in `ffi_lib'
        from /home/nk/.gem/ruby/1.9.1/gems/rubypython-0.5.3/lib/rubypython/python.rb:29:in `<module:Python>'
        from /home/nk/.gem/ruby/1.9.1/gems/rubypython-0.5.3/lib/rubypython/python.rb:21:in `<top (required)>'
        from /home/nk/.gem/ruby/1.9.1/gems/rubypython-0.5.3/lib/rubypython.rb:261:in `load'
        from /home/nk/.gem/ruby/1.9.1/gems/rubypython-0.5.3/lib/rubypython.rb:261:in `reload_library'
        from /home/nk/.gem/ruby/1.9.1/gems/rubypython-0.5.3/lib/rubypython.rb:104:in `start'
        from /home/nk/.gem/ruby/1.9.1/gems/pygments.rb-0.2.12/lib/pygments/ffi.rb:8:in `start'
        from /home/nk/.gem/ruby/1.9.1/gems/pygments.rb-0.2.12/lib/pygments/ffi.rb:82:in `highlight'
        from node_modules/docter/bin/github-flavored-markdown.rb:56:in `block_code'
        from node_modules/docter/bin/github-flavored-markdown.rb:73:in `render'
        from node_modules/docter/bin/github-flavored-markdown.rb:73:in `fromMarkdown'
        from node_modules/docter/bin/github-flavored-markdown.rb:77:in `<main>'

So I searched around and found the first issue at https://github.com/tmm1/pygments.rb/issues/10. Because I'm using arch there is python2 and python3 installed and pygments needs to use python2. So I "patched" the block_code method github-flavored-markdown.rb with the mentioned configure line to:

def block_code(code, language)
  RubyPython.configure :python_exe => 'python2'
  Pygments.highlight(code, :lexer => language, :options => {:encoding => 'utf-8'})
end

Now I just get the last part of the error:

/usr/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/lib/ffi/library.rb:121:in `block in ffi_lib': Could not open library 'lib.so': lib.so: cannot open shared object file: No such file or directory (LoadError)

So it seems to be an pygments.rb issue and thatswhy I commented on an already closed (but for me not fixed) issue tmm1/pygments.rb#7

losingkeys commented 12 years ago

I have this issue too (specifically 'Doesn't work under Archlinux 64bit'). node: v0.8.4 instant-markdown-d: v0.0.6 vim-instant-markdown: latest as of today (54421032cb7b21faf8be8e139f8d83c7fee16080) vim --version:

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jul 13 2012 05:23:34)
Included patches: 1-600
Compiled by ArchLinux
Big version without GUI.  Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent 
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs 
-dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path 
+find_in_path +float +folding -footer +fork() +gettext -hangul_input +iconv 
+insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent 
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape 
+mouse_dec +mouse_gpm -mouse_jsbterm +mouse_netterm -mouse_sysmouse 
+mouse_xterm +mouse_urxvt +multi_byte +multi_lang -mzscheme -netbeans_intg 
+path_extra +perl +persistent_undo +postscript +printer -profile -python 
-python3 +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent 
-sniff +startuptime +statusline -sun_workshop +syntax +tag_binary 
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
 -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo 
+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
 -xterm_clipboard -xterm_save 
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -I/usr/local/include  -march=x86-64 -mtune=generic -pipe -fstack-protector --param=ssp-buffer-size=4  -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim       -lm -lncurses  -lacl -lattr -lgpm -ldl    -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu -fstack-protector -L/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc

I reduced my vimrc to this:

source /home/josh/.vim/bundle/vim-instant-markdown/plugin/instant-markdown.vim

and I get the same result (firefox opens a new tab @ http://localhost:8090/ with nothing on it)

Note the echo 'lala' ... etc commands didn't get any output. Awesome plugin, looking forward to helping squash this bug!

weynhamz commented 12 years ago

The behaviour is strange, sometimes the content shows, sometimes not.

And I dumped the output of the command and found each time the content was not showed along with this error.

/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:81
        socket.emit('newContent', newHTML);
               ^
TypeError: Cannot call method 'emit' of undefined
    at ChildProcess.<anonymous> (/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:81:16)
    at ChildProcess.EventEmitter.emit (events.js:91:17)
    at Process._handle.onexit (child_process.js:674:10)
losingkeys commented 12 years ago

so socket isn't getting set on instant-markdown-d:91?

suan commented 12 years ago

Could be a race condition. @techlivezheng what OS, and version of node.js and socket.io are you using?

weynhamz commented 12 years ago

I am using a Arch Linux, node.js version 0.8.4, socket.io is 0.9.9, default web browser is Firefox 14.0.1 which does not support autoclosing by foreign script.

Sometimes I got the content shown, then exit the markdown file, the preview tab collapse(firefox can not auto close), the next time I open a mardown file, the content is always not shown, sometimes it is blank, sometimes it is connecting to the sever.

weynhamz commented 12 years ago

The time which content is not shown, the "connection established!" string is missing in the log, and then the "curl" is following, I think this cause the "call emit of undefined" issue, maybe add some check to make sure the server is set up before using curl fetch it?

suan commented 12 years ago

@techlivezheng Try adding the following line to your instant-markdown-d file and see if it fixes the Firefox blank tab issue. If it does, I'll commit and release the fix.

@@ -60,6 +60,7 @@

     case 'DELETE':
       socket.emit('die');
+      socket.disconnect();
       process.exit();
       break;
griffindy commented 12 years ago

@suan just wanted to say I'm having a similar problem to @techlivezheng above. I'm using node v0.9.1-pre, socket-io v0.9.10 on Mac OS X 10.7 and Chrome 22.0.1229.6. However, adding socket.disconnect(); doesn't seem to change anything. I do get errors when trying to install socket-io I think however, with this result:

> ws@0.4.21 install /usr/local/lib/node_modules/instant-markdown-d/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws                                     [2/475]
> node install.js

[ws v0.4.21] Attempting to compile blazing fast native extensions.
Setting srcdir to                        : /usr/local/lib/node_modules/instant-markdown-d/node_modules/socket.io/node_modules/redis/node_modules/hiredis 
Setting blddir to                        : /usr/local/lib/node_modules/instant-markdown-d/node_modules/socket.io/node_modules/redis/node_modules/hiredis/build 
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /usr/local 
'configure' finished successfully (0.050s)
Waf: Entering directory `/usr/local/lib/node_modules/instant-markdown-d/node_modules/socket.io/node_modules/redis/node_modules/hiredis/build'
[1/3] cxx: hiredis.cc -> build/Release/hiredis_1.o
[2/3] cxx: reader.cc -> build/Release/reader_1.o
gyp ERR! configure error 
gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
gyp ERR! stack     at install (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:68:16)
gyp ERR! stack     at Object.commands.forEach.self.commands.(anonymous function) [as install] (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/node-gyp.js:56:37)
gyp ERR! stack     at getNodeDir (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:147:20)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:87:9
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:534:7)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:91:17)
gyp ERR! stack     at maybeClose (child_process.js:634:16)
gyp ERR! stack     at Socket.ChildProcess.spawn.stdin (child_process.js:805:11)
gyp ERR! stack     at Socket.EventEmitter.emit (events.js:88:17)
gyp ERR! stack     at Socket._destroy.destroyed (net.js:364:10)
gyp ERR! System Darwin 11.4.2
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/instant-markdown-d/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
gyp ERR! node -v v0.9.1-pre
gyp ERR! node-gyp -v v0.6.1
gyp ERR! not ok 
[ws v0.4.21] Native code compile failed (but the module will still work):
[ws v0.4.21] The native extensions are faster, but not required.
[ws v0.4.21] On Windows, native extensions require Visual Studio and Python.
[ws v0.4.21] On Unix, native extensions require Python, make and a C++ compiler.
[ws v0.4.21] Start npm with --ws:verbose to show compilation output (if any).
[3/3] cxx_link: build/Release/hiredis_1.o build/Release/reader_1.o -> build/Release/hiredis.node
Waf: Leaving directory `/usr/local/lib/node_modules/instant-markdown-d/node_modules/socket.io/node_modules/redis/node_modules/hiredis/build'
'build' finished successfully (0.349s)

hopefully this helps

griffindy commented 12 years ago

alright, turns out my issue was that ws wouldn't install on my version of node, which was for whatever pre. installing node 0.8.7 fixed that. However, it seems that I still have to start the instant-markdown-d and then save my buffer in vim before anything will appear

weynhamz commented 12 years ago

@suan , still not lucky.

Here is a debug output which I continuously open and close the same markdown file but without a success, maybe this could help you find something.

info: socket.io started
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100  1929    0     0    0  1929      0   1842 --:--:--  0:00:01 --:--:-- 43840

/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82
        socket.emit('newContent', newHTML);
               ^
TypeError: Cannot call method 'emit' of undefined
    at ChildProcess.<anonymous> (/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82:16)
    at ChildProcess.EventEmitter.emit (events.js:91:17)
    at Process._handle.onexit (child_process.js:674:10)
info: socket.io started

/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:62
      socket.emit('die');
             ^
TypeError: Cannot call method 'emit' of undefined
    at Server.httpHandler (/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:62:14)
    at Manager.handleRequest (/home/techlive/.npm/node_modules/instant-markdown-d/node_modules/socket.io/lib/manager.js:564:28)
    at Server.<anonymous> (/home/techlive/.npm/node_modules/instant-markdown-d/node_modules/socket.io/lib/manager.js:118:10)
    at Server.EventEmitter.emit (events.js:115:20)
    at HTTPParser.parser.onIncoming (http.js:1793:12)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:111:23)
    at Socket.socket.ondata (http.js:1690:22)
    at TCP.onread (net.js:410:27)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:05 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:06 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:07 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:08 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:09 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:10 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:11 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:12 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:13 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:14 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:15 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:16 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:17 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:18 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:19 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:20 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:21 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:22 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:23 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:24 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:25 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:26 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:27 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:28 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:29 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:30 --:--:--     0
info: socket.io started
path.exists is now called `fs.exists`.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100  1929    0     0    0  1929      0   1839 --:--:--  0:00:01 --:--:-- 48225

/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82
        socket.emit('newContent', newHTML);
               ^
TypeError: Cannot call method 'emit' of undefined
    at ChildProcess.<anonymous> (/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82:16)
    at ChildProcess.EventEmitter.emit (events.js:91:17)
    at Process._handle.onexit (child_process.js:674:10)

  0     0    0     0    0     0      0      0 --:--:--  0:00:31 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:32 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:33 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:34 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:35 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:36 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:37 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:38 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:39 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:40 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:41 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:42 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:43 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:44 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:45 --:--:--     0
info: socket.io started
path.exists is now called `fs.exists`.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:46 --:--:--     0
100  1929    0     0    0  1929      0    961 --:--:--  0:00:02 --:--:--  1923
100  1929    0     0    0  1929      0    946 --:--:--  0:00:02 --:--:--  1863

/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:62
      socket.emit('die');
             ^
TypeError: Cannot call method 'emit' of undefined
    at Server.httpHandler (/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:62:14)
    at Manager.handleRequest (/home/techlive/.npm/node_modules/instant-markdown-d/node_modules/socket.io/lib/manager.js:564:28)
    at Server.<anonymous> (/home/techlive/.npm/node_modules/instant-markdown-d/node_modules/socket.io/lib/manager.js:118:10)
    at Server.EventEmitter.emit (events.js:115:20)
    at HTTPParser.parser.onIncoming (http.js:1793:12)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:111:23)
    at Socket.socket.ondata (http.js:1690:22)
    at TCP.onread (net.js:410:27)

  0     0    0     0    0     0      0      0 --:--:--  0:00:47 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:48 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:49 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:50 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:51 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:52 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:53 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:54 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:55 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:56 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:57 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:58 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:59 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:00 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:01 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:02 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:03 --:--:--     0
info: socket.io started

  0     0    0     0    0     0      0      0 --:--:--  0:01:04 --:--:--     0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100  1929    0     0    0  1929      0   1849 --:--:--  0:00:01 --:--:-- 47048

/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82
        socket.emit('newContent', newHTML);
               ^
TypeError: Cannot call method 'emit' of undefined
    at ChildProcess.<anonymous> (/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82:16)
    at ChildProcess.EventEmitter.emit (events.js:91:17)
    at Process._handle.onexit (child_process.js:674:10)

  0     0    0     0    0     0      0      0 --:--:--  0:01:05 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:06 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:07 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:08 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:09 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:10 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:11 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:12 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:13 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:14 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:15 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:16 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:17 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:18 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:19 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:20 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:21 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:22 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:23 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:24 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:25 --:--:--     0
info: socket.io started

  0     0    0     0    0     0      0      0 --:--:--  0:01:26 --:--:--     0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100  1929    0     0    0  1929      0   1847 --:--:--  0:00:01 --:--:-- 45928

/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82
        socket.emit('newContent', newHTML);
               ^
TypeError: Cannot call method 'emit' of undefined
    at ChildProcess.<anonymous> (/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82:16)
    at ChildProcess.EventEmitter.emit (events.js:91:17)
    at Process._handle.onexit (child_process.js:674:10)

  0     0    0     0    0     0      0      0 --:--:--  0:01:27 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:28 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:29 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:30 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:31 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:32 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:33 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:34 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:35 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:36 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:37 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:38 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:39 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:40 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:41 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:42 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:43 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:44 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:45 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:46 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:47 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:48 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:49 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:50 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:51 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:52 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:53 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:54 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:55 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:56 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:57 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:58 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:01:59 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:02:00 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:02:01 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:02:02 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:02:03 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:02:04 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:02:05 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:02:06 --:--:--     0
curl: (7) couldn't connect to host
info: socket.io started
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100  1929    0     0    0  1929      0   1829 --:--:--  0:00:01 --:--:-- 42866

/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82
        socket.emit('newContent', newHTML);
               ^
TypeError: Cannot call method 'emit' of undefined
    at ChildProcess.<anonymous> (/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82:16)
    at ChildProcess.EventEmitter.emit (events.js:91:17)
    at Process._handle.onexit (child_process.js:674:10)
info: socket.io started
path.exists is now called `fs.exists`.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100  1929    0     0    0  1929      0   1839 --:--:--  0:00:01 --:--:-- 47048

/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82
        socket.emit('newContent', newHTML);
               ^
TypeError: Cannot call method 'emit' of undefined
    at ChildProcess.<anonymous> (/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82:16)
    at ChildProcess.EventEmitter.emit (events.js:91:17)
    at Process._handle.onexit (child_process.js:674:10)
info: socket.io started
path.exists is now called `fs.exists`.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:62
      socket.emit('die');
             ^
TypeError: Cannot call method 'emit' of undefined
    at Server.httpHandler (/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:62:14)
    at Manager.handleRequest (/home/techlive/.npm/node_modules/instant-markdown-d/node_modules/socket.io/lib/manager.js:564:28)
    at Server.<anonymous> (/home/techlive/.npm/node_modules/instant-markdown-d/node_modules/socket.io/lib/manager.js:118:10)
    at Server.EventEmitter.emit (events.js:115:20)
    at HTTPParser.parser.onIncoming (http.js:1793:12)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:111:23)
    at Socket.socket.ondata (http.js:1690:22)
    at TCP.onread (net.js:410:27)

  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
curl: (56) Recv failure: Connection reset by peer
info: socket.io started
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100  1929    0     0    0  1929      0   1834 --:--:--  0:00:01 --:--:-- 43840

/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82
        socket.emit('newContent', newHTML);
               ^
TypeError: Cannot call method 'emit' of undefined
    at ChildProcess.<anonymous> (/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82:16)
    at ChildProcess.EventEmitter.emit (events.js:91:17)
    at Process._handle.onexit (child_process.js:674:10)
info: socket.io started
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100  1929    0     0    0  1929      0   1841 --:--:--  0:00:01 --:--:-- 47048

/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82
        socket.emit('newContent', newHTML);
               ^
TypeError: Cannot call method 'emit' of undefined
    at ChildProcess.<anonymous> (/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82:16)
    at ChildProcess.EventEmitter.emit (events.js:91:17)
    at Process._handle.onexit (child_process.js:674:10)
info: socket.io started
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100  1929    0     0    0  1929      0   1832 --:--:--  0:00:01 --:--:-- 47048

/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82
        socket.emit('newContent', newHTML);
               ^
TypeError: Cannot call method 'emit' of undefined
    at ChildProcess.<anonymous> (/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:82:16)
    at ChildProcess.EventEmitter.emit (events.js:91:17)
    at Process._handle.onexit (child_process.js:674:10)

instant-markdown-d with line socket.disconnect(); patched.

weynhamz commented 12 years ago

Switching the default browser to chrome does not change anything.

I suspect the problem might be lay in the stage of passing the buffer to the instant-markdown-d and getting it converted to html, somehow, this process has not been finished when the second "curl -X PUT" call arrived.

weynhamz commented 12 years ago

Here is a debug output about several failure after several success.

info: socket.io started
path.exists is now called `fs.exists`.
connection established!connection established!info: socket.io started
path.exists is now called `fs.exists`.
connection established!info: socket.io started
path.exists is now called `fs.exists`.

/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:62
      socket.emit('die');
             ^
TypeError: Cannot call method 'emit' of undefined
    at Server.httpHandler (/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:62:14)
    at Manager.handleRequest (/home/techlive/.npm/node_modules/instant-markdown-d/node_modules/socket.io/lib/manager.js:564:28)
    at Server.<anonymous> (/home/techlive/.npm/node_modules/instant-markdown-d/node_modules/socket.io/lib/manager.js:118:10)
    at Server.EventEmitter.emit (events.js:115:20)
    at HTTPParser.parser.onIncoming (http.js:1793:12)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:111:23)
    at Socket.socket.ondata (http.js:1690:22)
    at TCP.onread (net.js:410:27)
info: socket.io started

/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:62
      socket.emit('die');
             ^
TypeError: Cannot call method 'emit' of undefined
    at Server.httpHandler (/home/techlive/.npm/node_modules/instant-markdown-d/instant-markdown-d:62:14)
    at Manager.handleRequest (/home/techlive/.npm/node_modules/instant-markdown-d/node_modules/socket.io/lib/manager.js:564:28)
    at Server.<anonymous> (/home/techlive/.npm/node_modules/instant-markdown-d/node_modules/socket.io/lib/manager.js:118:10)
    at Server.EventEmitter.emit (events.js:115:20)
    at HTTPParser.parser.onIncoming (http.js:1793:12)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:111:23)
    at Socket.socket.ondata (http.js:1690:22)
    at TCP.onread (net.js:410:27)

It is totally random.

suan commented 12 years ago

@techlivezheng, @joshuarh, @griffindy: Try making this change in your instant-markdown.vim file This should fix the socket undefined issue:

@@ -2,8 +2,7 @@
   if (b:im_needs_init)
     let b:im_needs_init = 0
     silent! exec "silent! !echo " . escape(shellescape(join(getbufline("%", 1, "$"), "\n")), "%!#") . " | instant-markdown-d &>/dev/null &"
-  endif
-  if (b:last_number_of_changes == "" || b:last_number_of_changes != b:changedtick)
+  elseif (b:last_number_of_changes == "" || b:last_number_of_changes != b:changedtick)
     let b:last_number_of_changes = b:changedtick
     let current_buffer = join(getbufline("%", 1, "$"), "\n")
     silent! exec "silent! !echo " . escape(shellescape(current_buffer), "%!#") . " | curl -X PUT -T - http://localhost:8090/ &>/dev/null &"
weynhamz commented 12 years ago

@suan, yes, it did solve the soket problem and the rendered content displays most of time, but I still sometimes got a blank content. If I open and close the same markdwon file several times, the later times will not work.

info: socket.io started
path.exists is now called `fs.exists`.
connection established!
info: socket.io started
warn: error raised: Error: listen EADDRINUSE
connection established!
info: socket.io started
warn: error raised: Error: listen EADDRINUSE
connection established!

I got several ruby converting processing running as below.

techlive 20550     1  0 10:09 pts/1    00:00:01 node /home/techlive/.npm/node_modules/.bin/instant-markdown-d
techlive 21036 20550  0 10:10 pts/1    00:00:00 ruby /home/techlive/.npm/node_modules/instant-markdown-d/node_modules/docter/bin/github-flavored-markdown.rb --unstyled
techlive 21120 20550  0 10:11 pts/1    00:00:00 ruby /home/techlive/.npm/node_modules/instant-markdown-d/node_modules/docter/bin/github-flavored-markdown.rb --unstyled
techlive 21227 20550  0 10:11 pts/1    00:00:00 ruby /home/techlive/.npm/node_modules/instant-markdown-d/node_modules/docter/bin/github-flavored-markdown.rb --unstyled
techlive 22884 20550  0 10:18 pts/1    00:00:00 ruby /home/techlive/.npm/node_modules/instant-markdown-d/node_modules/docter/bin/github-flavored-markdown.rb --unstyled
techlive 23121 20221  0 10:18 pts/1    00:00:00 grep --color=auto markdown