Compare commits
4 Commits
70022a9b6c
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f4e6cd4ab0 | |||
| c90d3071ea | |||
| 9de735aace | |||
| 786a72126c |
@ -138,18 +138,15 @@ class OpenMarkdownPreviewCommand(sublime_plugin.TextCommand):
|
|||||||
# This is needed because the listener isn't easily accessible directly from the command instance
|
# This is needed because the listener isn't easily accessible directly from the command instance
|
||||||
def trigger_listener_setup(self, md_view_id, pv_view_id):
|
def trigger_listener_setup(self, md_view_id, pv_view_id):
|
||||||
print("--- MarkdownLivePreview: trigger_listener_setup running for md_view: {}, pv_view: {} ---".format(md_view_id, pv_view_id))
|
print("--- MarkdownLivePreview: trigger_listener_setup running for md_view: {}, pv_view: {} ---".format(md_view_id, pv_view_id))
|
||||||
# Find the listener instance (this is a bit indirect, but common in ST plugins)
|
# Access the listener instance directly via its class variable
|
||||||
listener_instance = None
|
listener_instance = MarkdownLivePreviewListener.instance
|
||||||
for listener in sublime_plugin.event_listeners:
|
|
||||||
if isinstance(listener, MarkdownLivePreviewListener):
|
|
||||||
listener_instance = listener
|
|
||||||
break
|
|
||||||
|
|
||||||
if listener_instance:
|
if listener_instance:
|
||||||
print("--- MarkdownLivePreview: Found listener instance, calling setup_and_update_preview ---")
|
print("--- MarkdownLivePreview: Found listener instance via class variable, calling setup_and_update_preview ---")
|
||||||
listener_instance.setup_and_update_preview(md_view_id, pv_view_id)
|
listener_instance.setup_and_update_preview(md_view_id, pv_view_id)
|
||||||
else:
|
else:
|
||||||
print("--- MarkdownLivePreview: ERROR: Could not find MarkdownLivePreviewListener instance to trigger setup! ---")
|
# This should ideally not happen if the listener loaded correctly before the command ran
|
||||||
|
print("--- MarkdownLivePreview: ERROR: MarkdownLivePreviewListener.instance is None! Cannot trigger setup. ---")
|
||||||
|
|
||||||
def is_enabled(self):
|
def is_enabled(self):
|
||||||
# FIXME: is this the best way there is to check if the current syntax is markdown?
|
# FIXME: is this the best way there is to check if the current syntax is markdown?
|
||||||
@ -160,6 +157,7 @@ class OpenMarkdownPreviewCommand(sublime_plugin.TextCommand):
|
|||||||
|
|
||||||
|
|
||||||
class MarkdownLivePreviewListener(sublime_plugin.EventListener):
|
class MarkdownLivePreviewListener(sublime_plugin.EventListener):
|
||||||
|
instance = None # Class variable to hold the single instance
|
||||||
|
|
||||||
phantom_sets = {
|
phantom_sets = {
|
||||||
# markdown_view.id(): phantom set
|
# markdown_view.id(): phantom set
|
||||||
@ -169,6 +167,11 @@ class MarkdownLivePreviewListener(sublime_plugin.EventListener):
|
|||||||
# then, we update only if now() - last_update > DELAY
|
# then, we update only if now() - last_update > DELAY
|
||||||
last_update = 0
|
last_update = 0
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__() # Good practice to call super
|
||||||
|
MarkdownLivePreviewListener.instance = self
|
||||||
|
print("--- MarkdownLivePreview: Listener instance created and registered. ---")
|
||||||
|
|
||||||
# FIXME: maybe we shouldn't restore the file in the original window...
|
# FIXME: maybe we shouldn't restore the file in the original window...
|
||||||
|
|
||||||
def on_pre_close(self, markdown_view):
|
def on_pre_close(self, markdown_view):
|
||||||
|
|||||||
Binary file not shown.
22
README.md
22
README.md
@ -1,5 +1,25 @@
|
|||||||
# MarkdownLivePreview
|
# MarkdownLivePreview
|
||||||
|
|
||||||
|
## Acknowledgments
|
||||||
|
|
||||||
|
This project is a fork of [MarkdownLivePreview](https://github.com/math2001/MarkdownLivePreview) by **math2001**. I'm grateful for the original implementation, which provided a solid foundation for live Markdown preview in Sublime Text.
|
||||||
|
|
||||||
|
Many thanks to math2001 for the original code—this fork wouldn't have been possible without their work.
|
||||||
|
|
||||||
|
## Changes contained in this Fork
|
||||||
|
|
||||||
|
In this fork ([christian.morpurgo/MarkdownLivePreview](https://git.0x42.cloud/christian.morpurgo/MarkdownLivePreview)), I've made the following enhancements:
|
||||||
|
|
||||||
|
- **Bundled `bs4` and `soupsieve`**
|
||||||
|
Repackaged both libraries as standalone modules by rewriting their imports, resolving errors when Sublime Text 4 attempted to install these old versions as external dependencies.
|
||||||
|
|
||||||
|
- **`font_scale` option**
|
||||||
|
Added a new `font_scale: number` setting to allow users to increase or decrease the preview text size directly from their Sublime Text settings.
|
||||||
|
|
||||||
|
- **In-window preview**
|
||||||
|
Changed the preview behavior so that starting a preview reuses the current window instead of opening a new one.
|
||||||
|
|
||||||
|
|
||||||
A simple plugin to preview your markdown as you type right in Sublime Text.
|
A simple plugin to preview your markdown as you type right in Sublime Text.
|
||||||
No dependencies!
|
No dependencies!
|
||||||
|
|
||||||
@ -31,7 +51,7 @@ could be working on, then there are a bunch of `FIXME`s all over this package.
|
|||||||
Just pick one and fix it :-)
|
Just pick one and fix it :-)
|
||||||
|
|
||||||
```
|
```
|
||||||
$ git clone https://github.com/math2001/MarkdownLivePreview
|
$ git clone https://git.0x42.cloud/christian.morpurgo/MarkdownLivePreview
|
||||||
$ cd MarkdownLivePreview
|
$ cd MarkdownLivePreview
|
||||||
$ grep -R FIXME
|
$ grep -R FIXME
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user