Class: Asciidoctor::Document
- Defined in:
- lib/asciidoctor/pdf/ext/asciidoctor/document.rb
Instance Method Summary collapse
-
#attr_unspecified?(name) ⇒ Boolean
Internal: Returns whether the specified attribute has never been set and is not locked.
-
#promote_preface_block ⇒ Object
promote preface block (i.e., preamble block with title in book doctype) to preface section FIXME: this should be handled by core.
Instance Method Details
#attr_unspecified?(name) ⇒ Boolean
Internal: Returns whether the specified attribute has never been set and is not locked.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/asciidoctor/pdf/ext/asciidoctor/document.rb', line 28 def attr_unspecified? name if (attribute_locked? name) || (@attributes_modified.include? name) false elsif nested? @parent_document.attr_unspecified? name else ([:attributes] || {}).each_pair.none? do |k, v| if k == name true elsif v == '@' k == %(!#{name}) || k == %(#{name}!) elsif k.end_with? '@' (k = k.chop) == name || k == %(!#{name}) || k == %(#{name}!) else false end end end end |
#promote_preface_block ⇒ Object
promote preface block (i.e., preamble block with title in book doctype) to preface section FIXME: this should be handled by core
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/asciidoctor/pdf/ext/asciidoctor/document.rb', line 6 def promote_preface_block if doctype == 'book' && (blk0 = blocks[0])&.context == :preamble && blk0.title? && !blk0.title.nil_or_empty? && blk0.blocks[0]&.style != 'abstract' && (blk1 = blocks[1])&.context == :section preface = Asciidoctor::Section.new self, blk1.level, false, attributes: { 1 => 'preface', 'style' => 'preface' } preface.special = true preface.sectname = 'preface' preface.title = blk0.instance_variable_get :@title preface.id = preface.generate_id if (first_child = blk0.blocks[0])&.option? 'notitle' preface.set_option 'notitle' first_child.set_attr 'role', 'lead' if first_child.context == :paragraph && !first_child.role? end preface.blocks.replace (blk0.blocks.map do |b| b.parent = preface b end) blocks[0] = preface end nil end |