summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2014-05-28 20:40:41 -0600
committerDan Allen <dan.j.allen@gmail.com>2014-05-28 20:54:38 -0600
commitf890f361919f8f2ca224b8baa0a2d30fdfa293f8 (patch)
tree857f3c1e6aae79c8715fb96a82bb8b2cf6d9cc85 /bin
parent07aa4985539fda5ccdd94a5158a0b63b14183be3 (diff)
add and register implicit header processor;
Diffstat (limited to 'bin')
-rwxr-xr-xbin/asciidoctor-pdf22
1 files changed, 15 insertions, 7 deletions
diff --git a/bin/asciidoctor-pdf b/bin/asciidoctor-pdf
index b5b5927a..46d1553f 100755
--- a/bin/asciidoctor-pdf
+++ b/bin/asciidoctor-pdf
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-attributes = %w(idprefix=@ listing-caption=Listing@)
+attributes = %w(idprefix=@ listing-caption=Listing@ buildfor-editor)
while ARGV[0] == '-a'
ARGV.shift
attributes << ARGV.shift
@@ -23,6 +23,7 @@ require 'ostruct'
require 'asciidoctor'
require 'asciidoctor/pdf_renderer'
require 'asciidoctor/theme_loader'
+require 'asciidoctor-pdf/implicit_header_processor'
require 'tilt'
require 'slim'
@@ -30,11 +31,11 @@ DataDir = File.join File.dirname(__FILE__), '..', 'data'
ThemesDir = File.join DataDir, 'themes'
TemplatesDir = File.join DataDir, 'templates'
-#theme_data = ::Asciidoctor::ThemeLoader.load_file File.join ThemesDir, 'default-theme.yml'
-#theme_data = ::Asciidoctor::ThemeLoader.load_file File.join ThemesDir, 'asciidoctor-theme.yml'
-theme_data = ::Asciidoctor::ThemeLoader.load_file(theme_file || (File.join ThemesDir, 'default-theme.yml'))
+#theme_data = Asciidoctor::ThemeLoader.load_file File.join ThemesDir, 'default-theme.yml'
+#theme_data = Asciidoctor::ThemeLoader.load_file File.join ThemesDir, 'asciidoctor-theme.yml'
+theme_data = Asciidoctor::ThemeLoader.load_file(theme_file || (File.join ThemesDir, 'default-theme.yml'))
-file_rootname = ::Asciidoctor::Helpers.rootname File.basename asciidoc_file
+file_rootname = Asciidoctor::Helpers.rootname File.basename asciidoc_file
pdf_file = %(#{file_rootname}.pdf)
options = {
safe: :safe,
@@ -42,5 +43,12 @@ options = {
attributes: attributes
}
-doc = ::Asciidoctor.load_file asciidoc_file, options
-::Asciidoctor::PdfRenderer.render doc, pdf_file, theme_data
+options[:extensions_registry] = Asciidoctor::Extensions.build_registry :pdf do
+ include_processor Asciidoctor::Pdf::ImplicitHeaderProcessor.new @document
+end
+
+workdir, asciidoc_file = File.split asciidoc_file
+Dir.chdir workdir
+
+doc = Asciidoctor.load_file asciidoc_file, options
+Asciidoctor::PdfRenderer.render doc, pdf_file, theme_data