tbfisher / sublimetext-Pandoc

A Sublime Text plugin that uses Pandoc to convert text from one markup format into another. Pandoc can convert documents in markdown, reStructuredText, textile, HTML, DocBook, LaTeX, MediaWiki markup, OPML, or Haddock markup to XHTML, HTML5, HTML slide shows using Slidy, reveal.js, Slideous, S5, or DZSlides, Microsoft Word docx, OpenOffice/LibreOffice ODT, OpenDocument XML, EPUB version 2 or 3, FictionBook2, DocBook, GNU TexInfo, Groff man pages, Haddock markup, OPML, LaTeX, ConTeXt, LaTeX Beamer slides, PDF via LaTeX, Markdown, reStructuredText, AsciiDoc, MediaWiki markup, Emacs Org-Mode, Textile, or custom writers can be written in lua.
MIT License
136 stars 26 forks source link

Error when using relative images #23

Closed stlehmann closed 8 years ago

stlehmann commented 9 years ago

I get an error when trying to convert my Markdown file with relative image pathes. In my oppinion the reason is that the current directory is net set to the docuemts directory before starting pandoc. This should be done in order to allow relative file imports in future versions.

error

rubenvandeven commented 8 years ago

I can confirm this issue. Having a markdown file with relative paths to images and converting it to pdf results in errors: "pandoc: Could not find image".

However, if I open the console and type:

import os
os.chdir("/path/to/where/my/markdown/file/is")

If I then run pandoc to pdf, it works.

So indeed, changing the current directory before running would be a nice feature!

ghost commented 8 years ago

Hello there, I've encountered the same issue and I made a quick fix in the Pandoc.py file by adding a regex replacement that works just fine (for me, I'm on Windows). It's all thanks to @rubenvandeven for finding this issue out! Pandoc_py_file.zip

I did the following :

  1. extracted the Pandoc package with Package Ressource Viewer
  2. added the following code after line 43 :
    def run(self):
        if self.window.active_view():

            #Modification attempt
            curr_fullpath = self.window.extract_variables()['file_path']
            regexpath = re.compile('\\\\|\\|\/')
            fixd_fullpath = regexpath.sub('/',curr_fullpath)
            os.chdir(fixd_fullpath)
            # ---
            self.window.show_quick_panel(
                self.transformations(),
                self.transform)

Of course, I'm waiting for an official fix from the developper.

rubenvandeven commented 8 years ago

I was about to make a change and create a pull request, but then noticed that #37 is already waiting to be merged. @tbfisher, could you please do that? Thank you for this great plugin!

tbfisher commented 8 years ago

see #37