Search code examples
pythongedit

Markdown preview Python-based plugin for gedit


I've installed the markdown preview plugin for gedit running on Lubuntu 13.04. It works as expected.

markdown preview in gedit

However, for ease of viewing, I altered the appearance of the resulting html panel (left panel) by including a link to a local stylesheet at the top of each markdown file. But this approach obviously means that I have to alter all my existing markdown files.

To avoid that, I looked at ~/.local/share/gedit/plugins/markdown-preview/__init__.py which has the code for the plugin, and I see lines #39 and #40 (reproduced below):

# Can be used to add default HTML code (e.g. default header section with CSS).
htmlTemplate = "%s" 

That gives me the impression that I can somehow tell the plugin to look at a stylesheet and style the html accordingly. But I don't know what to do (if indeed htmlTemplate = "%s" has to be changed).


Solution

  • Set htmlTemplate to something like the following

    # Can be used to add default HTML code (e.g. default header section with CSS).
    htmlTemplate = """
    <html>
    <head>
    <link rel="stylesheet" type="text/css" charset="utf-8" media="screen" href="http://paste.ubuntu.com/static/pastebin.css">
    </head>
    <body>
    %s
    </body>
    </html>
    """