urlopen error [Errno 111] Connection refused
When I press "ctrl+shift+g", error occurs as bellow:

Could you provide Sublime logs?
Potentially related:
- https://github.com/dotcypress/GitHubMarkdownPreview/issues/32
- https://github.com/dotcypress/GitHubMarkdownPreview/issues/33
The error I hit is while editing a document, that hasn't been saved to a file, and thus also isn't going to be part of a GitHub repo:
Error in GitHubMarkdownPreview package: 'NoneType' object has no attribute 'rfind'Using Sublime Text (build 4143) on macOS Ventura
For what's it's worth, I'm pretty sure the problem is that the package assumes the markdown file exists in a git repo.
Exploring how this addon works, for my own benefit, but also to help others figure out where there errors may be occuring/why..
The command is defined here, and calls the
github_markdown_previewfunction in the code: https://github.com/dotcypress/GitHubMarkdownPreview/blob/bafa0df006d05750f06614049953cd78b54e93c3/Default.sublime-commands#L3-L4
github_markdown_preview_command:
- tries to get the
repoNamewithrepoName = get_github_repo_name(self.view.file_name())- which is later used to generate the
htmlof the preview withhtml = generate_preview(self.view.substr(selection), repoName)- this
htmlis then written to a temporary file (temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.html')), and opened in the web browser (webbrowser.open("file://" + temp_file.name))https://github.com/dotcypress/GitHubMarkdownPreview/blob/bafa0df006d05750f06614049953cd78b54e93c3/GHMarkdownPreview.py#L64-L82
get_github_repo_namewill returnNoneif the filename isNone; otherwise it will callgitto try and parse the repo name from thegit remote, when it's using HTTPS (not SSH):https://github.com/dotcypress/GitHubMarkdownPreview/blob/bafa0df006d05750f06614049953cd78b54e93c3/GHMarkdownPreview.py#L36-L49
generate_preview:
- calls the
https://api.github.com/markdownAPI (either withurllib2, orcurlwhen on linux (because"The python package included with sublime text for Linux is missing the ssl module (for technical reasons)")
- it puts the git
repo_namein thecontextfield of the jsonbodysent to the/markdownAPI
The repository context to use when creating references in
gfmmode. For example, setting context toocto-org/octo-repowill change the text#42into an HTML link to issue42in theocto-org/octo-reporepository.- returns the response, which appears to be a string containing the HTML from rendering the provided markdown
https://github.com/dotcypress/GitHubMarkdownPreview/blob/bafa0df006d05750f06614049953cd78b54e93c3/GHMarkdownPreview.py#L51-L62
The docs for GitHub's
/markdownAPI endpoint are at:
- https://docs.github.com/en/rest/markdown?apiVersion=2022-11-28#render-a-markdown-document
Originally posted by @0xdevalias in https://github.com/dotcypress/GitHubMarkdownPreview/issues/33#issuecomment-1404361635