handle(text, code_object = nil, &block)public
Look for directives in a chunk of text.
Options that we don’t handle are yielded. If the block returns false the directive is restored to the text. If the block returns nil or no block was given the directive is handled according to the registered directives. If a String was returned the directive is replaced with the string.
If no matching directive was registered the directive is restored to the text.
If code_object is given and the param is set as metadata on the code_object. See RDoc::CodeObject#metadata
# File lib/rdoc/markup/pre_process.rb, line 60 def handle text, code_object = nil, &block encoding = if defined?(Encoding) then text.encoding else nil end # regexp helper (square brackets for optional) # $1 $2 $3 $4 $5 # [prefix][\]:directive:[spaces][param]newline text.gsub!(/^([ \t]*(?:#|\/?\*)?[ \t]*)(\\?):(\w+):([ \t]*)(.+)?\n/) do # skip something like ':toto::' next $& if $4.empty? and $5 and $5[0, 1] == ':' # skip if escaped next "#$1:#$3:#$4#$5\n" unless $2.empty? handle_directive $1, $3, $5, code_object, encoding, &block end text end