Sublime Forum

MarkdownLivePreview

#1

Hi guys!

I’ve seen a few plugin for sublime text that offers a preview for your markdown, but there’s some annoying dependencies.

So, I’ve created a plugin that preview you markdown in sublime text using the phantoms.

Naturaly, it’s called MarkdownLivePreview

It converts markdown to html using markdown2, but it’s only one file so it is included in the package.

Installation

See the README, it takes a fair bit of space :smiley:

Usage

As I say in the README, we don’t want the preview all the time. So, you just need to run a shortcut (alt+m), and it will activate it for you.

In dev

This plugin is in dev, this is why I present it. Tell me what you think about it. I know there’s some bug, but I don’t want to spend my time solving them for a plugin no one’s going to use, I’ve got much better to do (although they look pretty easy to solve).

So, if you feel you could use it, let me know, it might boost its dev.

Thanks for reading!

Matt

2 Likes

#2

Could you provide a screencast show how it is?

1 Like

#3

Sure! Here it is:

5 Likes

#4

Wow, looks awesome! Definitely I’ll use it! I wanted this feature for years :wink:

0 Likes

#5

But it’s not working for me now :frowning:

Sublime can’t find this:
https://github.com/math2001/MarkdownLivePreview/blob/master/md_in_popup.py#L3

0 Likes

#6

I don’t see Sublime minihtml supporting all of the HTML tags that you can generate using Markdown anytime soon or even ever!
Things like tables for example that’s very common in GFM.
How you gonna handle those?

0 Likes

#7

Would be cool if the preview auto-scrolled too, but I don’t see how that would be possible.

Likely not at all.

0 Likes

#8

You can use the rule of three to force the Preview Window follow the Markdown Window or vice-versa, or both at them same time, or any of them, configurable by the user.

Would be nice a option to lock and unlock the synced scroll, as a command on the command palette. Because some times or most times this simple algorithm could fail. Then it would be time to create alternate strategies to the rule of three, studying better how the Preview Windows is composed from the Markdown Window.

0 Likes

#9

@addons_zz I’ll look for the sync scroll

@ihodev Fixed. sublimetools is a package that I created that is just composed of a few shortcuts. I just removed it and replaced it with the function I’m likely to use.

@aziz No, it’s not going to support table, unless the phantom does. There is not much I can do about it. So, +1 to @FichteFoll

Well, looks like I’m going to continue this package… :slightly_smiling:

Thank you for your feedbacks!

Matt

3 Likes

#10

It will be a big suprise for me if all the funtionarity completed.I am too impatient to use it since it is not convenient to preview it in a browser.And I doubt why sublime Text didn’t integraded browser in it directly.If one day it support table,I will use it without hesitation.
It would be nice to support markdown.py’s extention like abbr_list which markdown2 do not support.
I will share it in my blog when it is complete.Thanks for your work.

0 Likes

#11

Is it a classic thing? I’ve never heard anything about those before…

Thanks!

I added a few changes: support <pre> blocks, with the indentation, no hard color (adapt to the color scheme), and sync scroll (when you type, not when you scroll).

Tell me what you think about it, any feature, @ihodev you’ve made great themes, if there’s any style that should be added/removed, tell me, i’m not really good at designing stuff. :smile:

Matt

0 Likes

#12

I’m on vacation now. I think I’ll write you later about some minor visual improvements or contribute to it :wink: Thanks!

1 Like

#13

+1
I’d use this plugin for sure.

1 Like

#14

just some news:

  • v1.1.0 is out
  • you might have noticed, it’s now on PackageControl!
  • it can display local/remote images (it has a cache system, so it doesn’t load each time you type a word) (thanks to @ihodev)
  • The preview is automatically hidden when the markdown view isn’t focus (and shown back as soon as it is re-focused). Thank to @yangweijie for the idea.

If there’s anything you’d like to see changed, just let me know!

That’s it for now, I hope you’ll enjoy MarkdownLivePreview. :slightly_smiling:

3 Likes

#15

The version 2 is out!

The system’s different: it now opens a new window for editing/previewing the markdown. Why? Because the showing/hiding the preview when the markdown view has the focus is a great idea, but made ST crashed (I haven’t find the solution yet).

So, it’s kind of a bind news because, as you know, the new window is going to be small size by default (on window win+up does the trick pretty fast). That’s the only reason. Otherwise, ST should crash anymore.

As you’ll understand, I can’t let a package crash 80% of time to a final user (especially now that it’s on package control).

So, this version is now the master branch, but I’m still going to work on the previous solution (showing/hiding), which I love, but is dangerous.

I’ll let you know about how it’s going, and don’t hesitate to tell me what you think about this. :slightly_smiling:

Hope you’ll still enjoy using this plugin!

Matt

1 Like

#16

Hi,

I wonder how that works using these phantoms mentioned in the first post.
Because I would love to have a PDF preview similar to this markdown preview. I wonder whether such a thing would be possible.

0 Likes

#17

I converts the markdown to a HTML code. I don’t know how PDF works, what would you want? You type the PDF, and you get the preview of it on the right?

It depends if it can be converted to (simple) html.

I don’t really see the use though? Do you edit your PDF by hand?

0 Likes

#18

I assume you are speaking about editing LaTeX. It is possible to show a pdf in the phantom by converting it to a png using ghostscript. We do something similar to preview equations, while editing them with LaTeXTools.

preview_math

However this is ill-suited to preview whole documents and would disable features like forward and inverse search.

1 Like

#19

Problem Description:
The zip version gets Sublime 3
The plug-in you downloaded manually has the following shortcuts after installation
{“keys”: [“alt+m”], “command”: “markdown_preview”, “args”: {“target”, “browser”, “parser”, “markdown”}
When I press Alt + m, it opens directly in the browser, not on the right side of the re-editor.

0 Likes