diff options
| author | Marat Radchenko <marat@slonopotamus.org> | 2020-10-18 20:21:25 +0300 |
|---|---|---|
| committer | Marat Radchenko <marat@slonopotamus.org> | 2020-10-18 20:21:25 +0300 |
| commit | f68307e31ef1f65ca62c4d3b2d7151908fa28cd3 (patch) | |
| tree | 85486bb1732cb7d2d1cdcf14a895d7e4c95ff760 | |
| parent | f9b7b402020ef5f37e2cd64b888f533a3e6bc10c (diff) | |
resolves #375 fix crash when inline pass macro `m` contains an icon
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | lib/asciidoctor-epub3/converter.rb | 11 | ||||
| -rw-r--r-- | spec/converter_spec.rb | 10 |
3 files changed, 18 insertions, 4 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index ad93e1b..6e12b0e 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -124,6 +124,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[ * upgrade pygments.rb to 1.2.1 (#216) * gepub dependency is no longer locked to 1.0.2 and will use latest 1.0.x version * fix `-a ebook-validate` not working on Windows (#232) +* fix crash when inline pass macro `m` contains an icon (#375) == 1.5.0.alpha.9 (2019-04-04) - @mojavelinux diff --git a/lib/asciidoctor-epub3/converter.rb b/lib/asciidoctor-epub3/converter.rb index 6344553..63dbba0 100644 --- a/lib/asciidoctor-epub3/converter.rb +++ b/lib/asciidoctor-epub3/converter.rb @@ -143,6 +143,10 @@ module Asciidoctor title end + def icon_names + @icon_names ||= [] + end + def convert_document node @format = node.attr('ebook-format').to_sym @@ -152,7 +156,6 @@ module Asciidoctor @kindlegen_path = node.attr 'ebook-kindlegen-path' @epubcheck_path = node.attr 'ebook-epubcheck-path' @xrefs_seen = ::Set.new - @icon_names = [] @media_files = {} @footnotes = [] @@ -360,10 +363,10 @@ module Asciidoctor # NOTE must run after content is resolved # TODO perhaps create dynamic CSS file? - if @icon_names.empty? + if icon_names.empty? icon_css_head = '' else - icon_defs = @icon_names.map {|name| + icon_defs = icon_names.map {|name| %(.i-#{name}::before { content: "#{FontIconMap.unicode name}"; }) } * LF icon_css_head = %(<style> @@ -1169,7 +1172,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) { def convert_inline_image node if node.type == 'icon' - @icon_names << (icon_name = node.target) + icon_names << (icon_name = node.target) i_classes = ['icon', %(i-#{icon_name})] i_classes << %(icon-#{node.attr 'size'}) if node.attr? 'size' i_classes << %(icon-flip-#{(node.attr 'flip')[0]}) if node.attr? 'flip' diff --git a/spec/converter_spec.rb b/spec/converter_spec.rb index b6bb326..05bb0f1 100644 --- a/spec/converter_spec.rb +++ b/spec/converter_spec.rb @@ -270,6 +270,16 @@ toc::[] EOS end + it 'does not crash when sees inline pass macro `m` with an icon' do + to_epub <<~EOS += Test +:icons: font +:call-to-action: pass:m,q[icon:hand-o-right[] *Call to Action*] + +{call-to-action} + EOS + end + it 'supports video' do book, = to_epub fixture_file('video/book.adoc') chapter = book.item_by_href '_chapter.xhtml' |
