Skip to content

Commit

Permalink
Merge pull request #21 from facelessuser/restrict-livereload
Browse files Browse the repository at this point in the history
Restrict live reload on github if no oauth
  • Loading branch information
facelessuser authored Jun 17, 2018
2 parents 53bd194 + 49d76ec commit f843fc5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions .dictionary
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ MathJax
MathJax's
MultiMarkdown
NONINFRINGEMENT
OAuth
OSs
Parsers
PyMdown
Expand Down
1 change: 1 addition & 0 deletions docs/src/markdown/_snippets/refs.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
[pymdownx]: http://facelessuser.github.io/pymdown-extensions/
[sequence]: https://bramp.github.io/js-sequence-diagrams/
[settings]: https://github.com/facelessuser/MarkdownPreview/blob/master/MarkdownPreview.sublime-settings
[superfences]: https://facelessuser.github.io/pymdown-extensions/extensions/superfences/
[toc]: https://pythonhosted.org/Markdown/extensions/toc.html#usage
4 changes: 4 additions & 0 deletions docs/src/markdown/changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## 2.1.2

- Don't allow live reload on save if using GitHub parser with no OAuth.

## 2.1.1

- Revert `autoNumber` set to `all` in MathJax config.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/markdown/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ To get live updates while editing a file after preview, you need to do the follo
*/
"enable_autoreload": true,
```
2. Install [LiveReload][7] package from Package Control.
2. Install [LiveReload][live-reload] package from Package Control.
3. Restart.
4. Open the command palette and select the command `LiveReload: Enable/disable plug-ins`.
5. Select `Simple Reload with delay (400ms)`. It is possible you can get away with `Simple Reload`, but some experience an issue where they are one rev behind when using `Simple Reload`.
Expand Down
6 changes: 4 additions & 2 deletions markdown_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ class MarkdownPreviewListener(sublime_plugin.EventListener):
def on_post_save(self, view):
"""Handle auto-reload on save."""
settings = sublime.load_settings('MarkdownPreview.sublime-settings')
if settings.get('enable_autoreload', True):
github_auth_provided = settings.get('github_oauth_token') is not None
parser = view.settings().get('parser')
if settings.get('enable_autoreload', True) and (parser != 'github' or github_auth_provided):
filetypes = settings.get('markdown_filetypes')
file_name = view.file_name()
if filetypes and file_name is not None and file_name.endswith(tuple(filetypes)):
Expand All @@ -176,7 +178,7 @@ def on_post_save(self, view):
# todo : check if browser still opened and reopen it if needed
view.run_command('markdown_preview', {
'target': 'disk',
'parser': view.settings().get('parser')
'parser': parser
})
sublime.status_message('Markdown preview file updated')

Expand Down

0 comments on commit f843fc5

Please sign in to comment.