mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Re-render markdown when a grammar is added
Previously if the markdown preview launched before grammars finished loading the fenced code blocks would not be colorized correctly.
This commit is contained in:
@@ -37,6 +37,7 @@ class MarkdownPreviewView extends ScrollView
|
||||
super
|
||||
|
||||
@renderMarkdown()
|
||||
syntax.on 'grammar-added', => @renderMarkdown()
|
||||
@on 'core:move-up', => @scrollUp()
|
||||
@on 'core:move-down', => @scrollDown()
|
||||
|
||||
@@ -72,7 +73,6 @@ class MarkdownPreviewView extends ScrollView
|
||||
setLoading: ->
|
||||
@html($$$ -> @div class: 'markdown-spinner', 'Loading Markdown...')
|
||||
|
||||
|
||||
tokenizeCodeBlocks: (html) =>
|
||||
html = $(html)
|
||||
preList = $(html.filter("pre"))
|
||||
|
||||
@@ -122,3 +122,13 @@ describe "MarkdownPreview package", ->
|
||||
pane1.activeItem.buffer.trigger 'saved'
|
||||
expect(preview.renderMarkdown).toHaveBeenCalled()
|
||||
expect(pane2.activeItem).toBe preview
|
||||
|
||||
describe "when a new grammar is loaded", ->
|
||||
it "reloads the view to colorize any fenced code blocks matching the newly loaded grammar", ->
|
||||
rootView.getActiveView().trigger 'markdown-preview:show'
|
||||
[pane1, pane2] = rootView.getPanes()
|
||||
preview = pane2.activeItem
|
||||
preview.renderMarkdown.reset()
|
||||
|
||||
atom.activatePackage('javascript-tmbundle', sync: true)
|
||||
expect(preview.renderMarkdown).toHaveBeenCalled()
|
||||
|
||||
Reference in New Issue
Block a user