Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the preview function in VimRepressPy3 #1820

Open
vanabel opened this issue May 4, 2023 · 0 comments
Open

Improve the preview function in VimRepressPy3 #1820

vanabel opened this issue May 4, 2023 · 0 comments

Comments

@vanabel
Copy link

vanabel commented May 4, 2023

StackEdit is awesome and I like it very much. But I would like to write markdown in VIM since there are a lot of math symbols I need to type. So I use the plugin VimRepressPy3, it has the preview function proceed by Python, see https://github.com/BourgeoisBear/VimRepressPy3/blob/399dbd9cdd675607c1651fb18befa4083114bf4a/plugin/vimrepress.py#L542:

    def html_preview(self):
        """
        Opens a browser with a local preview of the content.
        @params text_html - the html content
                meta      - a dictionary of the meta data
        """
        if g_data.vimpress_temp_dir == '':
            g_data.vimpress_temp_dir = tempfile.mkdtemp(suffix="vimpress")

        html = \
                """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Vimpress Local Preview: %(title)s</title> <style type="text/css"> ul, li { margin: 1em; } :link,:visited { text-decoration:none } h1,h2,h3,h4,h5,h6,pre,code { font-size:1.1em; } h1 {font-size: 1.8em;} h2 {font-size: 1.5em;} h3{font-size: 1.3em;} h4{font-size: 1.2em;} h5 {font-size: 1.1em;} a img,:link img,:visited img { border:none } body { margin:0 auto; width:770px; font-family: Helvetica, Arial, Sans-serif; font-size:12px; color:#444; } </style> </meta> </head> <body> %(content)s </body> </html>
""" % dict(content=self.html_text, title=self.buffer_meta["title"])
        with open(os.path.join(
                g_data.vimpress_temp_dir, "vimpress_temp.html"), 'w') as f:
            f.write(html)
        webbrowser.open("file://%s" % f.name)

    def remote_preview(self, pub="draft"):
        self.post_status = pub
        self.save_post()
        webbrowser.open("%s?p=%s&preview=true" %
                (g_data.blog_url, self.post_id))

Can we just improve it to preview the content in StackEdit? Thank you in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant