diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-09-14 12:26:45 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2022-09-14 12:26:45 -0600 |
| commit | b18ad55cc78d9aa76b898b63cb150efc8f3195cc (patch) | |
| tree | a3514583b0591acf3d74467b794f4d8716c99879 /docs/modules/extend/examples | |
| parent | a422b6680be30a77e3d66aaf9e2f978f5e0daff9 (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.rb | 19 |
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 |
