Skip to content

Commit

Permalink
If project directory is set, use it as working directory.
Browse files Browse the repository at this point in the history
This allows to use project-specific Markdown processors: If you have for example a Ruby project using the Redcarpet gem, you can now set `TM_MARKDOWN` to `bundle exec redcarpet` (optionally specifying additional command line options for configuration) in the project’s `.tm_properties` to use this exact version of Redcarpet for the preview command.
  • Loading branch information
noniq committed Aug 7, 2016
1 parent d39076a commit 6bfce79
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Commands/Markdown preview.plist
Expand Up @@ -11,6 +11,16 @@ require "#{ENV["TM_SUPPORT_PATH"]}/lib/tm/htmloutput"
require "#{ENV["TM_SUPPORT_PATH"]}/lib/tm/markdown"
TextMate::HTMLOutput.show(:title => "Markdown Preview", :sub_title => ENV["TM_FILENAME"]) do |io|
if ENV['TM_PROJECT_DIRECTORY']
# Run the Markdown command with the project directory as working dir: If you
# have for example a Ruby project using the Redcarpet gem, you can set
# `TM_MARKDOWN` to `"bundle exec redcarpet"` (optionally specifying additional
# command line options for configuration) in the project’s
# `.tm_properties` to use this exact version of Redcarpet for the preview
# command.
Dir.chdir ENV['TM_PROJECT_DIRECTORY']
end
if ENV["TM_FILEPATH"] && File.exists?(ENV["TM_FILEPATH"])
io << "<base href='file://#{URI.escape ENV["TM_FILEPATH"]}'>\n"
end
Expand Down

0 comments on commit 6bfce79

Please sign in to comment.