Skip to content

Commit

Permalink
Split conversion action; add CLI system call for asciidoctor-pdf
Browse files Browse the repository at this point in the history
This resolves issue #24
Dividing convert calls between PDF backend and non-PDF, with all PDF calls using system asciidoctor-pdf.
I don't love this solution, but it's good enough for now.
  • Loading branch information
briandominick committed Nov 5, 2017
1 parent 6ee2ee8 commit 20d6c0a
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions lib/liquidoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -568,18 +568,25 @@ def asciidocify doc, build
doc.add_attrs!(@passed_attrs)
@logger.debug "Final pre-parse attributes: #{doc.attributes}"
# Perform the aciidoctor convert
Asciidoctor.convert_file(
doc.index,
to_file: to_file,
attributes: doc.attributes,
require: "pdf",
backend: back,
doctype: build.doctype,
safe: "server",
sourcemap: true,
verbose: @verbose,
mkdirs: true
)
unless back == "pdf"
Asciidoctor.convert_file(
doc.index,
to_file: to_file,
attributes: doc.attributes,
require: "pdf",
backend: back,
doctype: build.doctype,
safe: "unsafe",
sourcemap: true,
verbose: @verbose,
mkdirs: true
)
else # For PDFs, we're calling the asciidoctor-pdf CLI, as the main dependency does not seem to perform the same way
attributes = '-a ' + doc.attributes.map{|k,v| "#{k}='#{v}'"}.join(' -a ')
command = "asciidoctor-pdf -o #{to_file} -b pdf -d #{build.doctype} -S unsafe #{attributes} -a no-header-footer --trace #{doc.index}"
@logger.debug "Running #{command}"
system command
end
@logger.info "Rendered file #{to_file}."
end

Expand Down

0 comments on commit 20d6c0a

Please sign in to comment.