Class: Kitchen::Directions::BakeChapterReferences::V2
- Defined in:
- lib/kitchen/directions/bake_chapter_references/v2.rb
Instance Method Summary collapse
- #bake(chapter:, metadata_source:, uuid_prefix: '.', klass: 'references') ⇒ Object
- #bake_cite(chapter:) ⇒ Object
- #bake_references(chapter:) ⇒ Object
Instance Method Details
#bake(chapter:, metadata_source:, uuid_prefix: '.', klass: 'references') ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/kitchen/directions/bake_chapter_references/v2.rb', line 5 def bake(chapter:, metadata_source:, uuid_prefix: '.', klass: 'references') bake_cite(chapter: chapter) bake_references(chapter: chapter) return if chapter.references.none? content = chapter.references.cut.paste Kitchen::Directions::CompositePageContainer.v1( container_key: klass, uuid_key: "#{uuid_prefix}#{klass}", metadata_source: , content: content, append_to: chapter ) end |
#bake_cite(chapter:) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/kitchen/directions/bake_chapter_references/v2.rb', line 22 def bake_cite(chapter:) chapter.search('[data-type="cite"]').each do |link| link.prepend(child: <<~HTML <sup class="os-end-note-number">#{link.count_in(:chapter)}</sup> HTML ) link.search('.delete-me').trash end end |
#bake_references(chapter:) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/kitchen/directions/bake_chapter_references/v2.rb', line 34 def bake_references(chapter:) chapter.references.each do |reference| Kitchen::Directions::RemoveSectionTitle.v1(section: reference) reference.search('a').each do |ref_link| ref_link.replace_children(with: <<~HTML <span>#{ref_link.count_in(:chapter)}.</span> HTML ) end end end |