summaryrefslogtreecommitdiff
path: root/docs/modules/extend/examples
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-09-14 12:26:45 -0600
committerDan Allen <dan.j.allen@gmail.com>2022-09-14 12:26:45 -0600
commitb18ad55cc78d9aa76b898b63cb150efc8f3195cc (patch)
treea3514583b0591acf3d74467b794f4d8716c99879 /docs/modules/extend/examples
parenta422b6680be30a77e3d66aaf9e2f978f5e0daff9 (diff)
add extended converter example that looks for images in multiple dirs
Diffstat (limited to 'docs/modules/extend/examples')
-rw-r--r--docs/modules/extend/examples/pdf-converter-multiple-imagesdirs.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/modules/extend/examples/pdf-converter-multiple-imagesdirs.rb b/docs/modules/extend/examples/pdf-converter-multiple-imagesdirs.rb
new file mode 100644
index 00000000..29747feb
--- /dev/null
+++ b/docs/modules/extend/examples/pdf-converter-multiple-imagesdirs.rb
@@ -0,0 +1,19 @@
+class PDFConverterMultipleImagesdirs < (Asciidoctor::Converter.for 'pdf')
+ register_for 'pdf'
+
+ def resolve_image_path node, image_path, image_format, relative_to = true
+ if relative_to == true
+ unless File.file? image_path
+ docdir = (doc = node.document).attr 'docdir'
+ %w(imagesdir imagesdir2).each do |attr_name|
+ imagesdir = (doc.attr attr_name) || ''
+ abs_imagesdir = File.absolute_path imagesdir, docdir
+ next unless File.file? (File.absolute_path image_path, abs_imagesdir)
+ relative_to = abs_imagesdir
+ break
+ end
+ end
+ end
+ super
+ end
+end