diff --git a/README.md b/README.md
index ed01db7..0a4f1b0 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# Markdown Preview package
[![macOS Build Status](https://travis-ci.org/atom/markdown-preview.svg?branch=master)](https://travis-ci.org/atom/markdown-preview) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/bvh0evhh4v6w9b29/branch/master?svg=true)](https://ci.appveyor.com/project/Atom/markdown-preview/branch/master) [![Dependency Status](https://david-dm.org/atom/markdown-preview.svg)](https://david-dm.org/atom/markdown-preview)
-Show the rendered HTML markdown to the right of the current editor using ctrl-shift-m.
+Show the rendered HTML markdown next to the current editor using ctrl-shift-m.
It is currently enabled for `.markdown`, `.md`, `.mdown`, `.mkd`, `.mkdown`, `.ron`, and `.txt` files.
@@ -9,6 +9,8 @@ It is currently enabled for `.markdown`, `.md`, `.mdown`, `.mkd`, `.mkdown`, `.r
## Customize
+You can choose in which direction to show the preview (`right` or `down`), or even to show the preview in a new tab in the current pane (`none`) by using the Split Pane Direction in the __package settings__.
+
By default Markdown Preview uses the colors of the active syntax theme. Enable `Use GitHub.com style` in the __package settings__ to make it look closer to how markdown files get rendered on github.com.
![markdown-preview GitHub style](https://cloud.githubusercontent.com/assets/378023/10013087/24ccc7ec-6149-11e5-97ea-53a842a715ea.png)
diff --git a/lib/main.coffee b/lib/main.coffee
index c700829..fd548bf 100644
--- a/lib/main.coffee
+++ b/lib/main.coffee
@@ -96,8 +96,9 @@ module.exports =
previousActivePane = atom.workspace.getActivePane()
options =
searchAllPanes: true
- if atom.config.get('markdown-preview.openPreviewInSplitPane')
- options.split = 'right'
+ splitPane = atom.config.get('markdown-preview.splitPaneDirection')
+ if splitPane isnt 'none'
+ options.split = splitPane
atom.workspace.open(uri, options).then (markdownPreviewView) ->
if isMarkdownPreviewView(markdownPreviewView)
previousActivePane.activate()
diff --git a/package.json b/package.json
index 767b7c5..09ae03b 100644
--- a/package.json
+++ b/package.json
@@ -33,10 +33,11 @@
"default": true,
"description": "Re-render the preview as the contents of the source changes, without requiring the source buffer to be saved. If disabled, the preview is re-rendered only when the buffer is saved to disk."
},
- "openPreviewInSplitPane": {
- "type": "boolean",
- "default": true,
- "description": "Open the preview in a split pane. If disabled, the preview is opened in a new tab in the same pane."
+ "splitPaneDirection": {
+ "type": "string",
+ "default": "right",
+ "enum": ["none", "right", "down"],
+ "description": "Whether to open the preview in a split pane, and if so the direction in which to open it. If `none`, the preview is opened in a new tab in the same pane."
},
"allowUnsafeProtocols": {
"type": "boolean",
diff --git a/spec/markdown-preview-spec.coffee b/spec/markdown-preview-spec.coffee
index ef4765b..8ae1140 100644
--- a/spec/markdown-preview-spec.coffee
+++ b/spec/markdown-preview-spec.coffee
@@ -4,6 +4,7 @@ temp = require('temp').track()
MarkdownPreviewView = require '../lib/markdown-preview-view'
describe "Markdown Preview", ->
+ previewPane = null
preview = null
beforeEach ->
@@ -24,21 +25,45 @@ describe "Markdown Preview", ->
runs ->
spyOn(atom.packages, 'hasActivatedInitialPackages').andReturn true
- expectPreviewInSplitPane = ->
+ expectPreviewInSplitPane = (orientation='horizontal') ->
waitsFor -> atom.workspace.getCenter().getPanes().length is 2
waitsFor "markdown preview to be created", ->
- preview = atom.workspace.getCenter().getPanes()[1].getActiveItem()
+ previewPane = atom.workspace.getCenter().getPanes()[1]
+ preview = previewPane.getActiveItem()
runs ->
expect(preview).toBeInstanceOf(MarkdownPreviewView)
expect(preview.getPath()).toBe atom.workspace.getActivePaneItem().getPath()
+ expect(previewPane.getParent().getOrientation()).toBe orientation
describe "when a preview has not been created for the file", ->
- it "displays a markdown preview in a split pane", ->
+ it "displays a markdown preview in a split pane (right by default)", ->
waitsForPromise -> atom.workspace.open("subdir/file.markdown")
runs -> atom.commands.dispatch atom.workspace.getActiveTextEditor().getElement(), 'markdown-preview:toggle'
- expectPreviewInSplitPane()
+ expectPreviewInSplitPane('horizontal')
+
+ runs ->
+ [editorPane] = atom.workspace.getPanes()
+ expect(editorPane.getItems()).toHaveLength 1
+ expect(editorPane.isActive()).toBe true
+
+ it "displays a markdown preview in a split pane (right)", ->
+ atom.config.set 'markdown-preview.splitPaneDirection', 'right'
+ waitsForPromise -> atom.workspace.open("subdir/file.markdown")
+ runs -> atom.commands.dispatch atom.workspace.getActiveTextEditor().getElement(), 'markdown-preview:toggle'
+ expectPreviewInSplitPane('horizontal')
+
+ runs ->
+ [editorPane] = atom.workspace.getPanes()
+ expect(editorPane.getItems()).toHaveLength 1
+ expect(editorPane.isActive()).toBe true
+
+ it "displays a markdown preview in a split pane (down)", ->
+ atom.config.set 'markdown-preview.splitPaneDirection', 'down'
+ waitsForPromise -> atom.workspace.open("subdir/file.markdown")
+ runs -> atom.commands.dispatch atom.workspace.getActiveTextEditor().getElement(), 'markdown-preview:toggle'
+ expectPreviewInSplitPane('vertical')
runs ->
[editorPane] = atom.workspace.getCenter().getPanes()