Class: PointBlank::Parsing::LinkReferenceOverlay

Inherits:
NullOverlay show all
Includes:
LinkSharedMethods
Defined in:
lib/mmmd/blankshell.rb

Overview

Overlay for link reference definitions

Instance Method Summary collapse

Methods included from LinkSharedMethods

#balanced?, #find_balanced_end, #normalize_label, #process_destination, #process_title, #read_destination, #read_label, #read_properties, #read_return_label, #read_title

Methods inherited from NullOverlay

begin?

Methods inherited from NullParser

begin?, #close, #consume, #parsed_content

Constructor Details

#initializeLinkReferenceOverlay

Returns a new instance of LinkReferenceOverlay.



845
846
847
848
# File 'lib/mmmd/blankshell.rb', line 845

def initialize
  super
  @definitions = {}
end

Instance Method Details

#process(block, **_lazy) ⇒ nil, Class

Process block after it closed

Parameters:

Returns:

  • (nil, Class)


851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
# File 'lib/mmmd/blankshell.rb', line 851

def process(block, **_lazy)
  text = block.content
  loop do
    prev = text
    label, text = read_label(text)
    break prev unless label

    destination, text = read_destination(text)
    break prev unless destination

    title, text = read_title(text)
    push_definition(label, destination, title)
  end
  modify(block, text)
  nil
end