Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoking asciidoctor-pdf in Ruby #866

Closed
briandominick opened this issue Nov 4, 2017 · 5 comments
Closed

Invoking asciidoctor-pdf in Ruby #866

briandominick opened this issue Nov 4, 2017 · 5 comments
Assignees
Milestone

Comments

@briandominick
Copy link

briandominick commented Nov 4, 2017

I've got a gem that calls Asciidoctor.convert_file and always sets require: "pdf", so when backend: pdf it churns out a nice doc. This has worked pretty great, but after struggling to suppress the cover page on a PDF document I'm rendering, I was unable to make it work, even using the technique described in Issue #95. So I tested by directly building with asciidoctor-pdf on the CLI, and it works like a charm.

So should I be trying to get Asciidoctor.convert_file to behave like the asciidoctor-pdf command? Maybe I'm missing a setting? Is there a way to call the Asciidoctor PDF from my Ruby script? Or do I have to switch to an explicit command-line invocation?

@mojavelinux
Copy link
Member

You should be able to use Asciidoctor PDF via the Asciidoctor.convert_file with the following script:

require 'asciidoctor-pdf'

Asciidoctor.convert_file 'input.adoc', backend: 'pdf', safe: :safe

The only requirements are that:

  • The asciidoctor-pdf library/gem is required by the script
  • The backend is set to "pdf" (which is what selects the converter)

Is that not working for you?

@mojavelinux mojavelinux self-assigned this Oct 28, 2018
@briandominick
Copy link
Author

Sorry Dan I should have come by and closed this issue. I did first implemen a CLI invocation of asciidoctor-pdf. Whatever testing I was doing was getting me stuck, and it matched the experience of someone else I was talking to at the time, that somehow invoking the asciidoctor-pdf gem was inadequate. I knew that couldn't be true (and that you can't get to ever issue post here), so I tried again recently and now I'm properly calling asciidoctor-pdf as a gem.
DocOps/liquidoc-gem#54

I'm sorry I didn't come back here and update this post. I forgot I posted it!

@mojavelinux
Copy link
Member

mojavelinux commented Oct 28, 2018

No problem @briandominick. I'm very happy to hear you got it working!

I'm curious about one thing, though. What does require: "pdf" do? I don't see a pdf.rb file in the repository, and "pdf" is not the name of a gem. It looks like you are already requiring asciidoctor-pdf at the top of the file, so I don't think you need that line unless I'm missing something.

@briandominick
Copy link
Author

Ah, if only I had you reviewing all of my PRs @mojavelinux! Or anyone, for that matter, but definitely you would be great, welcome anytime ;-) That looks vestigial from some attempt at something.

@mojavelinux
Copy link
Member

;)

If you need input, always feel free to @ me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants