ptsefton / chordprobook

Script to convert collections of chordpro format song charts to PDF, HTML, and word processing doc formats
Other
29 stars 4 forks source link

Docx output fails #29

Closed lpinner closed 6 years ago

lpinner commented 6 years ago

Trying to output to docx (one of my songs needed a little bit of additional formatting)

$ ./mksong -w samples/AmazingGrace.cho.txtTraceback (most recent call last):
  File "./mksong", line 121, in <module>
    convert()
  File "./mksong", line 109, in convert
    pypandoc.convert(book.to_md(), "docx", format="md", outputfile=word_path, extra_args=xtra)
NameError: name 'pypandoc' is not defined

Editing mksong to import pypandoc and re-running then outputs an empty songbook.docx

When pypandoc.convert(book.to_md(), etc...) is called, all the song.md properties are an empty string '' because song/self.format() has not been called. i.e. in init.py:

   def to_md(self):
        """ Generate Markdown version of a book """
        md = "---\ntitle: %s\n---\n" % self.title
        for song in self.songs:
            md += song.md  #<------ song.md is empty, has never been populated by song.format()
        return md

I assume the same issues apply to epub, but haven't tested.

ptsefton commented 6 years ago

Sorry about that - haven't used that bit for ages. I'll take a look as soon as I get a chance.

lpinner commented 6 years ago

It's not a big issue, more of a "for info". I only stumbled across it because of one song. I've happily been converting many many more to PDF for myself and band mates.