instant-markdown / vim-instant-markdown

Instant Markdown previews from Vim
https://instant-markdown.github.io
Other
2.73k stars 253 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.

losingkeys commented 12 years ago

Odd, I still am getting no content. What I've tried:

Version info for my installed instant-markdown-d from npm:

├─┬ instant-markdown-d@0.0.6
│ ├── docter@0.0.1
│ └─┬ socket.io@0.9.10
│   ├── policyfile@0.0.4
│   ├─┬ redis@0.7.2
│   │ └── hiredis@0.1.14
│   └─┬ socket.io-client@0.9.10
│     ├─┬ active-x-obfuscator@0.0.1
│     │ └── zeparser@0.0.5
│     ├── uglify-js@1.2.5
│     ├─┬ ws@0.4.21
│     │ ├── commander@0.6.1
│     │ ├── options@0.0.3
│     │ └── tinycolor@0.0.1
│     └── xmlhttprequest@1.4.2

Thanks for the patch! Anything else I should try/more info you might need? I really need to learn vimscript so I can help with these things...

suan commented 12 years ago

@techlivezheng I'm curious, what markdown file are you using to test this? Would you mind linking to it or pasting it here? Also, how quickly are you opening and closing the file when you see the problem? After my last suggestion is it stable enough for everyday use for you?

As for the many Ruby processes there's currently nothing you can do about that right now as I don't have any kind of rate limiting logic on the server. For the Address in use problem, see if this makes it better:

@@ -60,6 +60,8 @@

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

@joshuarh So did the very last command I listed here not even work for you? If that's the case, then something is wrong with your Rubygems/redcarpet/pygments.rb...

From within where instant-markdown-d is installed, open node_modules/docter/bin/github-flavored-markdown.rb and see whether this line exists:

    if UNSTYLED 
weynhamz commented 12 years ago

@suan It is now stable enough for me to use, thank you.

I think I might found the cause of the problem I reported before that after a successful displaying and then reopening, a new tab page popup trying to connecting to the server all the time while the old tab page is still there. This is because firefox does not support the closing by foreign script and I have changed dom.allow_scripts_to_close_windows to true.

This is how it displays when colsing the file and having dom.allow_scripts_to_close_windows set to false. At this time, all works fine except that if you keep close and then open a file, the tab page will keep growing.

Oops!
Firefox doesn't allow windows to self-close.
If you want the preview window to close automatically like in other browsers, go to about:config and set dom.allow_scripts_to_close_windows to true.

If dom.allow_scripts_to_close_windows is set to true, then the problem I discribed at the begining will occur, the old tab page do not collapse, and the new tab page is keep connecting.

In chrome, all works as expected.

weynhamz commented 12 years ago

@joshuarh I am a Arch Linux user, there are two things need to be done first in order to get pygments.rb working.

First, default python version on Arch Linux is 3.x, but rubypython-0.5.3 assume the python to be 2.x, so instant-markdown-d/node_modules/docter/bin/github-flavored-markdown.rb need to be patched.

@@ -19,6 +19,10 @@
 require 'pathname'
 require 'pygments.rb'

+if !!RUBY_PLATFORM['linux']
+    RubyPython.configure :python_exe => '/usr/bin/python2.7'
+end
+
 class HTMLwithPygments < Redcarpet::Render::XHTML
    def doc_header()
     ghf_css_path = File.join File.dirname(File.dirname Pathname.new(__FILE__).realpath),

Second, rubypython-0.5.3 could not find the proper location of python library, so gems/rubypython-0.5.3/lib/rubypython/pythonexec.rb should be patched.

-- 31 @library = find_python_lib
++ 31 @library = "/usr/lib/libpython2.7.so"

-- 126 %x(#{@python} -c "#{command}").chomp if @python
++ 126 %x("#{@python} -c #{command}").chomp if @python 

Hope these could help you, rubypython-0.6 should have fixed all these, but pygments is still depending on 0.5.3 though.

Related Posts: http://blog.gonzih.org/blog/2011/09/21/fix-octopress-pygments-error-on-arch-linux/

losingkeys commented 12 years ago

@suan I've installed it globally (npm install -g), but can't seem to find it. npm ls and npm ls -g both report (empty) from different directories. @techlivezheng I'll let you know when I get a chance to test this (when I find the .rb file).

suan commented 12 years ago

@joshuarh Are your node_modules in your PATH? For example in my .bashrc I have this:

if [ -d /usr/local/lib/node ]; then
  export NODE_PATH="/usr/local/lib/node"
fi

Otherwise, that is very strange, were you running npm ls -g right after you installed instant-markdown-d? If so, try doing a grep through your system for instant-markdown (not sure where the node_modules path is for Arch Linux)

If not, then perhaps your node/npm version has changed since you installed the package. Perhaps you've been playing with nvm or something? Try reinstalling the package and looking for it again.

losingkeys commented 12 years ago

@suan: now I seem to have it, not sure what was going on this morning. @techlivezheng: So I've patched github-flavored-markdown.rb, but don't seem to have a rubypython gem installed. Below are the gems that show up when I type gem list. Am I doing something wrong?

actionmailer (3.2.8, 3.2.7)
actionpack (3.2.8, 3.2.7)
activemodel (3.2.8, 3.2.7)
activerecord (3.2.8, 3.2.7)
activeresource (3.2.8, 3.2.7)
activesupport (3.2.8, 3.2.7)
arel (3.0.2)
bigdecimal (1.1.0)
boom (0.2.3)
builder (3.0.0)
bundler (1.1.5)
erubis (2.7.0)
hike (1.2.1)
hub (1.10.2)
i18n (0.6.0)
io-console (0.3)
journey (1.0.4)
json (1.7.5, 1.5.4)
json_pure (1.7.5, 1.5.4)
lolcat (42.0.99)
mail (2.4.4)
mime-types (1.19)
minitest (3.3.0, 2.5.1)
multi_json (1.3.6, 1.0.4)
paint (0.8.5)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.8, 3.2.7)
railties (3.2.8, 3.2.7)
rake (0.9.2.2)
rdoc (3.12, 3.9.4)
rubygems-update (1.8.24)
sprockets (2.4.5, 2.1.3)
spruz (0.2.13)
thor (0.16.0, 0.15.4)
tilt (1.3.3)
tmuxinator (0.5.0)
treetop (1.4.10)
trollop (2.0, 1.16.2)
tzinfo (0.3.33)
suan commented 12 years ago

@joshuarh Looks like you don't have the redcarpet and pygments.rb gems installed. Install those 2 and you should see rubypython get installed as a dependency.

losingkeys commented 12 years ago

@suan nice! It works now. Sorry I missed that (it's even in the README >.<); Thanks again!

suan commented 12 years ago

I am closing this since this comment thread has become too long to be useful. I'm actively working on a Ruby version of the backend which will remove the dependency on node.js, improve stability, and hopefully fix these no-display issues.

Here's a summary of solutions that have worked for others:

Please open a new issue if none of the suggestions in this thread solve your problem.

vsushkov commented 12 years ago

Here's a quick solution for this issue:

  1. Remove this plugin
  2. Add the following line to your .vimrc:

    autocmd BufWritePost *.md,*.markdown :silent !cat %:p | curl -X PUT -T - http://localhost:8090/
  3. Run instant-markdown-d > /dev/null 2>&1 &

Browser's content will update automatically every time you save a markdown file.

ffjia commented 11 years ago

I still encounter this problem. But use vsushkov's solution, I do see the content in my browser, any hints? Thanks.

suan commented 11 years ago

@ffjia Have you upgraded to the latest vim plugin? After the time of @vsushkov's comment there have been major changes. And there is a feature where you can do let g:instant_markdown_slow = 1 to only update the preview upon saving. Try that if the default behavior is not working for you...

ffjia commented 11 years ago

@suan I've already installed the latest version, v0.0.5. And did try to add "let g:instant_markdown_slow = 1" in my vimrc, it just not worked. I have no idea why.

Mac OS X 10.8.2 MacVim-snapshot-65.tbz

suan commented 11 years ago

@ffjia Do you see an instant-markdown-d process being started at all when you open a markdown file? Also, I know it's a pain, but I know someone who got it working after disabling all his other vim plugins. We tried to narrow down to which plugins were the culprit, but never got to the bottom of it. Maybe see if that works for you.

Also keep this in mind - if you don't have an actual markdown plugin installed the only .md files that will be recognized are README.md

ffjia commented 11 years ago

@suan I can see instant-markdown-d running, and I do have the markdown plugin installed.

The list below are what I installed: ['The_NERD_tree', 'confluencewiki', 'instant-markdown', 'Command-T', 'Powerline', 'fugitive', 'Solarized', 'ack', 'rails', 'Syntastic', 'vim-puppet', 'Tabular', 'DrawIt', 'markdown@tpope']

suan commented 11 years ago

@ffjia Please join us here to consolidate the discussion as I believe you guys have the same issue.