Class: Deplate::Regions::LinkMap

Inherits:
Deplate::Region show all
Defined in:
lib/deplate/mod/linkmap.rb

Overview

register links into a map for this source (each source has own map). Use link macro to access a link by key. The LinkMap can exist anywhere in the document, even at the end.

#LinkMap <<— Example: www.example.com Example News: news.example.com


Instance Method Summary collapse

Methods inherited from Deplate::Region

check_file, clean_strings, #deprecated_regnote, deprecated_regnote, #finish_accum, #format_compound, regions, register_as, set_line_cont, #setup

Methods inherited from Element

#join_lines, #join_lines_re_zh_cn

Instance Method Details

#finishObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/deplate/mod/linkmap.rb', line 57

def finish
    finish_accum
    sid = @args['global'] ? :global : @deplate.current_source.object_id
    log(['LinkMap', sid, @accum.inspect], :debug)
    @accum.each do |line|
        key, link = line.split(/:\s*/, 2).map {|e| e.strip}
        if key and link
            Deplate::LinkMap.set(sid, key, link)
        else
            log(['Malformed LinkMap entry', line.inspect], :error)
        end
    end
    return nil
end