math2001 / MarkdownLivePreview

A Sublime Text 3 plugin to preview your markdown as you type
https://math2001.github.io/MarkdownLivePreview
MIT License
304 stars 37 forks source link

Error when color scheme not selected #69

Closed mbreese closed 4 years ago

mbreese commented 6 years ago

If there is no color scheme already selected in Sublime, the plugin doesn't work. In the console, the below error is thrown.

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 577, in on_modified_async
    callback.on_modified_async(v)
  File "/Users/mbreese/Library/Application Support/Sublime Text 3/Installed Packages/MarkdownLivePreview.sublime-package/MarkdownLivePreview.py", line 72, in on_modified_async
    self.update(view)
  File "/Users/mbreese/Library/Application Support/Sublime Text 3/Installed Packages/MarkdownLivePreview.sublime-package/MarkdownLivePreview.py", line 64, in update
    show_html(view, preview)
  File "/Users/mbreese/Library/Application Support/Sublime Text 3/Installed Packages/MarkdownLivePreview.sublime-package/MLPApi.py", line 76, in show_html
    html = markdown2html(get_view_content(md_view), os.path.dirname(md_view.file_name()), md_view.settings().get('color_scheme'))
  File "/Users/mbreese/Library/Application Support/Sublime Text 3/Installed Packages/MarkdownLivePreview.sublime-package/MLPApi.py", line 40, in markdown2html
    html = '<style>\n{}\n</style>\n'.format(get_style(color_scheme))
  File "/Users/mbreese/Library/Application Support/Sublime Text 3/Installed Packages/MarkdownLivePreview.sublime-package/functions.py", line 131, in get_style
    css += pygments_from_theme(get_resource(color_scheme))
  File "/Users/mbreese/Library/Application Support/Sublime Text 3/Installed Packages/MarkdownLivePreview.sublime-package/functions.py", line 139, in get_resource
    return sublime.load_resource(resource)
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime.py", line 192, in load_resource
    raise IOError("resource not found")
OSError: resource not found

Once a color scheme is selected, things work as expected.

I'm assuming that a default should be used if the user hasn't selected a color scheme, but I don't know where it should be set.

gelldur commented 6 years ago

Traceback (most recent call last):
  File "/home/gelldur/.config/sublime-text-3/Installed Packages/MarkdownLivePreview.sublime-package/MarkdownLivePreview.py", line 74, in <lambda>
  File "/home/gelldur/.config/sublime-text-3/Installed Packages/MarkdownLivePreview.sublime-package/MarkdownLivePreview.py", line 64, in update
  File "/home/gelldur/.config/sublime-text-3/Installed Packages/MarkdownLivePreview.sublime-package/MLPApi.py", line 76, in show_html
  File "/home/gelldur/.config/sublime-text-3/Installed Packages/MarkdownLivePreview.sublime-package/MLPApi.py", line 40, in markdown2html
  File "/home/gelldur/.config/sublime-text-3/Installed Packages/MarkdownLivePreview.sublime-package/functions.py", line 131, in get_style
  File "/home/gelldur/.config/sublime-text-3/Installed Packages/MarkdownLivePreview.sublime-package/functions.py", line 139, in get_resource
  File "/opt/sublime_text_3/sublime.py", line 192, in load_resource
    raise IOError("resource not found")
OSError: resource not found```

Same here after fresh install
davidbitton commented 5 years ago

I have the same issue. Once I had a color_scheme in my user settings, it worked.

math2001 commented 4 years ago

This issue is no longer relevant to the new version, so I'm going to close this issue.