File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,10 @@ def process_block(block)
33
33
callout_extension = block . document . attr 'copy-callout-images'
34
34
if callout_extension
35
35
if block . parent && block . parent . context == :colist
36
- block . attr ( 'coids' ) . scan ( /CO(?:\d +)-(\d +)/ ) {
36
+ coids = block . attr ( 'coids' )
37
+ return unless coids
38
+
39
+ coids . scan ( /CO(?:\d +)-(\d +)/ ) {
37
40
copy_image block , "images/icons/callouts/#{ $1} .#{ callout_extension } "
38
41
}
39
42
return
Original file line number Diff line number Diff line change @@ -358,6 +358,28 @@ def copy_attributes(copied)
358
358
] )
359
359
end
360
360
361
+ it "doesn't blow up when the callout can't be found" do
362
+ copied = [ ]
363
+ attributes = copy_attributes copied
364
+ attributes [ 'copy-callout-images' ] = 'png'
365
+ input = <<~ASCIIDOC
366
+ == Example
367
+ ----
368
+ foo <1>
369
+ ----
370
+ <1> words
371
+ <2> doesn't get an id
372
+ ASCIIDOC
373
+ expected_warnings = <<~WARNINGS
374
+ WARN: <stdin>: line 6: no callout found for <2>
375
+ INFO: <stdin>: line 5: copying #{ spec_dir } /resources/copy_images/images/icons/callouts/1.png
376
+ WARNINGS
377
+ convert input , attributes , eq ( expected_warnings . strip )
378
+ expect ( copied ) . to eq ( [
379
+ [ "images/icons/callouts/1.png" , "#{ spec_dir } /resources/copy_images/images/icons/callouts/1.png" ] ,
380
+ ] )
381
+ end
382
+
361
383
it "doesn't copy callout images if the extension isn't set" do
362
384
copied = [ ]
363
385
attributes = copy_attributes copied
You can’t perform that action at this time.
0 commit comments