revolunet / sublimetext-markdown-preview

markdown preview and build plugin for sublime text 2/3
MIT License
2.31k stars 362 forks source link

Setting for whether the build system should build or preview? #175

Closed FichteFoll closed 10 years ago

FichteFoll commented 10 years ago

I use this plugin mainly for writing readmes or markdown documents in general for github, so I rarely need to "build" an html file if at all. However, I would love if I could use the same key binding as for every other file type. For now I just set the build system to call my own "batch" command which then calls the markdown_preview text command because you can only run window commands from build systems, but I really think this should be a setting.

FichteFoll commented 10 years ago

That actually didn't work so I had to override the plugin file. It's quick and dirty, but it does the job (so no PR). I just added this after line 504:


        settings = sublime.load_settings('MarkdownPreview.sublime-settings')
        if settings.get('preview_on_build'):
            view.run_command("markdown_preview")
            return

and set the setting accordingly (to true).

revolunet commented 10 years ago

i'm not sure to get it. you'd like to user Ctrl+B to preview instead of default build command ?

FichteFoll commented 10 years ago

Yes.

facelessuser commented 10 years ago

I am not sure a build should do as you suggest. It sounds like you should just preview via a keybinding or something similar.

@revolunet do you have an opinion on whether this should remain open?

FichteFoll commented 10 years ago

The plugin is called "Markdown Preview" so I figured its purpose was to preview built markdown ... I do realize though that this is likely not what everyone expects, referring to "bulding" something.

Anyway, I will just override the default keybinding for building (or rather the one I use) when I'm in a markdown file and make that always call markdown_preview the next time I end up using it. Or maybe I won't because it always works with my hack above.

facelessuser commented 10 years ago

I'm not suggesting we shouldn't. I am more sharing my opinion and requesting revolunet's opinion.

Using your hack will require you to maintain your own version or you will have to keep rebasing your stuff off the main branch. That is your choice though.

Recently, I have decided in the next little while to help reduce some of these issues and improve some things on this plugin. If @revolunet wants to add your suggestion, I will do it (especially since it is optional). I just noticed the issue has been open a number of months, and I am more curious if there was a reason he didn't add this already (besides not having time). If figure you never issued a pull request because you never got a response. I am just trying to get a response.

revolunet commented 10 years ago

thanks @facelessuser for helping here :) Having Cmd+B working on md files would be natural. For some reason i didn't implemented it before. Cmd+B should use the default settings

facelessuser commented 10 years ago

Cool this is easy enough to do.

facelessuser commented 10 years ago

You can now use this setting:

    /*
        By default, Markdown Preview builds the HTML in the source directory.
        It expects the file to exist on disk.  It pops up the build output panel etc.

        If you wish to override this behavior, you can change "build_action"

        build - The default build behavior.
        browser - Preview the file in your browser.
        clipboard - Copy the HTML output to the clipboard.
        sublime - Export the HTML to a Sublime tab.
        save - Run the normal save command that outputs to the source directory.
            It will also prompt for "save as" if the file does not exit on disk.

        All the build options use the default parser defined above in "parser"
    */
    "build_action": "build",
FichteFoll commented 10 years ago

Thanks!