summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2017-03-21 23:54:17 -0600
committerGitHub <noreply@github.com>2017-03-21 23:54:17 -0600
commit1e00a92377b0d0e0ea87c8892f414b590f38784a (patch)
tree28aa067d5b2813012d4d30a24bf30f83f0990940
parentc3d0e81bf9e49463fe415b659d6e1688a18b156f (diff)
implement none, no-bullet and unstyled unordered list styles (PR #778)
- none simply hides the bullet (aka visibility: hidden) - no-bullet shifts item text to (approx) left-hand margin of bullet column - unstyled removed indentation from the list itself - warn if list style is unrecognized
-rw-r--r--lib/asciidoctor-pdf/converter.rb27
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/asciidoctor-pdf/converter.rb b/lib/asciidoctor-pdf/converter.rb
index cd2d1135..cf4de375 100644
--- a/lib/asciidoctor-pdf/converter.rb
+++ b/lib/asciidoctor-pdf/converter.rb
@@ -73,7 +73,8 @@ class Converter < ::Prawn::Document
Bullets = {
disc: %(\u2022),
circle: %(\u25e6),
- square: %(\u25aa)
+ square: %(\u25aa),
+ none: ''
}
# NOTE Default theme font uses ballot boxes from FontAwesome
BallotBox = {
@@ -854,8 +855,15 @@ class Converter < ::Prawn::Document
case style
when 'bibliography'
:square
+ when 'unstyled', 'no-bullet'
+ nil
else
- style.to_sym
+ if Bullets.key?(candidate = style.to_sym)
+ candidate
+ else
+ warn %(asciidoctor: WARNING: unknown unordered list style: #{candidate})
+ :disc
+ end
end
else
case node.outline_level
@@ -882,7 +890,18 @@ class Converter < ::Prawn::Document
complex = false
# ...or if we want to give all items in the list the same treatment
#complex = node.items.find(&:complex?) ? true : false
- indent @theme.outline_list_indent do
+ if node.context == :ulist && !@list_bullets[-1]
+ if node.style == 'unstyled'
+ # unstyled takes away all indentation
+ list_indent = 0
+ elsif (list_indent = @theme.outline_list_indent) > 0
+ # no-bullet aligns text with left-hand side of bullet position (as though there's no bullet)
+ list_indent = [list_indent - (width_of %(\u2022x)), 0].max
+ end
+ else
+ list_indent = @theme.outline_list_indent
+ end
+ indent list_indent do
node.items.each do |item|
# FIXME extract to an ensure_space (or similar) method; simplify
start_new_page if cursor < (line_metrics.height + line_metrics.leading + line_metrics.padding_top)
@@ -902,7 +921,7 @@ class Converter < ::Prawn::Document
# TODO move this to a draw_bullet (or draw_marker) method
case (list_type = node.parent.context)
when :ulist
- marker = @list_bullets.last
+ marker = @list_bullets[-1]
if marker == :checkbox
if node.attr? 'checkbox', nil, false
marker = BallotBox[(node.attr? 'checked', nil, false) ? :checked : :unchecked]