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
137 stars 26 forks source link

How to avoid the popup every use? Or set a hotkey? #60

Open AnnanFay opened 7 years ago

AnnanFay commented 7 years ago

Hello,

Right now I'm using this to convert markdown to PDF. This is the only way I'm using this.

Is there a way to avoid the dropdown option every time? As I want to convert to PDF every time I use this.

Also, is there a way I can link this into the build system? So I can just click Ctrl+B when editing markdown and auto generate the PDF?

Maybe I'm using this extension incorrectly or there's an alternative. I've had a quick look at the settings file and couldn't find an option.

I've tried setting up a hotkey:

{ "keys": ["ctrl+shift+b"], "command": "pandoc", "args": {"transformation": "PDF"}},

However this fails with:

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 812, in run_
    return self.run(edit, **args)
  File "Pandoc in /home/_/.config/sublime-text-3/Installed Packages/Pandoc.sublime-package", line 103, in run
TypeError: string indices must be integers
pchtsp commented 6 years ago

I've been trying to do this too. If you use the following configuration, you'll have the shortcut but it will still show the prompt;

    { 
        "keys": ["ctrl+shift+k"],"command": "prompt_pandoc"
    },

I think in order to be able to give it the text argument with the name of the transformation, some modifications need to be done in the code or another function would need to be created because the transformation argument in the run function that is being called is in fact a dictionary.

While writing this answer, and based on your example, I figure out you can actually do this in a "not-so-pretty" way by giving explicitly the dictionary with the settings as the argument. I use html syntax but you would just have to copy your pdf settings here:

{ 
    //"keys": ["ctrl+shift+k"],"command": "prompt_pandoc"
    "keys": ["ctrl+shift+k"],
    "command": "pandoc",
    "args": 
    {
    "transformation":
        {
        "new-buffer": 1,
        "scope": {
          "text.html.markdown": "markdown",
          "text.html": "html",
        },
        "out-ext": "html",
        "pandoc-arguments": [
          "--to=html5",
          "--no-highlight",
          "--output=output.html",
          "--self-contained",
          "--standalone"
        ]
        }
    }
},
MPvHarmelen commented 4 years ago

I would also love to be able to do this. It seems like there's a fork that has solved this problem: https://github.com/geniusupgrader/Spandoc, maybe someone could look into how much work it is to port their solution?

It seems quite easy, this is the commit: https://github.com/geniusupgrader/Spandoc/commit/438abafc8bb99d0cda96538875b8685cd1bb029f