add feature:
setting to increase font scale
This commit is contained in:
@ -20,6 +20,7 @@ from .markdown2html import markdown2html
|
||||
MARKDOWN_VIEW_INFOS = "markdown_view_infos"
|
||||
PREVIEW_VIEW_INFOS = "preview_view_infos"
|
||||
SETTING_DELAY_BETWEEN_UPDATES = "delay_between_updates"
|
||||
SETTING_FONT_SCALE = "font_scale"
|
||||
|
||||
resources = {}
|
||||
|
||||
@ -201,7 +202,12 @@ class MarkdownLivePreviewListener(sublime_plugin.EventListener):
|
||||
# This check is needed since a this function is used as a callback for when images
|
||||
# are loaded from the internet (ie. it could finish loading *after* the user
|
||||
# closes the markdown_view)
|
||||
if time.time() - self.last_update < DELAY / 1000:
|
||||
# Reload settings each time to catch changes
|
||||
settings = get_settings()
|
||||
delay = settings.get(SETTING_DELAY_BETWEEN_UPDATES, 100) # Provide default
|
||||
font_scale = settings.get(SETTING_FONT_SCALE, 1.0) # Provide default
|
||||
|
||||
if time.time() - self.last_update < delay / 1000:
|
||||
return
|
||||
|
||||
if markdown_view.buffer_id() == 0:
|
||||
@ -213,15 +219,19 @@ class MarkdownLivePreviewListener(sublime_plugin.EventListener):
|
||||
markdown = markdown_view.substr(total_region)
|
||||
|
||||
preview_view = markdown_view.window().active_view_in_group(1)
|
||||
viewport_width = preview_view.viewport_extent()[0]
|
||||
# Get viewport_width, default to a large value if view isn't ready
|
||||
viewport_extent = preview_view.viewport_extent()
|
||||
viewport_width = viewport_extent[0] if viewport_extent else 1024
|
||||
|
||||
basepath = os.path.dirname(markdown_view.file_name())
|
||||
|
||||
basepath = os.path.dirname(markdown_view.file_name()) if markdown_view.file_name() else '.' # Handle unsaved files
|
||||
html = markdown2html(
|
||||
markdown,
|
||||
basepath,
|
||||
partial(self._update_preview, markdown_view),
|
||||
resources,
|
||||
viewport_width,
|
||||
font_scale,
|
||||
)
|
||||
|
||||
self.phantom_sets[markdown_view.id()].update(
|
||||
|
||||
Reference in New Issue
Block a user