From bc86f042f5bdcec4bab45508eab3617d0b370741 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 2 Apr 2016 16:55:59 +0100 Subject: Rename images.inline to images.img_element --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index c423581..1a4e1a6 100644 --- a/README.md +++ b/README.md @@ -177,7 +177,7 @@ def convert_image(image): "src": "data:{0};base64,{1}".format(image.content_type, encoded_src) } -mammoth.convert_to_html(docx_file, convert_image=mammoth.images.inline(convert_image)) +mammoth.convert_to_html(docx_file, convert_image=mammoth.images.img_element(convert_image)) ``` #### Bold @@ -312,8 +312,8 @@ Each message has the following properties: #### Image converters -An inline image converter can be created by calling `mammoth.images.inline(func)`. -This creates an inline `` element for each image in the original docx. +An image converter can be created by calling `mammoth.images.img_element(func)`. +This creates an `` element for each image in the original docx. `func` should be a function that has one argument `image`. This argument is the image element being converted, and has the following properties: @@ -322,8 +322,10 @@ and has the following properties: * `content_type`: the content type of the image, such as `image/png`. -`func` should return a `dict` with a `src` item, -which will be used as the `src` attribute on the `` element. +`func` should return a `dict` of attributes for the `` element. +At a minimum, this should include the `src` attribute. +If any alt text is found for the image, +this will be automatically added to the element's attributes. For instance, the following replicates the default image conversion: @@ -336,7 +338,7 @@ def convert_image(image): "src": "data:{0};base64,{1}".format(image.content_type, encoded_src) } -mammoth.images.inline(convert_image) +mammoth.images.img_element(convert_image) ``` ## Writing style maps -- cgit v1.2.3