pystitch / stitch

Write reproducible reports in Markdown
https://pystitch.github.io
MIT License
441 stars 13 forks source link

list indices must be integers or slices, not str #58

Open lincolnfrias opened 7 years ago

lincolnfrias commented 7 years ago

Even when I try to convert an empty .md t o .html, I get:

Traceback (most recent call last):
  File "/home/lincoln/anaconda3/bin/stitch", line 11, in <module>
    sys.exit(cli())
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/stitch/cli.py", line 60, in cli
    convert(input_text, to, output_file=output_file, extra_args=extra_args)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/stitch/stitch.py", line 476, in convert
    result = stitcher.stitch(source)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/stitch/stitch.py", line 236, in stitch
    version = ast['pandoc-api-version']
TypeError: list indices must be integers or slices, not str 

Bu the way, thanks a lot for the library. Coming from R to python, Rmarkdown is the thing I miss the most!

springcoil commented 7 years ago

I had an error like this but it was fixed by reinstalling from conda-forge pandoc.

I then had to install some Latex fonts to get this to work.

lincolnfrias commented 7 years ago

Thanks @springcoil, but after reinstalling from conda-forge pandoc, I get this new message, about RuntimeError:

Traceback (most recent call last):
  File "/home/lincoln/anaconda3/bin/stitch", line 11, in <module>
    sys.exit(cli())
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/lincoln/anaconda3/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/click/core.py", line 86, in augment_usage_errors
    yield
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/stitch/cli.py", line 60, in cli
    convert(input_text, to, output_file=output_file, extra_args=extra_args)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/stitch/stitch.py", line 480, in convert
    outputfile=output_file)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/pypandoc/__init__.py", line 103, in convert_text
    outputfile=outputfile, filters=filters)
  File "/home/lincoln/anaconda3/lib/python3.5/site-packages/pypandoc/__init__.py", line 325, in _convert_input
    'Pandoc died with exitcode "%s" during conversion: %s' % (p.returncode, stderr)
RuntimeError: Pandoc died with exitcode "67" during conversion: b'pandoc: Could not fetch css/style.css\ncss/style.css: openBinaryFile: does not exist (No such file or directory)\n'
TomAugspurger commented 7 years ago

Sorry about the painful install right now, pandoc just had a release that broke some things for pypandoc & stitch.

What is the output of pandoc --version? Ideally it's 1.18 or newer.

And `python -c 'import stitch; print(stitch.version)'? It should be 0.4.1;

Finally python -c 'import pypandoc; print(pypandoc.__version__)' should be 1.3.3+

lincolnfrias commented 7 years ago

My versions are exactly those (1.18, 0.4.1 and 1.3.3).

I am not in a hurry, I can wait for the fixes for the new pandoc release.
Thanks for your attention, @TomAugspurger.

TomAugspurger commented 7 years ago

Strange. Could you paste the command you're running from the terminal? And if you recall, could you say how you installed stitch? I don't know why it wouldn't be finding the CSS file. Also, does     stitch foo.md -t json  where foo.md is that empty markdown file?

    _____________________________

From: lincolnfrias notifications@github.com Sent: Thursday, November 24, 2016 13:24 Subject: Re: [pystitch/stitch] list indices must be integers or slices, not str (#58) To: pystitch/stitch stitch@noreply.github.com Cc: Tom Augspurger thomas-augspurger@uiowa.edu, Mention mention@noreply.github.com

My versions are exactly those (1.18, 0.4.1 and 1.3.3).

I am not in a hurry, I can wait for the fixes for the new pandoc release. Thanks for your attention, @TomAugspurger.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

lincolnfrias commented 7 years ago

The command I am running is stitch foo.md -o foo.html. I installed stitch with pip install knotr. And stitch foo.md -t json gives me:

{"blocks":[{"t":"Para","c":[{"t":"Str","c":"a"}]}],"pandoc-api-version":[1,17,0,4],"meta":{}}

gglanzani commented 7 years ago

I'm getting the same CSS error here, when trying to do things with reveal.js

My fix was to download reveal.js so that pandoc can find the css file, e.g.

ex_revealjs.md
css/
   reveal.css
   theme/
      beige.css
....

Edit: js/lib/plugin from reveal should also be linked.

TomAugspurger commented 7 years ago

Thanks @gglanzani, good catch.

It'd be nice to update this example with the directory structure. I have

I have

src/ex_revealjs.txt  # the example
revealjs.html  # the template
reveal.js/  # the git repo
  # relevant bits
  css/
    reveal.css  
  lib/
    css/zenburn.css
    js/head.min.js
  js/
    reveal.js

And run it with

stitch src/ex_revealjs.txt -o ex_revealjs.html -t html5 \                                                                                                           
    --template=revealjs.html --standalone \
    --variable theme="beige" \
    --section-divs

It seems pandoc removed the --no-highlight option. I'll put it on my todo, unless someone beats me to it (doc build is a bit complicated ATM).

dorianbrown commented 6 years ago

Hey @gglanzani, funny seeing you here!

For future users, pandoc 1.19.1 was giving me issues, but upgrading to the newest version (2.2.1) solved the RuntimeError: Pandoc died with exitcode "67" during conversion: b'pandoc: Could not fetch css/style.css\ncss/style.css: openBinaryFile: does not exist errors.