Skip to content
This repository was archived by the owner on Jun 7, 2018. It is now read-only.
This repository was archived by the owner on Jun 7, 2018. It is now read-only.

RSTPreview doesn't open the preview in user's default browser #17

@Joshua-Snapp

Description

@Joshua-Snapp

This is not a significant issue, but I thought I'd mention it since it isn't especially hard to fix.

In RstPreview.py you call the webbrowser.open in the following way.

from webbrowser import open as open_in_browser

I'm not sure why this method is chosen, but apparently there's an issue with the way the webbrowser function works where it doesn't always identify the user's default browser. It also apparently doesn't even "know" about the google-chrome browser.

ref. Calling Chrome web browser from the webbrowser.get() in Python

The way you're calling webbrowser.open isn't causing the problem, but I think it gets in the way of implementing a solution easily. Why not just import the whole function? That way people can use it in the following way.

Solution:
Use import webbrowser in RstPreview.py in order to be able to call the webbrowser.get().open() function.

Then replace

open_in_browser('http://127.0.0.1:%s' % server.server_port)

with

# open_in_browser('http://127.0.0.1:%s' % server.server_port) webbrowser.get().open('http://127.0.0.1:%s' % server.server_port)

This way a user can simply specify the browser they want to use.

e.g.
Google-Chrome
# open_in_browser('http://127.0.0.1:%s' % server.server_port) webbrowser.get('google-chrome %s').open('http://127.0.0.1:%s' % server.server_port)

Firefox
# open_in_browser('http://127.0.0.1:%s' % server.server_port) webbrowser.get('firefox %s').open('http://127.0.0.1:%s' % server.server_port)

A comment in the RstPreview.py file and/or the README.rst would be helpful to point people to this option. I think that could improve the user experience.

Thanks for your work! I appreciate being able to preview RST stuff.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions