Skip to content

Commit

Permalink
resolves #405 add support for floating elements
Browse files Browse the repository at this point in the history
  • Loading branch information
slonopotamus committed Dec 25, 2022
1 parent 8003129 commit 222631b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 8 additions & 0 deletions data/styles/epub3.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1147,3 +1147,11 @@ nav[hidden~="hidden"] {
font-family: monospace;
}
}

.left {
float: left !important;
}

.right {
float: right !important;
}
10 changes: 7 additions & 3 deletions lib/asciidoctor-epub3/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,9 @@ def convert_table node
if (role = node.role)
table_classes << role
end
if (float = node.attr 'float')
table_classes << float
end
table_styles = []
if (autowidth = node.option? 'autowidth') && !(node.attr? 'width')
table_classes << 'fit-content'
Expand Down Expand Up @@ -1069,7 +1072,7 @@ def convert_video node
poster_attr = %( poster="#{poster}")
end

%(<figure#{id_attr} class="video#{prepend_space node.role}">#{title_element}
%(<figure#{id_attr} class="video#{prepend_space node.role}#{prepend_space node.attr('float')}">#{title_element}
<div class="content">
<video src="#{target}#{time_anchor}"#{width_attr}#{height_attr}#{autoplay_attr}#{poster_attr}#{controls_attr}#{loop_attr}>
<div>Your Reading System does not support (this) video.</div>
Expand All @@ -1084,7 +1087,7 @@ def convert_image node
id_attr = node.id ? %( id="#{node.id}") : ''
title_element = node.title? ? %(\n<figcaption>#{node.captioned_title}</figcaption>) : ''
img_attrs = resolve_image_attrs node
%(<figure#{id_attr} class="image#{prepend_space node.role}">
%(<figure#{id_attr} class="image#{prepend_space node.role}#{prepend_space node.attr('float')}">
<div class="content">
<img src="#{target}"#{prepend_space img_attrs * ' '} />
</div>#{title_element}
Expand Down Expand Up @@ -1189,13 +1192,14 @@ def convert_inline_image node
i_classes << %(icon-flip-#{(node.attr 'flip')[0]}) if node.attr? 'flip'
i_classes << %(icon-rotate-#{node.attr 'rotate'}) if node.attr? 'rotate'
i_classes << node.role if node.role?
i_classes << node.attr('float') if node.attr 'float'
%(<i class="#{i_classes * ' '}"></i>)
else
target = node.image_uri node.target
register_media_file node, target, 'image'

img_attrs = resolve_image_attrs node
img_attrs << %(class="inline#{prepend_space node.role}")
img_attrs << %(class="inline#{prepend_space node.role}#{prepend_space node.attr('float')}")
%(<img src="#{target}"#{prepend_space img_attrs * ' '}/>)
end
end
Expand Down

0 comments on commit 222631b

Please sign in to comment.