Add support for images
This commit is contained in:
@@ -21,6 +21,7 @@ module Ezdoc
|
||||
@current_table = nil
|
||||
@current_row = nil
|
||||
@num_id_counter = 0
|
||||
@images = {}
|
||||
end
|
||||
|
||||
def save(path)
|
||||
@@ -30,5 +31,26 @@ module Ezdoc
|
||||
def lists
|
||||
@nodes.select { |n| n.is_a?(Nodes::List) }
|
||||
end
|
||||
|
||||
def images
|
||||
@images.values
|
||||
end
|
||||
|
||||
def register_image(path, width: nil, height: nil)
|
||||
return @images[path] if @images[path]
|
||||
|
||||
rid = next_image_rid
|
||||
width_emu, height_emu = ImageDimensions.calculate_emus(path, width: width, height: height)
|
||||
image = Nodes::Image.new(path, rid: rid, width_emu: width_emu, height_emu: height_emu)
|
||||
@images[path] = image
|
||||
image
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def next_image_rid
|
||||
base = lists.any? ? 2 : 1
|
||||
"rId#{base + @images.size}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user