Giter Club home page Giter Club logo

kitabu's Introduction

kitabu

Tests Gem Gem MIT License

Kitabu is a framework for creating e-books from Markdown using Ruby. Using Prince PDF generator, you'll be able to get high quality PDFs. Also supports EPUB, Mobi, and HTML generation.

While Prince is too expensive (495USD for a single user license), the free version available at http://www.princexml.com/download generates a PDF with a small logo on the first page, which is removed when sent to a printer; you can use it locally for viewing the results immediately. When you're done writing your e-book, you can use DocRaptor, which have plans starting at $15/mo.

Features

  • Write using Markdown
  • Book layout support
  • Syntax highlight
  • Generate HTML, PDF, e-Pub (version 3.3), and Mobi
  • Table of Contents automatically generated from chapter titles

Installation

To install Kitabu, you'll need a working Ruby 3.2+ installation. If you're cool with it, just run the following command to install it.

gem install kitabu

After installing Kitabu, run the following command to check your external dependencies.

$ kitabu check

Prince XML: Converts HTML files into PDF files.
Installed.

Calibre's ebook-convert: Converts ePub e-books into .mobi files.
Installed.

There are no hard requirements here; just make sure you cleared the correct dependency based on the formats you want to export to.

Usage

To create a new e-book, just run

$ kitabu new mybook

This command creates a directory mybook with the following structure:

.
├── Gemfile
├── Gemfile.lock
├── Guardfile
├── assets
│   ├── fonts
│   ├── images
│   │   ├── cover.png
│   │   ├── kitabu.svg
│   │   ├── markdown.svg
│   │   └── up.svg
│   ├── scripts
│   └── styles
│       ├── epub.css
│       ├── html.css
│       ├── pdf.css
│       ├── print.css
│       └── support
│           ├── kitabu.css
│           ├── normalize.css
│           ├── notes.css
│           └── toc.css
├── config
│   ├── helpers.rb
│   ├── kitabu.yml
│   └── locales
│       └── en.yml
├── templates
│   ├── epub
│   │   ├── cover.erb
│   │   ├── page.erb
│   │   └── toc.erb
│   └── html
│       └── layout.erb
└── text
    ├── 01_Getting_Started.md
    ├── 02_Creating_Chapters.md
    ├── 03_Syntax_Highlighting.md.erb
    ├── 04_Dynamic_Content.md.erb
    ├── 05_Exporting_Files.md
    └── 06_Changelog.md

13 directories, 28 files

The config/kitabu.yml file holds some information about your book; so you'll always change it.

The generated structure is actually a good example. So make sure you try it!

Kitabu - Sample Book

There's a generated sample available on the attachments directoryPDF / EPUB / MOBI / HTML.

Now it's time to write your e-book. All your book content will be placed on the text directory. Kitabu requires you to separate your book into chapters. A chapter is nothing but a directory that holds lots of text files. The e-book will be generated using every folder/file alphabetically. So be sure to use a sequential numbering as the name. Here's a sample:

* text
  * 01_Introduction
    * 01_introduction.md
  * 02_What_is_Ruby_on_Rails
    * 01_MVC.md
    * 02_DRY.md
    * 03_Convention_Over_Configuration.md
  * 03_Installing_Ruby_on_Rails
    * 01_Installing.md
    * 02_Mac_OS_X_instructions.md
    * 03_Windows_instructions.md
    * 04_Ubuntu_Linux_instructions.md

If you prefer, you can add a chapter per file:

* text
  * 01_Introduction.md
  * 02_What_is_Ruby_on_Rails.md
  * 03_Installing_Ruby_on_Rails.md

You'll want to see your progress eventually; it's time for you to generate the book PDF. Just run the command kitabu export and your book will be created on the output directory.

Kitabu can generate a Table of Contents (TOC) based on your h1-h6 tags. To print the TOC, you need to print a variable called toc, using the eRb tag.

<%= toc %>

Frontmatter

Markdown files (and their .md.erb counterparts) support frontmatter, a section that can inject variables to the page. Notice that the contents inside the --- delimiters must be valid YAML annotation and only basic types can be used (booleans, numbers, strings, nils and hashes/arrays with these same types).

Right now there's only one special value called section, which defines the class section when generating files. This allows you to have files inside your text directory that doesn't necessarily should have styling like regular chapters. For instance, this is how you can define a changelog section:

---
section: changelog
---

## Changelog

### Jan 26, 2024

- Initial release

Note

Notice that section will be retrieved from the first file, even if you have multiple files defining a section with a directory.

This meta data will be inject on your template using the variable meta. If you have other variables, you could print them as <%= meta["varname"] %>.

Using ERB

You can also have .md.erb files. You can mix Markdown and HTML, like the following:

## This the chapter title

<%= image_tag "myimage.png" %>

The above content must be placed in a .md.erb file. The generated content will be something like this:

<img src="images/myimage.png" />

You book's helpers can be added to config/helpers.rb, as this file is loaded automatically by kitabu.

You can see available helpers on https://github.com/fnando/kitabu/blob/main/lib/kitabu/helpers.rb.

Syntax Highlighting

To highlight code, use fenced code blocks.

``` ruby
class User < ActiveRecord::Base
  validates_presence_of :login, :password, :email
  validates_uniqueness_of :login, :email
end
```

You can even provide options:

```php?start_line=1&line_numbers=1
echo "Hello World";
```
  • We use Redcarpet for Markdown processing.
  • We use Rouge for syntax highlighting.

The following Redcarpet options are enabled:

  • autolink
  • fenced_code_blocks
  • footnotes
  • hard_wrap
  • highlight
  • no_intra_emphasis
  • safe_links_only
  • space_after_headers
  • strikethrough
  • superscript
  • tables

Hooks

There are a few hooks that allows manipulating the content. You can use before_render and after_render to process the Markdown content. You can add such hooks to your config/helpers.rb file.

Kitabu::Markdown.add_hook(:before_render) do |content|
  # manipulate content and return it.
  content
end

Kitabu::Markdown.add_hook(:after_render) do |content|
  # manipulate content and return it.
  content
end

Using custom fonts

You can use custom fonts on your ebooks. Just add them to the fonts directory (you can create this directory on your book's root directory if it doesn't exist).

Then, on assets/styles/support/fonts.css you can add the @font-face declaration.

@font-face {
  font-family: "Open Sans Condensed Bold";
  src: url("../../fonts/OpenSans-CondBold.ttf");
}

Finally, to use this font, do something like this:

.chapter > h1 {
  font-family: "Open Sans Condensed Bold";
}

Instead of doing the above manually, you can also use Prince's --scanfonts option.

$ prince --scanfonts assets/fonts/* > assets/styles/support/fonts.css

Just remember to replace the generated path to be something like ../../fonts instead.

Tip

In most cases, it's easier to redefine sans-serif, serif and monospace fonts. To know more about how to do this, read Prince's Redefining the generic font families documentation.

If you're unsure if fonts are actually being used on PDF files, use the environment variable PRINCEOPT to disable system fonts.

$ PRINCEOPT='--no-system-fonts --debug --log output/prince.log' kitabu export --only pdf
=> e-book couldn't be exported

$ tail -n10 output/prince.log
Sat Jan 27 18:39:10 2024: debug: font request: Caslon, serif
Sat Jan 27 18:39:10 2024: warning: Ensure fonts are available on the system or load them via a @font-face rule.
Sat Jan 27 18:39:10 2024: warning: For more information see:
Sat Jan 27 18:39:10 2024: warning: https://www.princexml.com/doc/help-install/#missing-glyphs-or-fonts
Sat Jan 27 18:39:10 2024: internal error: Unable to find any available fonts.
Sat Jan 27 18:39:10 2024: finished: failure
Sat Jan 27 18:39:10 2024: ---- end

Configuring Markdown

Kitabu uses Redcarpet as the Markdown engine. You can override the default processor by setting Kitabu::Markdown.processor. This can be done by adding something like the following to config/helpers.rb:

Kitabu::Markdown.processor = Redcarpet::Markdown.new(
  Kitabu::Markdown::Renderer.new(hard_wrap: false, safe_links_only: true),
  tables: true,
  footnotes: true,
  space_after_headers: true,
  superscript: true,
  highlight: true,
  strikethrough: true,
  autolink: true,
  fenced_code_blocks: true,
  no_intra_emphasis: true
)

The above options are Kitabu's defaults.

Exporting PDFs using DocRaptor

If you're not planning to buy PrinceXML, consider using DocRaptor. Here's how you can easily do it:

curl -H "Content-Type:application/json" -d'{"user_credentials":"YOUR_CREDENTIALS_HERE", "doc":{"name":"kitabu.pdf", "document_type":"pdf", "test":"false", "document_url":"https://example.com/output/kitabu.pdf.html"}}' http://docraptor.com/docs > kitabu.pdf

References

Legal Notes

Maintainer

Contributors

Contributing

For more details about how to contribute, please read https://github.com/fnando/kitabu/blob/main/CONTRIBUTING.md.

License

The gem is available as open source under the terms of the MIT License. A copy of the license can be found at https://github.com/fnando/kitabu/blob/main/LICENSE.md.

Code of Conduct

Everyone interacting in the kitabu project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

kitabu's People

Contributors

alindeman avatar arthurgeek avatar cndreisbach avatar coredump avatar dependabot[bot] avatar elomarns avatar fnando avatar hugobarauna avatar jstorimer avatar maurogeorge avatar pothix avatar trevorbramble avatar williamn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kitabu's Issues

Missing runtime dependencies

vagrant@precise32:~$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [i686-linux]
vagrant@precise32:~$ kitabu check
/usr/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- zip/zip (LoadError)
    from /usr/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/eeepub-with-cover-support-0.8.8/lib/eeepub/ocf.rb:1:in `<top (required)>'
    from /usr/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/eeepub-with-cover-support-0.8.8/lib/eeepub.rb:3:in `<top (required)>'
    from /usr/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/kitabu-1.0.5/lib/kitabu.rb:3:in `<top (required)>'
    from /usr/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/kitabu-1.0.5/bin/kitabu:4:in `<top (required)>'
    from /usr/bin/kitabu:23:in `load'
    from /usr/bin/kitabu:23:in `<main>'

Don't add left padding to both `pre` and `pre code`

The first line of each of my code blocks is indented too far. It looks like this:

markdown_code_html_output

when it should look like this:

markdown_code_html_output_corrected

The root issue here is that Markdown specifies that code blocks come out looking like this:

<pre><code>This is a code block.
</code></pre>

as opposed to this:

<pre><code>
This is a code block.
</code></pre>

The lack of a linebreak causes weirdness. This isn't Kitabu's fault and shouldn't be solved by you; I've got a question about it here:

http://stackoverflow.com/questions/17574489/does-any-markdown-parser-allow-adding-a-linebreak-to-the-start-of-code-blocks

However, one way I can make it look OK is to NOT apply left padding to pre code elements. If I change your layout.css from this:

pre, pre code {
    font-size: 8pt;
    line-height: 1.4;
    padding-left: 25pt;
}

to this:

pre, pre code {
    font-size: 8pt;
    line-height: 1.4;
}

pre {
    padding-left: 25pt;
}

... it looks correct.

The code element really doesn't need left padding anyway, since its parent pre already has it.

Do you see any problem with making this style change?

Totally Confused!

So when I do a gem install kitabu, and then kitabu export command, it blows chunks due to some code no longer supported in ActiveSupport.

Specifically, the normalize function in String. The OLD code is present in tagged version 2.1 which is what we get when we install. That code is old and bugs out.

So the new code in main is perfect, but we do not get that with gem install. What is the secret sauce to getting the new code when using gem install?

So version 2.1, lib/kitabu/extensions/string has this old code, which we get with gem install kitabu.

    str = ActiveSupport::Multibyte::Chars.new(self.dup)
    str = str.normalize(:kd).gsub(/[^\x00-\x7F]/,'').to_s

But when we see the main branch, we see that code was already all fixed up.

str = dup.unicode_normalize(:nfkd)
str = str.gsub(/[^\x00-\x7F]/, "").to_s

So when I am at my command line, and I want the main branch of kitabu to be my daily driver, what do I use for the install so I do not get the older tagged version?

I downloaded the repository, did a bundle install, and tried a build, but it bombed as it was missing rubocop. So I added rucocop to the gemspec, and then finally bundle exec rake build which gave me the kitabu gem built with the latest code, so I could install it. Seems like a lot of work for something that could just be gem install kitabu

Show Word Count

Most writers take the book's total word count in consideration when publishing. I have a target word count range to meet, but it's a lot of work to know what's my current word count if I have more than 30 different text files.

It would be nice if kitabu export would show my word count. It doesn't have to be anything fancy, it would be nice a simple word count like:

"Lorem lorem lorem".split.size

And then the total shows up on the console as:

"Total word count: 3"

epub

Hi,
what about generation of epub documents? Is it possible to add this option to future releases?

undefined method `+' for nil:NilClass

On Mac OS X 10.6.1, with the 0.4.4 gem built locally (because github isn't building gems right now), after doing

kitabu mypdf

and creating some markdown files in text/, doing

rake pdf

gives the following trace:

Iolar mypdf $ rake --trace pdf
(in /Users/kjhealy/temp/kitabu/mypdf)
** Invoke pdf (first_time)
** Invoke html (first_time)
** Execute html
rake aborted!
undefined method `+' for nil:NilClass
/Library/Ruby/Gems/1.8/gems/kitabu-0.4.4/lib/kitabu/base.rb:164:in `generate_html'
/Library/Ruby/Gems/1.8/gems/kitabu-0.4.4/lib/kitabu/base.rb:140:in `each'
/Library/Ruby/Gems/1.8/gems/kitabu-0.4.4/lib/kitabu/base.rb:140:in `generate_html'
/Library/Ruby/Gems/1.8/gems/kitabu-0.4.4/lib/kitabu/base.rb:121:in `each'
/Library/Ruby/Gems/1.8/gems/kitabu-0.4.4/lib/kitabu/base.rb:121:in `generate_html'
/Library/Ruby/Gems/1.8/gems/kitabu-0.4.4/lib/kitabu/tasks.rb:34
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

incompatible encoding regexp match

I'm running Windows 7 and Ruby 1.9.2-p290. Installed kitabu using gem install kitabu
I created a file structure and a few markdown files, nothing special. However this is what I get when trying to generate a pdf:

rake aborted! incompatible encoding regexp match (Windows-31J regexp with IBM437 string)

thanks for the awesome app, hopefully we can sort this out.

Fails to create new book on Ubuntu 12.04, missing activesupport

Hello, I tried creating a new book but it does not work..

System running on Ubuntu 12.04. Install of activesupport is successful, but still fails to work.

Dump:

joel@JOEL-UBUNTU-U36JC:~/Desktop$ kitabu new mybook
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- activesupport (LoadError)
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /var/lib/gems/1.9.1/gems/fnando-kitabu-0.3.10/lib/kitabu.rb:8:in `<top (required)>'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /var/lib/gems/1.9.1/gems/fnando-kitabu-0.3.10/bin/kitabu:4:in `<top (required)>'
    from /usr/local/bin/kitabu:23:in `load'
    from /usr/local/bin/kitabu:23:in `<main>'

Weird TOC on Epub and Mobi

My interest is in making a book in Mobi format. The sample book renders to HTML, Epub and Mobi, but the TOC in the latter two contains lots of text from each page. , which

I tracked it down to 390eed1 - lib/kitabu/exporter/epub.rb - the selector on line 132 seems to match too many elements on the page. I edited the gem and changed that selector back to the previous one, and it generates a minimal but improved TOC, which looks much better in the Kindle app.

Prince

Hi, more a question than an issue.

Why is prince used? Is it so much better than say prawn?
Sincerely asking because the price of prince is ridiculously high for me and I would like to use pdfs without printing so the watermark is also a no-no.

Anyway I have forked the repo and will experiment in the coming weeks.

regards, fede

about i18n

Hi again,

Got my first short ebook out today.

Now, I could go and hack on kitabu's code, but I was wondering if you had something ready to support a simple subtree when generating the book.
for example:

text
-- en
-- folders for my book in English
-- fr
-- folders for my book in French.

This way it is easy to edit the same book for different languages.

Any suggestion ?

No Rakefile created when new project generated

Hi,

I followed the instructions over at #13 and have managed to get Kitabu running on OS X. Running kitabu new bookproject generates a book project, but contrary to the information provided at http://fnando.github.com/public/kitabu.html no Rakefile is created in the project directory. This of course means I can't generate a PDF as otherwise documented:

$ rake pdf
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)

(See full trace by running task with --trace)

When I run kitabu --help I see:

Tasks:
kitabu export [OPTIONS] # Export e-book
kitabu help [TASK] # Describe available tasks or one specific task
kitabu new EBOOK_PATH # Generate a new e-book structure
kitabu permalinks # List title permalinks
kitabu syntaxes # List available syntaxes
kitabu themes # List available themes
kitabu version # Prints the Kitabu's version information

So how do I generate a PDF, or even HTML for that matter?

Jason

sample pdf output

Hey guys, the library looks awesome. One thing for the wishlist: you guys have the example directory, but can you also provide the resulting PDF? That way, we don't have to install, build, and run before we see what comes out!

Chapters begin counting on 2

I've started a project with Kitabu, and when I exported it, the first chapter was listed as "Chapter 2" instead of "Chapter 1". To be sure I wasn't doing anything wrong, I've created another project, and exported it right away, and the same ocurred: the sample chapter was listed as "Chapter 2".

Tweaking on Firebug, I've found the problem may be on default layout.css (line 121):

/* =========== */
/* = CHAPTER = */
/* =========== */
#chapters {
    counter-reset: page 1;
    counter-reset: chapter 1;
    page-break-before: always;
}

When I've changed the line 121 to "counter-reset: chapter;" (I've just remove the blank space and the "1" character") the chapters was numbered as expected.

I would do a pull request, but I'm not sure I'm not breaking nothing.

Create a decent layout

The default layout needs to be improved. It's breaking the sidebar bookmark and has tons of blank and useless pages.

Footnote Placement

I'm looking at Kitabu for book self-publication. The book I'm using for the evaluation has a number of footnotes. I like what you did with footnotes in Blackcloth, but this is already marked up in Markdown.

When I create the book, the footnotes show up as endnotes to the section (next h# tag), rather than true footnotes. When I rename the file to .textile and add the %{} bookmark markup, the footnotes show up as footnotes. Can you post-proc for %{} for Markdown-based? (I can probably fork & push.)

I would submit that there should also be a way to request endnote v. footnote.

Can I use kitabu and prince in windows?

After I installed kitabu in my win10 , and the path of prince was added to the environment variable of PATH. But when I ran the command of kitabu check, it showed the error:

E:/mywamp/ruby-2.0.0-p645-i386-mingw32/lib/ruby/gems/2.0.0/gems/rouge-1.9.1/lib/rouge/lexers/shell.rb:20: warning: already initialized constant Rouge::Lexers::Shell::KEYWORDS
E:/mywamp/ruby-2.0.0-p645-i386-mingw32/lib/ruby/gems/2.0.0/gems/rouge-1.9.1/lib/rouge/lexers/shell.rb:20: warning: previous definition of KEYWORDS was here
E:/mywamp/ruby-2.0.0-p645-i386-mingw32/lib/ruby/gems/2.0.0/gems/rouge-1.9.1/lib/rouge/lexers/shell.rb:25: warning: already initialized constant Rouge::Lexers::Shell::BUILTINS
E:/mywamp/ruby-2.0.0-p645-i386-mingw32/lib/ruby/gems/2.0.0/gems/rouge-1.9.1/lib/rouge/lexers/shell.rb:25: warning: previous definition of BUILTINS was here
E:/mywamp/ruby-2.0.0-p645-i386-mingw32/bin/kitabu: No such file or directory - which prince
E:/mywamp/ruby-2.0.0-p645-i386-mingw32/bin/kitabu: No such file or directory - which kindlegen
E:/mywamp/ruby-2.0.0-p645-i386-mingw32/bin/kitabu: No such file or directory - which html2text
E:/mywamp/ruby-2.0.0-p645-i386-mingw32/lib/ruby/gems/2.0.0/gems/kitabu-2.0.4/lib/kitabu/cli.rb:70:in `block in check': undefined method `<<' for nil:NilClass (NoMethodError)
        from E:/mywamp/ruby-2.0.0-p645-i386-mingw32/lib/ruby/gems/2.0.0/gems/kitabu-2.0.4/lib/kitabu/cli.rb:68:in `each'
        from E:/mywamp/ruby-2.0.0-p645-i386-mingw32/lib/ruby/gems/2.0.0/gems/kitabu-2.0.4/lib/kitabu/cli.rb:68:in `check'
        from E:/mywamp/ruby-2.0.0-p645-i386-mingw32/lib/ruby/gems/2.0.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
        from E:/mywamp/ruby-2.0.0-p645-i386-mingw32/lib/ruby/gems/2.0.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
        from E:/mywamp/ruby-2.0.0-p645-i386-mingw32/lib/ruby/gems/2.0.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
        from E:/mywamp/ruby-2.0.0-p645-i386-mingw32/lib/ruby/gems/2.0.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
        from E:/mywamp/ruby-2.0.0-p645-i386-mingw32/lib/ruby/gems/2.0.0/gems/kitabu-2.0.4/bin/kitabu:5:in `<top (required)>'
        from E:/mywamp/ruby-2.0.0-p645-i386-mingw32/bin/kitabu:23:in `load'
        from E:/mywamp/ruby-2.0.0-p645-i386-mingw32/bin/kitabu:23:in `<main>'

Question about chapters in a single source file

Question: Does kitabu require each chapter to be a separate file? Is there any way (or interest) to support separating chapters based on the source text? (e.g. H2s)

Details:

I'm using kitabu to process a single markdown file created in a different application (Scrivener). This markdown is my entire book and uses ## to separate the different chapters. The TOC renders correctly but I noticed that the Prince CSS for .chapter wasn't getting applied (specifically the page-break-before). Upon digging into the generated HTML I found there was a #chapters element with a single .chapter div, with content for the 40 or so real chapters (## in the source).

<div id="chapters">
  <div class"chapter">
    <h2 id="first">First Chapter</h2>
    ....content...
    <h2 id="second">Second Chapter</h2>
    ....content...
  </div>
</div>

Picking through the source I was able to change TOC::HTML#normalize to add the .chapter class to each of my h2s which gave me the styling I needed but isn't semantically correct (one chapters element with one chapter element).

Picking through the source again, I found Parser::HTML#content (and #chapter_files) is where the chapter class is added but it looks like it's based on the chapter-per-file (or chapter-per-directory-with-many-files).

Ideally I'd want this to happen

(File text/export.md)

## First Chapter

This is the first chapter

## Second Chapter

And here is the second chapter
<div id="chapters">
  <div class"chapter">
    <h2 id="first">First Chapter</h2>
    <p>This is the first chapter</p>
  </div>
  <div class"chapter">
    <h2 id="second">Second Chapter</h2>
    <p>And here is the second chapter</p>
  </div>
</div>

unable to generate the sample pdf

Hi,

I've got this error when doing rake pdf:

steve@mbp wikipedia $ rake pdf
(in /Users/steve/code/kitabu/samples/wikipedia)
rake aborted!
undefined method `silence_warnings' for Kitabu::Syntax:Module

I did a project search and it didn't found any declaration of 'silence_warnings' method. Looks like it's not a method in your project, but if you use it you could be able to tell me where this method is? Kernel Module?

Thanks for help.

First line of code block is indented further than the others

Why is the first line of code blocks indented further than those that follow? This issue is evident even within the RailsGuides.pdf generated from the example project included with the download. For instance see page 11 of the generated RailsGuides.pdf.

I've seen this with other Markdown -> PDF generators but for the life of me can't figure out why it happens. Any ideas?

Allow Pygment options

I have a bunch of PHP code that I would like to have syntax highlighting; however, I normally don't show the entire file leaving off the start tag '<?php' causing highlighter to skip highlighting.

pygments.rb has an option for this which can be set using the option 'startinline':

In Kitabu's highlight.rb file this line:

Pygments.highlight(code, :lexer => language, :options => {:encoding => "utf-8", :startinline => true})

Fixes this for my particular case but it would be nice to be able to set options for example:

@@@ php startinline
public function indexAction() {
    echo 'Hello World!';
}
@@@

or something similar. Any ideas on how we could handle this since kitabu supports different syntax highlighters?

Questions about templates

The generator creates two template directories:

├── templates
│   ├── epub
│   │   ├── cover.erb
│   │   ├── cover.png
│   │   ├── page.erb
│   │   └── user.css
│   └── html
│       ├── layout.css
│       ├── layout.erb
│       ├── syntax.css
│       └── user.css

The html template directory is used for HTML and PDF output.

Is the epub template directory used to create the .epub and .mobi output?

Can I use a different layout.erb file for the .pdf output? That is, a layout.erb file for html and another layout.erb file for pdf. How do I do that?

Problem with Ruby 2.0

When I try to install the gem with Ruby 2.0.0 I get the error

ERROR: Error installing kitabu:
kitabu requires Ruby version ~> 1.9.

kitabu fails with thor 0.18.1

A new release of thor is out as of March 30, 2013 and kitabu fails.

$ ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.2.0]
$ gem list
*** LOCAL GEMS ***
activesupport (3.2.13)
builder (3.2.0)
bundler (1.3.4)
coderay (1.0.9)
eeepub-with-cover-support (0.8.7)
i18n (0.6.1)
kitabu (1.0.3)
listen (0.7.3)
multi_json (1.7.2)
nokogiri (1.5.9)
notifier (0.4.1)
rake (10.0.4)
rdiscount (2.0.7.1)
RedCloth (4.2.9)
rubygems-bundler (1.1.1)
rubyzip (0.9.9)
rvm (1.11.3.6)
thor (0.18.1)
$ kitabu --help
/Users/danielkehoe/.rvm/gems/ruby-1.9.3-p392@tutorials/gems/kitabu-1.0.3/lib/kitabu/cli.rb:12:in `initialize': undefined method `name' for nil:NilClass (NoMethodError)
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p392@tutorials/gems/thor-0.18.1/lib/thor.rb:359:in `new'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p392@tutorials/gems/thor-0.18.1/lib/thor.rb:359:in `dispatch'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p392@tutorials/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p392@tutorials/gems/kitabu-1.0.3/bin/kitabu:5:in `<top (required)>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p392@tutorials/bin/kitabu:19:in `load'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p392@tutorials/bin/kitabu:19:in `<main>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p392@tutorials/bin/ruby_noexec_wrapper:14:in `eval'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p392@tutorials/bin/ruby_noexec_wrapper:14:in `<main>'
$ gem uninstall thor
You have requested to uninstall the gem:
    thor-0.18.1
kitabu-1.0.3 depends on [thor (>= 0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  Y
Remove executables:
    thor
in addition to the gem? [Yn]  Y
Removing thor
Successfully uninstalled thor-0.18.1
$ gem install thor -v 0.17.0
Fetching: thor-0.17.0.gem (100%)
Successfully installed thor-0.17.0
1 gem installed
$ kitabu --help
Tasks:
  kitabu check             # Check if all external dependencies are installed
  kitabu export [OPTIONS]  # Export e-book
  kitabu help [TASK]       # Describe available tasks or one specific task
  kitabu new EBOOK_PATH    # Generate a new e-book structure
  kitabu permalinks        # List title permalinks
  kitabu stats             # Display some stats about your e-book
  kitabu version           # Prints the Kitabu's version information

Can't install gem

Howdy, just tried installing them gem and I'm getting an error when it's trying to build the native extensions. I didn't install the Oniguruma package since it was implied that it's optional.

tesla:Desktop rob$ sudo gem install fnando-kitabu
Password:
Building native extensions. This could take a while...
Building native extensions. This could take a while...
Building native extensions. This could take a while...
ERROR: Error installing fnando-kitabu:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for main() in -lonig... no
creating Makefile

make
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -Wall -c oregexp.c
oregexp.c:2:23: error: oniguruma.h: No such file or directory
oregexp.c:9: error: expected specifier-qualifier-list before ‘regex_t’
oregexp.c: In function ‘oregexp_free’:
oregexp.c:16: warning: implicit declaration of function ‘onig_free’
oregexp.c:16: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c: In function ‘oregexp_allocate’:
oregexp.c:22: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c: At top level:
oregexp.c:27: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘’ token
oregexp.c:72: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘
’ token
oregexp.c:95: error: expected specifier-qualifier-list before ‘OnigRegion’
oregexp.c:99: warning: type defaults to ‘int’ in declaration of ‘UChar’
oregexp.c:99: error: expected ‘;’, ‘,’ or ‘)’ before ‘’ token
oregexp.c: In function ‘oregexp_initialize’:
oregexp.c:123: error: ‘UChar’ undeclared (first use in this function)
oregexp.c:123: error: (Each undeclared identifier is reported only once
oregexp.c:123: error: for each function it appears in.)
oregexp.c:123: error: ‘pat_ptr’ undeclared (first use in this function)
oregexp.c:129: error: ‘OnigEncodingType’ undeclared (first use in this function)
oregexp.c:129: error: ‘iEncoding’ undeclared (first use in this function)
oregexp.c:129: warning: implicit declaration of function ‘int2encoding’
oregexp.c:130: error: ‘OnigSyntaxType’ undeclared (first use in this function)
oregexp.c:130: error: ‘iSyntax’ undeclared (first use in this function)
oregexp.c:130: warning: implicit declaration of function ‘int2syntax’
oregexp.c:134: error: ‘OnigErrorInfo’ undeclared (first use in this function)
oregexp.c:134: error: expected ‘;’ before ‘einfo’
oregexp.c:135: warning: implicit declaration of function ‘onig_new’
oregexp.c:135: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:135: error: ‘einfo’ undeclared (first use in this function)
oregexp.c:136: error: ‘ONIG_NORMAL’ undeclared (first use in this function)
oregexp.c:137: error: ‘ONIG_MAX_ERROR_MESSAGE_LEN’ undeclared (first use in this function)
oregexp.c:138: warning: implicit declaration of function ‘onig_error_code_to_str’
oregexp.c:137: warning: unused variable ‘s’
oregexp.c: At top level:
oregexp.c:153: error: expected declaration specifiers or ‘...’ before ‘OnigRegion’
oregexp.c: In function ‘oregexp_make_match_data’:
oregexp.c:158: error: ‘region’ undeclared (first use in this function)
oregexp.c:162: error: invalid application of ‘sizeof’ to incomplete type ‘struct re_registers’
oregexp.c:163: error: dereferencing pointer to incomplete type
oregexp.c:164: error: dereferencing pointer to incomplete type
oregexp.c:165: error: dereferencing pointer to incomplete type
oregexp.c:166: error: dereferencing pointer to incomplete type
oregexp.c:169: error: dereferencing pointer to incomplete type
oregexp.c:170: error: dereferencing pointer to incomplete type
oregexp.c:173: error: ‘struct callback_packet’ has no member named ‘region’
oregexp.c:174: warning: implicit declaration of function ‘onig_number_of_names’
oregexp.c:174: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:176: warning: implicit declaration of function ‘onig_foreach_name’
oregexp.c:176: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:176: error: ‘name_callback’ undeclared (first use in this function)
oregexp.c: In function ‘oregexp_match’:
oregexp.c:211: warning: statement with no effect
oregexp.c:215: error: ‘UChar’ undeclared (first use in this function)
oregexp.c:215: error: ‘str_ptr’ undeclared (first use in this function)
oregexp.c:229: error: ‘OnigRegion’ undeclared (first use in this function)
oregexp.c:229: error: ‘region’ undeclared (first use in this function)
oregexp.c:229: warning: implicit declaration of function ‘onig_region_new’
oregexp.c:230: warning: implicit declaration of function ‘onig_search’
oregexp.c:230: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:230: error: ‘ONIG_OPTION_NONE’ undeclared (first use in this function)
oregexp.c:233: error: too many arguments to function ‘oregexp_make_match_data’
oregexp.c:234: warning: implicit declaration of function ‘onig_region_free’
oregexp.c:238: error: ‘ONIG_MISMATCH’ undeclared (first use in this function)
oregexp.c:243: error: ‘ONIG_MAX_ERROR_MESSAGE_LEN’ undeclared (first use in this function)
oregexp.c:243: warning: unused variable ‘s’
oregexp.c:248: warning: control reaches end of non-void function
oregexp.c: At top level:
oregexp.c:250: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘BACKSLASH’
oregexp.c: In function ‘oregexp_append_replacement’:
oregexp.c:262: error: expected declaration specifiers before ‘OnigRegion’
oregexp.c:268: error: ‘UChar’ undeclared (first use in this function)
oregexp.c:268: error: ‘replacementText’ undeclared (first use in this function)
oregexp.c:269: error: ‘replacementEnd’ undeclared (first use in this function)
oregexp.c:272: error: ‘OnigCodePoint’ undeclared (first use in this function)
oregexp.c:272: error: expected ‘;’ before ‘digitC’
oregexp.c:273: error: ‘OnigEncoding’ undeclared (first use in this function)
oregexp.c:273: error: expected ‘;’ before ‘enc’
oregexp.c:274: error: nested functions are disabled, use -fnested-functions to re-enable
oregexp.c:274: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘
’ token
oregexp.c:274: error: ‘matchText’ undeclared (first use in this function)
oregexp.c:280: error: ‘enc’ undeclared (first use in this function)
oregexp.c:280: warning: implicit declaration of function ‘onig_get_encoding’
oregexp.c:280: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:283: error: expected ‘;’ before ‘c’
oregexp.c:284: warning: implicit declaration of function ‘ONIGENC_MBC_ENC_LEN’
oregexp.c:286: error: ‘c’ undeclared (first use in this function)
oregexp.c:290: error: ‘BACKSLASH’ undeclared (first use in this function)
oregexp.c:307: error: ‘digitC’ undeclared (first use in this function)
oregexp.c:307: warning: implicit declaration of function ‘ONIGENC_MBC_TO_CODE’
oregexp.c:309: warning: implicit declaration of function ‘ONIGENC_IS_CODE_DIGIT’
oregexp.c:328: error: invalid type argument of ‘->’
oregexp.c:328: error: invalid type argument of ‘->’
oregexp.c:328: error: invalid type argument of ‘->’
oregexp.c:332: error: invalid type argument of ‘->’
oregexp.c:336: error: invalid type argument of ‘->’
oregexp.c:336: error: invalid type argument of ‘->’
oregexp.c:346: error: invalid type argument of ‘->’
oregexp.c:347: error: invalid type argument of ‘->’
oregexp.c:348: error: invalid type argument of ‘->’
oregexp.c:363: warning: implicit declaration of function ‘ONIGENC_IS_CODE_WORD’
oregexp.c:375: warning: implicit declaration of function ‘onig_name_to_backref_number’
oregexp.c:375: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:378: error: invalid type argument of ‘->’
oregexp.c:379: error: invalid type argument of ‘->’
oregexp.c:379: error: invalid type argument of ‘->’
oregexp.c:391: error: invalid type argument of ‘->’
oregexp.c:391: error: invalid type argument of ‘->’
oregexp.c:392: error: invalid type argument of ‘->’
oregexp.c:392: error: invalid type argument of ‘->’
oregexp.c:392: error: invalid type argument of ‘->’
oregexp.c: In function ‘oregexp_gsub’:
oregexp.c:417: error: expected declaration specifiers before ‘OnigRegion’
oregexp.c:429: error: ‘OnigEncoding’ undeclared (first use in this function)
oregexp.c:429: error: expected ‘;’ before ‘enc’
oregexp.c:444: error: ‘UChar’ undeclared (first use in this function)
oregexp.c:444: error: ‘str_ptr’ undeclared (first use in this function)
oregexp.c:447: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:447: error: ‘ONIG_OPTION_NONE’ undeclared (first use in this function)
oregexp.c:457: error: ‘enc’ undeclared (first use in this function)
oregexp.c:457: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:460: error: invalid type argument of ‘->’
oregexp.c:461: error: invalid type argument of ‘->’
oregexp.c:464: error: too many arguments to function ‘oregexp_make_match_data’
oregexp.c:487: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c: At top level:
oregexp.c:510: error: expected specifier-qualifier-list before ‘OnigRegion’
oregexp.c: In function ‘oregexp_packed_gsub’:
oregexp.c:513: error: ‘gsub_packet’ has no member named ‘region’
oregexp.c: At top level:
oregexp.c:515: error: expected ‘)’ before ‘*’ token
oregexp.c: In function ‘oregexp_safe_gsub’:
oregexp.c:525: error: ‘OnigRegion’ undeclared (first use in this function)
oregexp.c:525: error: ‘region’ undeclared (first use in this function)
oregexp.c:526: warning: excess elements in struct initializer
oregexp.c:526: warning: (near initialization for ‘call_args’)
oregexp.c:527: error: ‘oregexp_cleanup_region’ undeclared (first use in this function)
oregexp.c: At top level:
oregexp.c:597: error: expected declaration specifiers or ‘...’ before ‘OnigRegion’
oregexp.c: In function ‘oregexp_scan’:
oregexp.c:606: error: ‘OnigEncoding’ undeclared (first use in this function)
oregexp.c:606: error: expected ‘;’ before ‘enc’
oregexp.c:614: error: ‘UChar’ undeclared (first use in this function)
oregexp.c:614: error: ‘str_ptr’ undeclared (first use in this function)
oregexp.c:616: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:616: error: ‘region’ undeclared (first use in this function)
oregexp.c:616: error: ‘ONIG_OPTION_NONE’ undeclared (first use in this function)
oregexp.c:622: error: ‘enc’ undeclared (first use in this function)
oregexp.c:622: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:624: error: too many arguments to function ‘oregexp_make_match_data’
oregexp.c:641: error: ‘ORegexp%E

inner_html method not found updating from kitabu 1.0.6 to v2.0.4

When I updated from kitabu 1.0.6 to v2.0.4, I got the following error (using Ruby 2.0.0):

NoMethodError: undefined method `inner_html' for nil:NilClass
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/toc/html.rb:31:in `normalize'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/toc/html.rb:37:in `generate'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/exporter/html.rb:67:in `parse_layout'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/exporter/html.rb:20:in `block in export'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/exporter/html.rb:19:in `open'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/exporter/html.rb:19:in `export'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/exporter/base.rb:13:in `export'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/exporter.rb:32:in `export!'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/exporter.rb:5:in `run'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/cli.rb:38:in `export'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/bin/kitabu:5:in `<top (required)>'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/bin/kitabu:23:in `load'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/bin/kitabu:23:in `<main>'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/bin/ruby_executable_hooks:15:in `eval'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/bin/ruby_executable_hooks:15:in `<main>'
/Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/exporter/pdf.rb:17:in `create_html_file': undefined method `set_attribute' for nil:NilClass (NoMethodError)
    from /Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/exporter/pdf.rb:12:in `apply_footnotes!'
    from /Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/exporter/pdf.rb:5:in `export'
    from /Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/exporter/base.rb:13:in `export'
    from /Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/exporter.rb:33:in `export!'
    from /Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/exporter.rb:5:in `run'
    from /Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/lib/kitabu/cli.rb:38:in `export'
    from /Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/gems/kitabu-2.0.4/bin/kitabu:5:in `<top (required)>'
    from /Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/bin/kitabu:23:in `load'
    from /Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/bin/kitabu:23:in `<main>'
    from /Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/bin/ruby_executable_hooks:15:in `eval'
    from /Users/danielkehoe/.rvm/gems/ruby-2.0.0-p643@tutorials/bin/ruby_executable_hooks:15:in `<main>'

Can't install on OSX

I use Ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.4.0](installed using Homebrew).

Here's the command I run:

sudo gem install fnando-kitabu -s http://gems.github.com

Here's the output:

Fetching: rdiscount-1.6.8.gem (100%)
Building native extensions. This could take a while...
Fetching: hpricot-0.8.4.gem (100%)
Building native extensions. This could take a while...
Fetching: unicode-0.4.0.gem (100%)
Building native extensions. This could take a while...
Fetching: fattr-2.2.0.gem (100%)
Fetching: arrayfields-4.7.4.gem (100%)
Fetching: main-4.4.0.gem (100%)
Fetching: oniguruma-1.1.0.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing fnando-kitabu:
ERROR: Failed to build gem native extension.

    /usr/local/Cellar/ruby/1.9.2-p180/bin/ruby extconf.rb

checking for main() in -lonig... no
creating Makefile

make
/usr/bin/cc -I. -I/usr/local/Cellar/ruby/1.9.2-p180/include/ruby-1.9.1/x86_64-darwin10.4.0 -I/usr/local/Cellar/ruby/1.9.2-p180/include/ruby-1.9.1/ruby/backward -I/usr/local/Cellar/ruby/1.9.2-p180/include/ruby-1.9.1 -I. -I/usr/local/Cellar/readline/6.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -Wall -o oregexp.o -c oregexp.c
oregexp.c:2:23: error: oniguruma.h: No such file or directory
oregexp.c:9: error: expected specifier-qualifier-list before ‘regex_t’
oregexp.c: In function ‘oregexp_free’:
oregexp.c:16: warning: implicit declaration of function ‘onig_free’
oregexp.c:16: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c: In function ‘oregexp_allocate’:
oregexp.c:22: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c: At top level:
oregexp.c:27: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘’ token
oregexp.c:72: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘
’ token
oregexp.c:95: error: expected specifier-qualifier-list before ‘OnigRegion’
oregexp.c:99: warning: type defaults to ‘int’ in declaration of ‘UChar’
oregexp.c:99: error: expected ‘;’, ‘,’ or ‘)’ before ‘’ token
oregexp.c: In function ‘oregexp_initialize’:
oregexp.c:123: error: ‘UChar’ undeclared (first use in this function)
oregexp.c:123: error: (Each undeclared identifier is reported only once
oregexp.c:123: error: for each function it appears in.)
oregexp.c:123: error: ‘pat_ptr’ undeclared (first use in this function)
oregexp.c:123: error: ‘struct RString’ has no member named ‘ptr’
oregexp.c:124: error: ‘struct RString’ has no member named ‘len’
oregexp.c:129: error: ‘OnigEncodingType’ undeclared (first use in this function)
oregexp.c:129: error: ‘iEncoding’ undeclared (first use in this function)
oregexp.c:129: warning: implicit declaration of function ‘int2encoding’
oregexp.c:130: error: ‘OnigSyntaxType’ undeclared (first use in this function)
oregexp.c:130: error: ‘iSyntax’ undeclared (first use in this function)
oregexp.c:130: warning: implicit declaration of function ‘int2syntax’
oregexp.c:134: error: ‘OnigErrorInfo’ undeclared (first use in this function)
oregexp.c:134: error: expected ‘;’ before ‘einfo’
oregexp.c:135: warning: implicit declaration of function ‘onig_new’
oregexp.c:135: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:135: error: ‘einfo’ undeclared (first use in this function)
oregexp.c:136: error: ‘ONIG_NORMAL’ undeclared (first use in this function)
oregexp.c:137: error: ‘ONIG_MAX_ERROR_MESSAGE_LEN’ undeclared (first use in this function)
oregexp.c:138: warning: implicit declaration of function ‘onig_error_code_to_str’
oregexp.c:137: warning: unused variable ‘s’
oregexp.c: At top level:
oregexp.c:153: error: expected declaration specifiers or ‘...’ before ‘OnigRegion’
oregexp.c: In function ‘oregexp_make_match_data’:
oregexp.c:158: error: ‘region’ undeclared (first use in this function)
oregexp.c:162: error: invalid application of ‘sizeof’ to incomplete type ‘struct re_registers’
oregexp.c:163: error: dereferencing pointer to incomplete type
oregexp.c:164: error: dereferencing pointer to incomplete type
oregexp.c:165: error: dereferencing pointer to incomplete type
oregexp.c:166: error: dereferencing pointer to incomplete type
oregexp.c:169: error: dereferencing pointer to incomplete type
oregexp.c:170: error: dereferencing pointer to incomplete type
oregexp.c:173: error: ‘struct callback_packet’ has no member named ‘region’
oregexp.c:174: warning: implicit declaration of function ‘onig_number_of_names’
oregexp.c:174: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:176: warning: implicit declaration of function ‘onig_foreach_name’
oregexp.c:176: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:176: error: ‘name_callback’ undeclared (first use in this function)
oregexp.c: In function ‘oregexp_match’:
oregexp.c:211: warning: statement with no effect
oregexp.c:215: error: ‘UChar’ undeclared (first use in this function)
oregexp.c:215: error: ‘str_ptr’ undeclared (first use in this function)
oregexp.c:215: error: ‘struct RString’ has no member named ‘ptr’
oregexp.c:216: error: ‘struct RString’ has no member named ‘len’
oregexp.c:229: error: ‘OnigRegion’ undeclared (first use in this function)
oregexp.c:229: error: ‘region’ undeclared (first use in this function)
oregexp.c:229: warning: implicit declaration of function ‘onig_region_new’
oregexp.c:230: warning: implicit declaration of function ‘onig_search’
oregexp.c:230: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:230: error: ‘ONIG_OPTION_NONE’ undeclared (first use in this function)
oregexp.c:233: error: too many arguments to function ‘oregexp_make_match_data’
oregexp.c:234: warning: implicit declaration of function ‘onig_region_free’
oregexp.c:238: error: ‘ONIG_MISMATCH’ undeclared (first use in this function)
oregexp.c:243: error: ‘ONIG_MAX_ERROR_MESSAGE_LEN’ undeclared (first use in this function)
oregexp.c:243: warning: unused variable ‘s’
oregexp.c:248: warning: control reaches end of non-void function
oregexp.c: At top level:
oregexp.c:250: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘BACKSLASH’
oregexp.c: In function ‘oregexp_append_replacement’:
oregexp.c:262: error: expected declaration specifiers before ‘OnigRegion’
oregexp.c:267: error: ‘struct RString’ has no member named ‘len’
oregexp.c:268: error: ‘UChar’ undeclared (first use in this function)
oregexp.c:268: error: ‘replacementText’ undeclared (first use in this function)
oregexp.c:268: error: ‘struct RString’ has no member named ‘ptr’
oregexp.c:269: error: ‘replacementEnd’ undeclared (first use in this function)
oregexp.c:272: error: ‘OnigCodePoint’ undeclared (first use in this function)
oregexp.c:272: error: expected ‘;’ before ‘digitC’
oregexp.c:273: error: ‘OnigEncoding’ undeclared (first use in this function)
oregexp.c:273: error: expected ‘;’ before ‘enc’
oregexp.c:274: error: nested functions are disabled, use -fnested-functions to re-enable
oregexp.c:274: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘
’ token
oregexp.c:274: error: ‘matchText’ undeclared (first use in this function)
oregexp.c:277: error: ‘struct RString’ has no member named ‘ptr’
oregexp.c:278: error: ‘struct RString’ has no member named ‘len’
oregexp.c:280: error: ‘enc’ undeclared (first use in this function)
oregexp.c:280: warning: implicit declaration of function ‘onig_get_encoding’
oregexp.c:280: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:283: error: expected ‘;’ before ‘c’
oregexp.c:284: warning: implicit declaration of function ‘ONIGENC_MBC_ENC_LEN’
oregexp.c:286: error: ‘c’ undeclared (first use in this function)
oregexp.c:290: error: ‘BACKSLASH’ undeclared (first use in this function)
oregexp.c:307: error: ‘digitC’ undeclared (first use in this function)
oregexp.c:307: warning: implicit declaration of function ‘ONIGENC_MBC_TO_CODE’
oregexp.c:309: warning: implicit declaration of function ‘ONIGENC_IS_CODE_DIGIT’
oregexp.c:328: error: invalid type argument of ‘->’
oregexp.c:328: error: invalid type argument of ‘->’
oregexp.c:328: error: invalid type argument of ‘->’
oregexp.c:332: error: invalid type argument of ‘->’
oregexp.c:336: error: invalid type argument of ‘->’
oregexp.c:336: error: invalid type argument of ‘->’
oregexp.c:346: error: invalid type argument of ‘->’
oregexp.c:347: error: invalid type argument of ‘->’
oregexp.c:348: error: invalid type argument of ‘->’
oregexp.c:363: warning: implicit declaration of function ‘ONIGENC_IS_CODE_WORD’
oregexp.c:375: warning: implicit declaration of function ‘onig_name_to_backref_number’
oregexp.c:375: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:378: error: invalid type argument of ‘->’
oregexp.c:379: error: invalid type argument of ‘->’
oregexp.c:379: error: invalid type argument of ‘->’
oregexp.c:391: error: invalid type argument of ‘->’
oregexp.c:391: error: invalid type argument of ‘->’
oregexp.c:392: error: invalid type argument of ‘->’
oregexp.c:392: error: invalid type argument of ‘->’
oregexp.c:392: error: invalid type argument of ‘->’
oregexp.c: In function ‘str_mod_check’:
oregexp.c:405: error: ‘struct RString’ has no member named ‘ptr’
oregexp.c:405: error: ‘struct RString’ has no member named ‘len’
oregexp.c: In function ‘oregexp_gsub’:
oregexp.c:417: error: expected declaration specifiers before ‘OnigRegion’
oregexp.c:429: error: ‘OnigEncoding’ undeclared (first use in this function)
oregexp.c:429: error: expected ‘;’ before ‘enc’
oregexp.c:444: error: ‘UChar’ undeclared (first use in this function)
oregexp.c:444: error: ‘str_ptr’ undeclared (first use in this function)
oregexp.c:444: error: ‘struct RString’ has no member named ‘ptr’
oregexp.c:445: error: ‘struct RString’ has no member named ‘len’
oregexp.c:447: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:447: error: ‘ONIG_OPTION_NONE’ undeclared (first use in this function)
oregexp.c:457: error: ‘enc’ undeclared (first use in this function)
oregexp.c:457: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:460: error: invalid type argument of ‘->’
oregexp.c:461: error: invalid type argument of ‘->’
oregexp.c:464: error: too many arguments to function ‘oregexp_make_match_data’
oregexp.c:487: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c: At top level:
oregexp.c:510: error: expected specifier-qualifier-list before ‘OnigRegion’
oregexp.c: In function ‘oregexp_packed_gsub’:
oregexp.c:513: error: ‘gsub_packet’ has no member named ‘region’
oregexp.c: At top level:
oregexp.c:515: error: expected ‘)’ before ‘’ token
oregexp.c: In function ‘oregexp_safe_gsub’:
oregexp.c:525: error: ‘OnigRegion’ undeclared (first use in this function)
oregexp.c:525: error: ‘region’ undeclared (first use in this function)
oregexp.c:526: warning: excess elements in struct initializer
oregexp.c:526: warning: (near initialization for ‘call_args’)
oregexp.c:527: error: ‘oregexp_cleanup_region’ undeclared (first use in this function)
oregexp.c: At top level:
oregexp.c:597: error: expected declaration specifiers or ‘...’ before ‘OnigRegion’
oregexp.c: In function ‘oregexp_scan’:
oregexp.c:606: error: ‘OnigEncoding’ undeclared (first use in this function)
oregexp.c:606: error: expected ‘;’ before ‘enc’
oregexp.c:614: error: ‘UChar’ undeclared (first use in this function)
oregexp.c:614: error: ‘str_ptr’ undeclared (first use in this function)
oregexp.c:614: error: ‘struct RString’ has no member named ‘ptr’
oregexp.c:615: error: ‘struct RString’ has no member named ‘len’
oregexp.c:616: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:616: error: ‘region’ undeclared (first use in this function)
oregexp.c:616: error: ‘ONIG_OPTION_NONE’ undeclared (first use in this function)
oregexp.c:622: error: ‘enc’ undeclared (first use in this function)
oregexp.c:622: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c:624: error: too many arguments to function ‘oregexp_make_match_data’
oregexp.c:641: error: ‘ORegexp’ has no member named ‘reg’
oregexp.c: At top level:
oregexp.c:651: error: expected specifier-qualifier-list before ‘OnigRegion’
oregexp.c: In function ‘oregexp_packed_scan’:
oregexp.c:654: error: ‘struct scan_packet’ has no member named ‘region’
oregexp.c:654: error: too many arguments to function ‘oregexp_scan’
oregexp.c: In function ‘oregexp_m_scan’:
oregexp.c:669: error: ‘OnigRegion’ undeclared (first use in this function)
oregexp.c:669: error: ‘region’ undeclared (first use in this function)
oregexp.c:670: warning: excess elements in struct initializer
oregexp.c:670: warning: (near initialization for ‘call_args’)
oregexp.c:671: error: ‘oregexp_cleanup_region’ undeclared (first use in this function)
oregexp.c: In function ‘oregexp_match_op’:
oregexp.c:727: error: dereferencing pointer to incomplete type
oregexp.c:728: warning: control reaches end of non-void function
oregexp.c: In function ‘Init_oregexp’:
oregexp.c:743: warning: implicit declaration of function ‘onig_version’
oregexp.c:743: warning: passing argument 1 of ‘strlen’ makes pointer from integer without a cast
oregexp.c:743: warning: passing argument 1 of ‘rb_str_new’ makes pointer from integer without a cast
oregexp.c:743: warning: passing argument 1 of ‘rb_str_new_cstr’ makes pointer from integer without a cast
make: *
* [oregexp.o] Error 1

Gem files will remain installed in /usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/oniguruma-1.1.0 for inspection.
Results logged to /usr/local/Cellar/ruby/1.9.2-p180/lib/ruby/gems/1.9.1/gems/oniguruma-1.1.0/ext/gem_make.out

html2text gives an error on `kitabu export`

When I run kitabu export, I get an error with html2text.

$ kitabu export
Usage: html2text [(filename|url) [encoding]]

html2text: error: no such option: -t
** e-book couldn't be exported

When I only build HTML or ePub, everything seems to work:

$ kitabu export --only html
** e-book has been exported
$ kitabu export --only epub
** e-book has been exported

I installed html2text from pip (by running pip install html2text). I assume that this is the wrong one?

Here are some potentially relevant details about my system:

$ kitabu --version
Kitabu version 2.0.4

$ html2text --version
html2text 2015.6.21

$ kitabu check

Prince XML: Converts HTML files into PDF files.
Not installed.

KindleGen: Converts ePub e-books into .mobi files.
Not installed.

html2text: Converts HTML documents into plain text.
Installed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.