Class: Deplate::Command::IDX
- Inherits:
-
Deplate::Command
- Object
- Element
- Deplate::Command
- Deplate::Command::IDX
- Defined in:
- lib/deplate/commands.rb
Class Method Summary collapse
- .accumulate(src, array, deplate, text, match, args, cmd) ⇒ Object
- .get_indices(container, deplate, args, text, source) ⇒ Object
Instance Method Summary collapse
Methods inherited from Deplate::Command
commands, #format_special, register_as, #setup, update_variables
Methods included from Names
name_match_c, name_match_fs, name_match_sf
Methods inherited from Element
#join_lines, #join_lines_re_zh_cn
Class Method Details
.accumulate(src, array, deplate, text, match, args, cmd) ⇒ Object
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 |
# File 'lib/deplate/commands.rb', line 640 def accumulate(src, array, deplate, text, match, args, cmd) i = -1 while array[i] and array[i].kind_of?(Deplate::Element::Whitespace) i -= 1 end e = array[i] if e out = get_indices(e, deplate, args, text, src) pseudocontainer = Deplate::PseudoContainer.new(deplate, :args => args) e.postponed_preformat << Proc.new do |container| out.collect! do |idx| deplate.formatter.format_particle(:format_index, pseudocontainer, idx) end end e.postponed_format << Proc.new do |container| out.delete('') out.compact! container.output(out.join) unless out.empty? end else array << self.new(deplate, src, text, match, args, cmd) end end |
.get_indices(container, deplate, args, text, source) ⇒ Object
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 |
# File 'lib/deplate/commands.rb', line 664 def get_indices(container, deplate, args, text, source) accum = [] auto = args['auto'] auto = deplate.variables['autoindex'] if auto.nil? for i in Deplate::Core.split_list(text, ';', nil, source) # <+TBD IDX+>idx = deplate.add_index(nil, i, deplate.get_current_heading) idx = deplate.add_index(container, i) Deplate::Particle.auto_indexing(deplate, idx) if auto accum << idx container.(source, 'type' => 'index', 'name' => idx.name, 'label' => idx.label ) end return accum end |
Instance Method Details
#finish ⇒ Object
687 688 689 |
# File 'lib/deplate/commands.rb', line 687 def finish return self end |
#process ⇒ Object
691 692 693 694 695 696 697 698 699 |
# File 'lib/deplate/commands.rb', line 691 def process @accum.collect! do |idx| deplate.formatter.format_particle(:format_index, self, idx) end @accum.delete("") @accum.compact! @elt = [ @accum.join ] super end |
#setup_command ⇒ Object
683 684 685 |
# File 'lib/deplate/commands.rb', line 683 def setup_command @accum = Deplate::Command::IDX.get_indices(self, @deplate, @args, @text, @source) end |