import sublime
import os.path as fs

if int(sublime.version()) < 3000:
    from elm_project import ElmProject
    from ViewInBrowserCommand import ViewInBrowserCommand
else:
    from .elm_project import ElmProject
    ViewInBrowserCommand = __import__('View In Browser').ViewInBrowserCommand.ViewInBrowserCommand

class ElmOpenInBrowserCommand(ViewInBrowserCommand):

    def run(self, edit):
        super(ElmOpenInBrowserCommand, self).run(edit)

    def is_enabled(self):
        self.project = ElmProject(self.view.file_name())
        return self.project.exists

    def normalizePath(self, fileToOpen): # ViewInBrowserCommand
        norm_path = fs.join(self.project.working_dir, fs.expanduser(self.project.html_path))
        return super(ElmOpenInBrowserCommand, self).normalizePath(fs.abspath(norm_path))

import sublime
import os.path as fs

if int(sublime.version()) < 3000:
    from elm_project import ElmProject
    from ViewInBrowserCommand import ViewInBrowserCommand as OpenInBrowserCommand
else:
    from .elm_project import ElmProject
    try:
        from SideBarEnhancements.SideBar import SideBarOpenInBrowserCommand as OpenInBrowserCommand
    except:
        OpenInBrowserCommand = __import__('View In Browser').ViewInBrowserCommand.ViewInBrowserCommand

class ElmOpenInBrowserCommand(OpenInBrowserCommand):

    def run(self, edit=None):
        if edit: # ViewInBrowserCommand
            super(ElmOpenInBrowserCommand, self).run(edit)
        else: # SideBarOpenInBrowserCommand
            super(ElmOpenInBrowserCommand, self).run([self.html_path()])

    def is_enabled(self):
        try: # ViewInBrowserCommand
            self.project = ElmProject(self.view.file_name())
        except: # SideBarOpenInBrowserCommand
            self.project = ElmProject(self.window.active_view().file_name())
        return self.project.exists

    def normalizePath(self, fileToOpen): # ViewInBrowserCommand
        return super(ElmOpenInBrowserCommand, self).normalizePath(self.html_path())

    def html_path(self):
        norm_path = fs.join(self.project.working_dir, fs.expanduser(self.project.html_path))
        return fs.abspath(norm_path)

Add alternative support for open in browser
Add alternative support for open in browser

Integrate SideBarEnhancements for ST3 for poplarity and browser detection

  import sublime
  import os.path as fs
  
  if int(sublime.version()) < 3000:
      from elm_project import ElmProject
-     from ViewInBrowserCommand import ViewInBrowserCommand
+     from ViewInBrowserCommand import ViewInBrowserCommand as OpenInBrowserCommand
  else:
      from .elm_project import ElmProject
+     try:
+         from SideBarEnhancements.SideBar import SideBarOpenInBrowserCommand as OpenInBrowserCommand
+     except:
-     ViewInBrowserCommand = __import__('View In Browser').ViewInBrowserCommand.ViewInBrowserCommand
+         OpenInBrowserCommand = __import__('View In Browser').ViewInBrowserCommand.ViewInBrowserCommand
  
- class ElmOpenInBrowserCommand(ViewInBrowserCommand):
+ class ElmOpenInBrowserCommand(OpenInBrowserCommand):
  
-     def run(self, edit):
+     def run(self, edit=None):
+         if edit: # ViewInBrowserCommand
-         super(ElmOpenInBrowserCommand, self).run(edit)
+             super(ElmOpenInBrowserCommand, self).run(edit)
+         else: # SideBarOpenInBrowserCommand
+             super(ElmOpenInBrowserCommand, self).run([self.html_path()])
  
      def is_enabled(self):
+         try: # ViewInBrowserCommand
-         self.project = ElmProject(self.view.file_name())
+             self.project = ElmProject(self.view.file_name())
+         except: # SideBarOpenInBrowserCommand
+             self.project = ElmProject(self.window.active_view().file_name())
          return self.project.exists
  
      def normalizePath(self, fileToOpen): # ViewInBrowserCommand
+         return super(ElmOpenInBrowserCommand, self).normalizePath(self.html_path())
+ 
+     def html_path(self):
          norm_path = fs.join(self.project.working_dir, fs.expanduser(self.project.html_path))
-         return super(ElmOpenInBrowserCommand, self).normalizePath(fs.abspath(norm_path))
+         return fs.abspath(norm_path)
  
Add alternative support for open in browser
## Code Before:
import sublime
import os.path as fs

if int(sublime.version()) < 3000:
    from elm_project import ElmProject
    from ViewInBrowserCommand import ViewInBrowserCommand
else:
    from .elm_project import ElmProject
    ViewInBrowserCommand = __import__('View In Browser').ViewInBrowserCommand.ViewInBrowserCommand

class ElmOpenInBrowserCommand(ViewInBrowserCommand):

    def run(self, edit):
        super(ElmOpenInBrowserCommand, self).run(edit)

    def is_enabled(self):
        self.project = ElmProject(self.view.file_name())
        return self.project.exists

    def normalizePath(self, fileToOpen): # ViewInBrowserCommand
        norm_path = fs.join(self.project.working_dir, fs.expanduser(self.project.html_path))
        return super(ElmOpenInBrowserCommand, self).normalizePath(fs.abspath(norm_path))

## Instruction:
Add alternative support for open in browser
## Code After:
import sublime
import os.path as fs

if int(sublime.version()) < 3000:
    from elm_project import ElmProject
    from ViewInBrowserCommand import ViewInBrowserCommand as OpenInBrowserCommand
else:
    from .elm_project import ElmProject
    try:
        from SideBarEnhancements.SideBar import SideBarOpenInBrowserCommand as OpenInBrowserCommand
    except:
        OpenInBrowserCommand = __import__('View In Browser').ViewInBrowserCommand.ViewInBrowserCommand

class ElmOpenInBrowserCommand(OpenInBrowserCommand):

    def run(self, edit=None):
        if edit: # ViewInBrowserCommand
            super(ElmOpenInBrowserCommand, self).run(edit)
        else: # SideBarOpenInBrowserCommand
            super(ElmOpenInBrowserCommand, self).run([self.html_path()])

    def is_enabled(self):
        try: # ViewInBrowserCommand
            self.project = ElmProject(self.view.file_name())
        except: # SideBarOpenInBrowserCommand
            self.project = ElmProject(self.window.active_view().file_name())
        return self.project.exists

    def normalizePath(self, fileToOpen): # ViewInBrowserCommand
        return super(ElmOpenInBrowserCommand, self).normalizePath(self.html_path())

    def html_path(self):
        norm_path = fs.join(self.project.working_dir, fs.expanduser(self.project.html_path))
        return fs.abspath(norm_path)
