Class: Brandish::Processors::All::Literal

Inherits:
Brandish::Processor::Base show all
Includes:
Brandish::Processor::Block
Defined in:
lib/brandish/processors/all/literal.rb

Overview

Takes the contents of the block, and outputs it, without any processing. This is used to bypass any text processing processors that are being used. This does nothing for command or block elements in the literal block, and the existance of such elements will cause errors.

Because of the way the parser works, the original source text information is discarded for command and block elements, since they are unneeded for building the nodes. This means that it is not possible to reconstruct, from only the AST, the original text without slight variances (which we don't want). (The other option would be to use the location information to grab it from the file itself, but as of right now, location information is unreliable.) This is why the literal tag cannot contain other command or block elements.

This processor takes no options, nor any pairs.

Examples:

<l>**Test**</l> this.
# => "**Test** this."

Instance Attribute Summary

Attributes inherited from Brandish::Processor::Base

#context

Instance Method Summary collapse

Methods included from Brandish::Processor::Block

included, #process_block

Methods inherited from Brandish::Processor::Base

#accept, #call, #initialize, #postprocess, #process_block, #process_command, #process_root, #process_text, register, #setup

Constructor Details

This class inherits a constructor from Brandish::Processor::Base

Instance Method Details

#perform::String

Preforms the literalizing of the body. Right now, this just uses Brandish::Parser::Node::Root#flatten.

Returns:

  • (::String)


36
37
38
# File 'lib/brandish/processors/all/literal.rb', line 36

def perform
  @body.flatten
end