ogom / sublimetext-markdown-slideshow

Sublime Text 2/3 plugin for markdown slideshow
http://ogom.github.com/sublimetext-markdown-slideshow
93 stars 18 forks source link

if output_file is specified as ".", then output html file to the same directory. #6

Closed liris closed 9 years ago

liris commented 12 years ago

markdown-slideshow always outputs html file to the same directory or temporary directory. But if the md file contains images, the img link is not workable.

The patch is to output html file to the same directory of the md file.

ogom commented 12 years ago

The output in the same directory it is good. Mcider default is output to the same directory.

By the way, the image is displayed if an absolute path.

![mocha](file:///Users/user/images/mocha.png)
ogom commented 12 years ago

fix the file name is null.

# path of the output file
output_path = None
if not output_file is None:
    if output_file == '.':
        file_name = self.view.file_name()
        if not file_name is None:
            output_path = os.path.abspath(os.path.dirname(file_name))
            output_file = os.path.join(output_path, os.path.splitext(os.path.basename(file_name))[0] + '.html')
    else:
        output_path = os.path.abspath(os.path.dirname(output_file))

if output_path is None or not os.path.isdir(output_path):
    output_path = tempfile.mkdtemp()
    output_file = os.path.join(output_path, 'slide.html')