Jump to content

Pandoctor: An Alfred GUI for Pandoc


Recommended Posts

Pandoctor

An Alfred GUI for Pandoc

Version: 1.0.5

Download from Packal

View on GitHub

Read a slightly fuller version on my blog

Introduction

Pandoctor is a relatively simple, easy-to-use way to bring the high-powered functionality of Pandoc to you. For those new to Pandoc, Pandoc is "the universal document converter". It is an amazingly powerful utility that allows you to convert structured text from a ton of possible input formats to an even larger number of output formats.

A potential downside to Pandoc, however, for many users is that it is entirely a command line utility. This means, on the Mac, you have to open Terminal to use it. For many Mac/Alfred users, this is at least slightly daunting. Yet I believe that this should not be a deterrent to more people coming to use the power of Pandoc. This is the reason for Pandoctor. Now, Alfred users can enjoy the comfortability and familiarity of the Alfred interface to manage Pandoc. Here's how:

Pandoctor is accessed via File Actions. The basic file action is "New Pandoc Conversion", which will kick off a series of interactive Alfred menus to create your Pandoc conversion. Once you have chosen the file you want to convert and selected the file action, Pandoctor works in 4 stages:

  • specify the text format of the chosen file
  • chose the output format you want for the converted file
  • chose any options you want for the conversion process
  • run Pandoc to convert the input file using your chosen options
Luckily, Pandoctor is built to move you through these four steps seamlessly and without any interaction on your part aside from selecting and setting the formats and options you want. Let's walk through the steps.

Configuration

When you first download Pandoctor, you will need to configure a few settings. Luckily, Pandoctor takes care of this for you. All you need to do is use the dr:config keyword to get everything set up. Once you see the completion notification, you can start using Pandoctor for real.

Running a new Pandoc Conversion

Using the File Action

If you've configured, you begin Pandoctor by using Alfred's file navigation abilities to find the file you want Pandoc to convert for you. Once you've found the file, enter Alfred's File Actions pane for that file (by default this is ). Then find Pandoctor's "New Pandoc Conversion" file action:

>file_action_new.png

Selecting the Input Format

This tells Pandoctor to begin a new conversion on that file. Once you select "New Pandoc Conversion", Pandoctor will automatically ask you to choose the format of this input file:

>dr_in.png

Pandoctor tries to be smart about formatting, so it will pre-fill the search bar with what it believes to be the file's formatting. However, if you need to, you can simply delete this and start searching yourself. You will see that Pandoctor displays the full name of the input format as well as a short description to help you discern between similar formats (such as the 4 types of Markdown Pandoc accepts).

Selecting the Output Format

When you choose the input format, Pandoctor will then automatically ask you to select what format you want the outputted, converted file to be:

>dr_out.png

You have access to the full range of possible output formats from this selection. You can use the arrow keys to navigate down, or start searching for your desired output format by name:

Selecting any Options

As soon as you select the output format, Pandoctor will ask you what Options you want to add to this Pandoc conversion:

>dr_opt.png

Pandoctor UI

There are a few elements to the UI that require more explanation. First, you see that some items have the inner rectangle filled, and others do not. This is your visual cue to determine which options are active for this conversion (filled) and which are not (empty).

Pandoctor Default Options

When you first come to this "screen" or "window" (not sure what to call individual Alfred windows/pop-ups), you will see that some options are already filled, even though you didn't select them. These are Pandoctor's Default Options. The file (pandoc_defaults.json) specifying which options are by default always on (filled) can be found inside the workflow's folder (if you need to open this folder, you can do so easily using the dr:help keyword and selecting Root). This file also has comments for most options, which gives some information about them (Obviously, for detailed information about Pandoc's options, visit the User Guide). When installed, Pandoctor has 4 default options on:

  • parse-raw
    • Description: "Parse untranslatable HTML codes and LaTeX environments as raw HTML or LaTeX, instead of ignoring them."
  • smart
    • Description: "Produce typographically correct output, converting straight quotes to curly quotes, --- to em-dashes, -- to en-dashes, and ... to ellipses."
  • normalize
    • Description: "Normalize the document after reading: merge adjacent Str or Emph elements, for example, and remove repeated Spaces."
  • standalone
    • Description: "Produce output with an appropriate header and footer (e.g. a standalone HTML, LaTeX, or RTF file, not a fragment)."
User Default Options

If you want to set your own default options (overriding these), you can use the dr:defs keyword. This will provide a "window" similar to the standard Options window, but without anything selected. Here select whatever items you want to be on by default for any new conversion.

Selecting any Options, pt. 2

Back to the Options Selection, tho. You will also see that that there are 2 basic types of options:

  • Boolean
  • Argument
Selecting Boolean Options

If you select a Boolean option, it will simply "turn on" (the rectangle will be filled) and this screen will refresh. For example, here's this screen right before I choose to "turn on" the strict option:

>dr_opt_parse_off.png

and here's what the screen looks like as soon as it refreshes after I selected that option:

>dr_opt_parse_on.png

Selecting Argument Options

So, "turning on" Boolean options is simple. Argument options, however, require a bit more work. As the name suggests, this type of option requires more information (an "argument"). (Again, if any of this is confusing, I would highly recommend reading through Pandoc's User Guide). This means that you will need to tell Pandoctor what you want the "argument", the information, to be. So, whenever you select an Argument option, you are taken to an intermediary "screen" where you can supply the needed information. For example, if I were to select the toc-depth argument option, I  would then fill in the information (I want the Table of Contents in the converted file to only go 4 levels deep):

>dr_opt_set_filled.png

Once you fill in the information, press return (i.e. "Set argument value of chosen option") and return to the base Options "screen".

Finalizing Options

Now, as soon as you have set all of the options you need, you only need to select the top item on this "screen": Done setting Options?. This will close this screen. As I've noted before, if you instead select an option, this screen will merely refresh.

Pandoctor UI, pt. 2

A small UI note: there is always a "header" for every list that Pandoctor displays. However, there are 2 different kinds of headers:

  • informational and non-selectable
  • interrogative and selectable
The purely informational headers have the little i in the center. These headers are found when selecting input and output formats. They cannot be selected; they simply tell you what that "screen" is. The interrogative headers, however, can be selected. These have the ? in the center. You will use these to "close" the screen you are viewing.

Running your Pandoc Conversion

Returning to the flow of the conversion, you have just finished selecting all of the options for your Pandoc conversion. As soon as you hit Done setting Options?, Pandoctor will begin processing the conversion. This process can take a bit of time (particularly when generating PDFs), but when it is complete, you will see a notification in the top right of your screen:

That's all there is to it really. In 4 simple steps, you can convert just about anything. However, for those more inclined toward "power-use", there are a few other abilities under Pandoctor's hood.


Ignoring Options

First off, Pandoctor offers the ability to "hide" or "ignore" certain options in the Select Options screen. Pandoc itself offers a lot of options, and always seeing them all is often unnecessary. If there are any options that you never use, you can simply remove them. To do this, you need to use the dr:ignore keyword.

This will bring up a "screen" almost identical to the Select Options screen, but here you are choosing what options are hidden from that other screen. Once again, the two icons are informative. If an item is filled in, this means that it is going to be ignored:

>dr_ignore_data_on.png

Otherwise (not filled in), it will appear in the standard Select Options window:

>dr_ignore_data_off.png

As with the basic window, you can search here or just use the arrow keys. Select all of the options you want to ignore, and when you are done, select Done setting Ignore? to exit.

Template Commands

For those who use Pandoc frequently, you will likely use the same basic command over and over again. If that's the case, Pandoctor has a "power-user" feature just for you. In addition to the "on-the-fly" conversion available via the "New Pandoc Conversion" file action, Pandoctor also hase a "Templated Pandoc Conversion" file action:

>file_action_template.png

This action grants you access to any and all Pandoc template commands you have set up. Before I detail how to create a new template, let's briefly discuss the elements of a template. Pandoctor ships with a file in the workflow directory that has some sample templates. This file is titled pandoc_templates.json. If you open this file in your text editor of choice, it will look just like this:

Sample Templates

 

/*
PANDOC TEMPLATED COMMANDS

The [font=courier new,courier,monospace][/font]defaults[font=courier new,courier,monospace][/font], at initiation the [font=courier new,courier,monospace]parse-raw[/font], [font=courier new,courier,monospace]smart[/font], [font=courier new,courier,monospace]normalize[/font], and [font=courier new,courier,monospace]standalone[/font]
options, are found at [font=courier new,courier,monospace][/font]pandoc_defaults.json[font=courier new,courier,monospace][/font].

HOW TO CREATE TEMPLATE:
    + take your CLI pandoc command 
        (e.g. "pandoc -s -S --toc -c pandoc.css -A footer.html README -o example3.html")
    + convert all "short option + space + argument" to "long option + '=' + argument"
        (e.g. "pandoc -s -S --toc --css=pandoc.css --include-after-body=footer.html README --output=example3.html")
    + split all options into list of individual options
        (e.g. [pandoc, -s, -S, --toc, --css=pandoc.css, --include-after-body=footer.html, README, --output=example3.html])
    + remove initial call to [font=courier new,courier,monospace]pandoc[/font] and replace input text path with [font=courier new,courier,monospace][/font]{input}[font=courier new,courier,monospace][/font] variable
        (e.g. [-s, -S, --toc, --css=pandoc.css, --include-after-body=footer.html, {input}, --output={input}.html])
    + make sure every option is a JSON string
        (e.g. ["-s", "-S", "--toc", "--css=pandoc.css", "--include-after-body=footer.html", "{input}", "--output={input}.html"])
    + give it a memorable name
    + determine if you want to automatically add your default options to the command or not. 

In order to make your templates more extensible, you can use any of 3 built-in
variables that relate to the file chosen to convert:
    * {input_file} = The full path to the file, including file extension
    * {input_name} = The full path to the file, without file extension
    * {input_dir} = The full path to the parent directory of the file

For example, this template would only work if you kept a project directory 
that contained both [font=courier new,courier,monospace]biblio.bib[/font] and [font=courier new,courier,monospace]chicago-author-date.csl[/font] alongside
your input file. 
    {
        "name": "Biblio Test",
        "use_defaults": false,
        "options": [
            "-s", 
            "-S",
            "--biblio={input_dir}/biblio.bib",
            "--csl={input_dir}/chicago-author-date.csl", 
            "{input_file}",
            "--output={input_name}.html"
        ]
    }
*/
[
{
    "name": "XeLaTeX PDF",
    "use_defaults": true,
    "options": [
        "-N",
        "--variable=mainfont:Georgia",
        "--variable=sansfont:Arial",
        "--variable=monofont:\"Andale Mono\"",
        "--variable=fontsize:12pt",
        "{input_file}",
        "--latex-engine=xelatex",
        "--toc",
        "--output={input_name}.pdf"
    ]
},
{
    "name": "Pandoc MD -> HTML",
    "use_defaults": true,
    "options": [
        "--toc",
        "--css=pandoc.css",
        "{input_file}", 
        "--output={input_name}.html"
    ]
}
]
Template Elements

As you can see, it comes with two "default" templates, as well as one commented-out template. These are there to help you see the format of the JSON as well as Pandoctor's unique features. As the default templates show, each template must have 3 keys:

  • name
  • use_defaults
  • options
The type of value for each of these is fixed. For name, you must use a string; for use_defaults, you use a Boolean (either true or false); and for options, you use a list/array of strings. The name parameter is simple; this is the name of your template (what will be displayed when you are asked to choose which template you want to use). The use_defaults parameter is fairly self-explanatory as well; do you want to automatically add the default options to this command or not? It is the options parameter where the magic happens, and this is the one that requires the most precision.

As the comments in the file will tell you, you need to properly format your Pandoc command for use as a Pandoctor template. This means, each option is its own item in the list and each option is without spaces (unless properly quoted). This will require you to use the "long" version of any option along with the an equals [=]. The 3 given examples give thorough demonstration of what acceptable templates can look like.

Template Variables

In addition to these formatting requirements, Pandoctor also gives you the ability to abstract your template properly. For any template, you have access to 3 variables:

  • {input_file} = The full path to the file, including file extension
  • {input_name} = The full path to the file, without file extension
  • {input_dir} = The full path to the parent directory of the file
These variables will allow you to properly use your template with any conversion. You will see that every template should use {input_file} and {input_name} for the input and output options respectively. In addition, if you specify any outside resource files, you can then use {input_dir} to ensure that the full path is properly constructed (see the "Biblio Test" example in the comments).

Running a Template Command

Once you set up a template, it will make using Pandoc so much easier.

All you have to do is select the file in Alfred's file navigator, choose the "Templated Pandoc Conversion" file action, and then choose which template you want to use. That's it.

>dr_temps.png

As with the New Conversion, the process takes a variable amount of time. Whenever the conversion does finish, however, you will see a notification in the top right of your screen:

>template_notify.png

Creating a Template

So, how do you set up template commands? As the Template Elements section describes, each template requires 3 things. So, in order to create a new template, you will need to create each of these 3 elements. Hopefully, however, Pandoctor makes this dead-simple to do.

To begin creating a new template, use the dr:temp:set keyword.

Setting Template Name

Type the keyword and then press return. This will immediately jump you to assigning a name for your new template. 

To assign a name, simply type the name of the template. As seen in the screenshot above, this name will be all that you will see in the Script Filter to choose which template you want to run. As an example, I created a new template called "Template Test":

>template_set_name.png

Setting Template Defaults

Once you finish typing your template name, hit return and Pandoctor will then automatically ask you if you want your Default Options to always be added to the template command:

>template_set_defs.png

If you select True, this means that whatever options your template command has, your assigned Default Options will be added to the final Pandoc command. For example, if you have set standalone to be a Default Option, regardless of whether or not you have that option in your template command, Pandoc will still create a standalong document. If, however, you select False, only the options you have in the template will be run through Pandoc.

Setting Template Command

The final element you need to add to create your new template is, of course, the actual Pandoc command.

As the section above described, Pandoctor requires your template command options to be in a very specific format. However, must Pandoc users don't actually type commands into Terminal in this format. In order to make Pandoctor as simple as possible, I have written a script that will convert the standard, short-form Pandoc command into the long-form Pandoctor compliant format. This means that all you have to do is copy your command from Terminal and paste it into this field:

>template_set_cmd.png

As it is currently implemented, there is the possibility of some bugs in the conversion process. This means it is in your best interest to double check the user_templates.json file in your workflow storage folder (you can open this folder easily using the dr:help keyword and selecting Storage). Ensure that the variables are properly used. Also ensure that the all of the short-form options where correctly translated into their long-form version. Remember, you can use the pandoc_templates.json file as a guide for the template JSON format.


I think that Pandoctor has a lot of power, and I hope it proves useful to you. For example, I wrote this entire README in Markdown and generated an HTML file using Pandoctor. If you have any problems, please let me know.

stephen

The Hackademic

Edited by smarg19
Link to comment
  • 2 weeks later...

UPDATE

Version 1.0.5 fixes a small bug in the template variables. Probably didn't effect anyone, but definently won't now.

Also, Pandoc 1.13 is now out. This is a major upgrade, which includes the .docx files as input files. This means you can convert Word files to Markdown files! Anyways, once you update pandoc, you will need to run dr:config again for Pandoctor to update its internals for the new version of pandoc. This will then show .docx in the inputs window, and will properly interface with Pandoc 1.13.

So, enjoy the newest versions of Pandoc and Pandoctor!

Link to comment
  • 1 month later...
  • 2 months later...

I'd like a built-in variable for the original file name without the full path so I can create a template to save in a different directory.

Can you elaborate a bit? Do you mean a variable as a part of the templating? In addition to the {input_path}, {input_name}, {input_dir} variables? That does make sense, I guess I would need to rename them tho:

  • {input_path_with_ext}
  • {input_path_without_ext}
  • {input_filename}
  • {input_parent_dir}

Would those four variables suffice for your needs?

- - -

FWIW, you can easily change the templating variables by editing the _format_template() method. Here is it's current state:

def _format_template(self, args):
    """Format the variables in a Template.
    """
    input_path = self._get_input_path()[0]
    input_name = os.path.splitext(input_path)[0]
    input_dir = os.path.dirname(input_path)
    for i, arg in enumerate(args):
        # Replace any and all variables with correct data
        arg = arg.replace('{input_file}', input_path)
        arg = arg.replace('{input_name}', input_name)
        arg = arg.replace('{input_dir}', input_dir)
        args[i] = arg
    return args

All you would need to do is add a new variable name and supply the proper value.

I say this because I plan on refactoring Pandoctor at some point, and will def make this addition then, but I can't say right now how soon that will be, so this will allow you to get the functionality you want without having to wait for me.

Edited by smarg19
Link to comment
  • 1 month later...
Pandoctor 1.0.5

 

Alfred 2.6 (374)
Starting debug for 'Pandoctor'


[ERROR: alfred.workflow.action.script] 10:51:12 pandoctor.py:1206 DEBUG    {u'<argument>': u'/Users/drlulz/Desktop/Untitled.md',
 u'<flag>': u'in_path',
 u'config': False,
 u'help': False,
 u'launch': False,
 u'run': False,
 u'search': False,
 u'store': True}
10:51:12 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
10:51:12 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/pandoc.cache
10:51:12 workflow.py:970 DEBUG    Cached data saved at : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
[ERROR: alfred.workflow.output.script] 10:51:12 pandoctor.py:1206 DEBUG    {u'<argument>': u'[path]',
 u'<flag>': u'pandoc_inputs',
 u'config': False,
 u'help': False,
 u'launch': True,
 u'run': False,
 u'search': False,
 u'store': False}
10:51:12 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
10:51:12 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/pandoc.cache
[STDERR: alfred.workflow.input.scriptfilter] 10:51:13 pandoctor.py:1206 DEBUG    {u'<argument>': u'markdown',
 u'<flag>': u'inputs',
 u'config': False,
 u'help': False,
 u'launch': False,
 u'run': False,
 u'search': True,
 u'store': False}
10:51:13 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
10:51:13 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/pandoc.cache
[ERROR: alfred.workflow.action.script] 10:51:15 pandoctor.py:1206 DEBUG    {u'<argument>': u'markdown',
 u'<flag>': u'in_format',
 u'config': False,
 u'help': False,
 u'launch': False,
 u'run': False,
 u'search': False,
 u'store': True}
10:51:15 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
10:51:15 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/pandoc.cache
10:51:15 workflow.py:970 DEBUG    Cached data saved at : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
[ERROR: alfred.workflow.output.script] 10:51:15 pandoctor.py:1206 DEBUG    {u'<argument>': u'',
 u'<flag>': u'pandoc_outputs',
 u'config': False,
 u'help': False,
 u'launch': True,
 u'run': False,
 u'search': False,
 u'store': False}
10:51:15 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
10:51:15 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/pandoc.cache
[STDERR: alfred.workflow.input.scriptfilter] 10:51:15 pandoctor.py:1206 DEBUG    {u'<argument>': u'',
 u'<flag>': u'outputs',
 u'config': False,
 u'help': False,
 u'launch': False,
 u'run': False,
 u'search': True,
 u'store': False}
10:51:15 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
10:51:15 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/pandoc.cache
[STDERR: alfred.workflow.input.scriptfilter] 10:51:16 pandoctor.py:1206 DEBUG    {u'<argument>': u'w',
 u'<flag>': u'outputs',
 u'config': False,
 u'help': False,
 u'launch': False,
 u'run': False,
 u'search': True,
 u'store': False}
10:51:16 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
10:51:16 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/pandoc.cache
[STDERR: alfred.workflow.input.scriptfilter] 10:51:16 pandoctor.py:1206 DEBUG    {u'<argument>': u'wi',
 u'<flag>': u'outputs',
 u'config': False,
 u'help': False,
 u'launch': False,
 u'run': False,
 u'search': True,
 u'store': False}
10:51:16 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
10:51:16 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/pandoc.cache
[STDERR: alfred.workflow.input.scriptfilter] 10:51:17 pandoctor.py:1206 DEBUG    {u'<argument>': u'wik',
 u'<flag>': u'outputs',
 u'config': False,
 u'help': False,
 u'launch': False,
 u'run': False,
 u'search': True,
 u'store': False}
10:51:17 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
10:51:17 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/pandoc.cache
[STDERR: alfred.workflow.input.scriptfilter] 10:51:17 pandoctor.py:1206 DEBUG    {u'<argument>': u'wiki',
 u'<flag>': u'outputs',
 u'config': False,
 u'help': False,
 u'launch': False,
 u'run': False,
 u'search': True,
 u'store': False}
10:51:17 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
10:51:17 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/pandoc.cache
[ERROR: alfred.workflow.action.script] 10:51:21 pandoctor.py:1206 DEBUG    {u'<argument>': u'mediawiki',
 u'<flag>': u'out_format',
 u'config': False,
 u'help': False,
 u'launch': False,
 u'run': False,
 u'search': False,
 u'store': True}
10:51:21 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
10:51:21 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/pandoc.cache
10:51:21 workflow.py:970 DEBUG    Cached data saved at : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
[ERROR: alfred.workflow.output.script] 10:51:21 pandoctor.py:1206 DEBUG    {u'<argument>': u'',
 u'<flag>': u'pandoc_options',
 u'config': False,
 u'help': False,
 u'launch': True,
 u'run': False,
 u'search': False,
 u'store': False}
10:51:21 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
10:51:21 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/pandoc.cache
[ERROR: alfred.workflow.input.scriptfilter] Code 1: 10:51:21 pandoctor.py:1206 DEBUG    {u'<argument>': u'',
 u'<flag>': u'options',
 u'config': False,
 u'help': False,
 u'launch': False,
 u'run': False,
 u'search': True,
 u'store': False}
10:51:21 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
10:51:21 workflow.py:940 DEBUG    Loading cached data from : /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/pandoc.cache
10:51:21 workflow.py:1275 ERROR    u'options'
Traceback (most recent call last):
  File "/Users/drlulz/Google Drive/MacBook/Alfred/Alfred.alfredpreferences/workflows/user.workflow.155F404E-339A-46A3-9025-93C99FEF4B1D/workflow/workflow.py", line 1273, in run
    func(self)
  File "pandoctor.py", line 1208, in main
    res = pd.run(args)
  File "pandoctor.py", line 355, in run
    return method()
  File "pandoctor.py", line 442, in search_codepath
    data = getattr(self.pandoc, prop, None)
  File "pandoctor.py", line 174, in options
    return self.data['options']KeyError: u'options'
Link to comment

Ok. TBH, Pandoctor's code base was/is slightly in flux. It appears that I have stored the Options data under a different name. To determine what that is, you need to open this file: /Users/drlulz/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/pandoc.cache

It is a pickled file, so opening it in a text editor like Sublime. Paste that text (it will look sort of like gobbedly gook) here. I'll check it out.

Link to comment

Paste that text (it will look sort of like gobbedly gook) here.

(dp0Voutputs
p1
(lp2
(dp3
Vdescription
p4
VPortable Document Format
p5
sVarg
p6
Vpdf
p7
sa(dp8
g4
Vnative Haskell
p9
sg6
Vnative
p10
sa(dp11
g4
VJSON version of native AST
p12
sg6
Vjson
p13
sa(dp14
g4
Vplain text
p15
sg6
Vplain
p16
sa(dp17
g4
Vpandoc\u2019s extended markdown
p18
sg6
Vmarkdown
p19
sa(dp20
g4
Voriginal unextended markdown
p21
sg6
Vmarkdown_strict
p22
sa(dp23
g4
VPHP Markdown extra extended markdown
p24
sg6
Vmarkdown_phpextra
p25
sa(dp26
g4
Vgithub extended markdown
p27
sg6
Vmarkdown_github
p28
sa(dp29
g4
VreStructuredText
p30
sg6
Vrst
p31
sa(dp32
g4
VXHTML 1
p33
sg6
Vhtml
p34
sa(dp35
g4
VHTML 5
p36
sg6
Vhtml5
p37
sa(dp38
g4
VLaTeX
p39
sg6
Vlatex
p40
sa(dp41
g4
VLaTeX beamer slide show
p42
sg6
Vbeamer
p43
sa(dp44
g4
VConTeXt
p45
sg6
Vcontext
p46
sa(dp47
g4
Vgroff man
p48
sg6
Vman
p49
sa(dp50
g4
VMediaWiki markup
p51
sg6
Vmediawiki
p52
sa(dp53
g4
VDokuWiki markup
p54
sg6
Vdokuwiki
p55
sa(dp56
g4
VTextile
p57
sg6
Vtextile
p58
sa(dp59
g4
VEmacs Org-Mode
p60
sg6
Vorg
p61
sa(dp62
g4
VGNU Texinfo
p63
sg6
Vtexinfo
p64
sa(dp65
g4
VOPML
p66
sg6
Vopml
p67
sa(dp68
g4
VDocBook
p69
sg6
Vdocbook
p70
sa(dp71
g4
VOpenDocument
p72
sg6
Vopendocument
p73
sa(dp74
g4
VOpenOffice text document
p75
sg6
Vodt
p76
sa(dp77
g4
VWord docx
p78
sg6
Vdocx
p79
sa(dp80
g4
VHaddock markup
p81
sg6
Vhaddock
p82
sa(dp83
g4
Vrich text format
p84
sg6
Vrtf
p85
sa(dp86
g4
VEPUB v2 book
p87
sg6
Vepub
p88
sa(dp89
g4
VEPUB v3
p90
sg6
Vepub3
p91
sa(dp92
g4
VFictionBook2 e-book
p93
sg6
Vfb2
p94
sa(dp95
g4
VAsciiDoc
p96
sg6
Vasciidoc
p97
sa(dp98
g4
VInDesign ICML
p99
sg6
Vicml
p100
sa(dp101
g4
VSlidy HTML and javascript slide show
p102
sg6
Vslidy
p103
sa(dp104
g4
VSlideous HTML and javascript slide show
p105
sg6
Vslideous
p106
sa(dp107
g4
VDZSlides HTML5 + javascript slide show
p108
sg6
Vdzslides
p109
sa(dp110
g4
Vreveal.js HTML5 + javascript slide show
p111
sg6
Vrevealjs
p112
sa(dp113
g4
VS5 HTML and javascript slide show
p114
sg6
Vs5
p115
sasVinputs
p116
(lp117
(dp118
Vdescription
p119
Vnative Haskell
p120
sVarg
p121
Vnative
p122
sa(dp123
g119
VJSON version of native AST
p124
sg121
Vjson
p125
sa(dp126
g119
Vpandoc\u2019s extended markdown
p127
sg121
Vmarkdown
p128
sa(dp129
g119
Voriginal unextended markdown
p130
sg121
Vmarkdown_strict
p131
sa(dp132
g119
VPHP Markdown Extra extended markdown
p133
sg121
Vmarkdown_phpextra
p134
sa(dp135
g119
Vgithub extended markdown
p136
sg121
Vmarkdown_github
p137
sa(dp138
g119
VTextile
p139
sg121
Vtextile
p140
sa(dp141
g119
VreStructuredText
p142
sg121
Vrst
p143
sa(dp144
g119
VHTML
p145
sg121
Vhtml
p146
sa(dp147
g119
VDocBook
p148
sg121
Vdocbook
p149
sa(dp150
g119
Vtxt2tags
p151
sg121
Vt2t
p152
sa(dp153
g119
Vdocx
p154
sg121
Vdocx
p155
sa(dp156
g119
VEPUB
p157
sg121
Vepub
p158
sa(dp159
g119
VOPML
p160
sg121
Vopml
p161
sa(dp162
g119
VEmacs Org-mode
p163
sg121
Vorg
p164
sa(dp165
g119
VMediaWiki markup
p166
sg121
Vmediawiki
p167
sa(dp168
g119
VTWiki markup
p169
sg121
Vtwiki
p170
sa(dp171
g119
VHaddock markup
p172
sg121
Vhaddock
p173
sa(dp174
g119
VLaTeX
p175
sg121
Vlatex
p176
sas.
Link to comment

It looks like the dr:config didn't work fully. You only have outputs and inputs here. You should also have options and arg-options. Delete this file. Then re-run dr:config. Have the debugger on with "Interesting Information". As a quick check if the second run did something more, look at the file size before you delete and the file size after dr:config is re-run. If bigger, then try to convert again. If the same, post the debug output here.

Link to comment

Possibly you should require an IQ test on certain workflows. Maybe a secret sub-forum where people like me can't access. 

 

In my haste I forgot to install pandoc. I guess I thought it was a web service, I'm not sure what I was thinking. Apologies.

Edited by DrLulz
Link to comment

Possibly you should require an IQ test on certain workflows. Maybe a secret sub-forum where people like me can't access. 

 

In my haste I forgot to install pandoc.

Haha. If you knew how many times I've done stuff like that you'd realize why I can't require an IQ for workflows; I wouldn't be able to use them myself :)

Glad you figured it out tho. And TBH, this will help me to deal with this problem when it (inevitably) occurs again.

Pandoc is wonderful and powerful. And if you really start to use it, you should honestly check out my blog post on this workflow, where I explain Templated Commands, which are the real power-user feature of the workflow (the GUI for one-off conversions is the "normal" use case) as well as my Pandoc Templates (on GitHub). I have a nice Word DOCX template and a CSS file so that you can preview in Marked. With templated commands and the reference.docx file, I've basically got my pandoc workflow down to one step (run the Pandoctor templated command).

Link to comment
  • 4 months later...

error message when trying to configure Pandoctor:

 

I also get the error message: <?xml version="1.0" encoding=

when I try to configure pandoctor.

 

pandoc 1.14.0.1 is installed on the computer.

pandoc works fine from the terminal but pandoctor does not. 

 

Here  ist the debug log: 

 

[ERROR: alfred.workflow.action.script] 21:00:21 pandoctor.py:1206 DEBUG    {u'<argument>': None,

 u'<flag>': None,
 u'config': True,
 u'help': False,
 u'launch': False,
 u'run': False,
 u'search': False,
 u'store': False}
21:00:21 workflow.py:940 DEBUG    Loading cached data from : /Users/j********/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache
21:00:22 workflow.py:1275 ERROR    'NoneType' object has no attribute 'read'
Traceback (most recent call last):
  File "/Users/j********/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.60CECC29-7BBE-4EE5-B5FC-C222BEEEFC55/workflow/workflow.py", line 1273, in run
    func(self)
  File "pandoctor.py", line 1208, in main
    res = pd.run(args)
  File "pandoctor.py", line 355, in run
    return method()
  File "pandoctor.py", line 429, in config_codepath
    self.pandoc.config()
  File "pandoctor.py", line 121, in config
    self.store('pandoc', 'outputs', self._formats('output'))
  File "pandoctor.py", line 226, in _formats
    lines = req.text.splitlines()
  File "/Users/j*******/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.60CECC29-7BBE-4EE5-B5FC-C222BEEEFC55/workflow/web.py", line 220, in text
    return self.content
  File "/Users/j********/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.60CECC29-7BBE-4EE5-B5FC-C222BEEEFC55/workflow/web.py", line 205, in content
    self._content = self.raw.read()
AttributeError: 'NoneType' object has no attribute 'read'
Link to comment
  • 3 months later...

I've got into trouble, please help

 

My pandoctor stopped working. 

Whenever I try to start conversion on file it gives me:

Error in workflow

'NoneType' object has no attribute '__getitem__'. 

 

Video

Log file

 

I tried deleting workflow from alfred and installing a new one from packal but It didn't help :(

any ideas? 

Edited by 40-02
Link to comment
  • 3 months later...
  • 7 months later...

Pandoc works OK in Terminal, not from Alfred.

 

Debug information:

`

Starting debug for 'Pandoctor'

 

[2016-09-26 15:25:08][ERROR: action.script] 15:25:08 pandoctor.py:1206 DEBUG    {u'<argument>': u'/Users/jeremycherfas/Dropbox/Trust/trust-genebank-platform/Drafts/About/about-04.md',

 u'<flag>': u'in_path',

 u'config': False,

 u'help': False,

 u'launch': False,

 u'run': False,

 u'search': False,

 u'store': True}

15:25:08 workflow.py:940 DEBUG    Loading cached data from : /Users/jeremycherfas/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache

15:25:08 workflow.py:970 DEBUG    Cached data saved at : /Users/jeremycherfas/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache

[2016-09-26 15:25:14][ERROR: action.script] 15:25:10 pandoctor.py:1206 DEBUG    {u'<argument>': u'[path]',

 u'<flag>': u'pandoc_inputs',

 u'config': False,

 u'help': False,

 u'launch': True,

 u'run': False,

 u'search': False,

 u'store': False}

15:25:10 workflow.py:940 DEBUG    Loading cached data from : /Users/jeremycherfas/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.pandoctor/runner.cache

`

 

Any clue as to how I can fix this?

 

Thanks.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...