class WPV_Editor_Parser

 Methods

Initialize the parser

__construct(string $content, array $shortcodes) 

Parameters

$content

string

string to parse

$shortcodes

array

list of supported shortcodes and their options

Creates a tree of the content

parse() : \[type]

Two special node types: 1. ROOT - a single root element 2. text - unrecognized shortcodes and text blocks. Adjascent text nodes are collapsed together

Returns

\[type][description]

Get atrributes when inside an opening shortcode tag

get_attributes(int $pos) 

Parameters

$pos

int

parser position

Get shortcode type

get_type(int $pos) : array

Parameters

$pos

int

parser position

Returns

arrayarray of two elements - shortcode type and parser position

Moves the parser position at the end of the whitespace

ignore_whitespace(int $pos) : int

Parameters

$pos

int

parser position

Returns

intparser position

Whether a shortcode of type $type accepts nested shortcodes

is_accepting(string $type) : boolean

Parameters

$type

string

shortcode type

Returns

booleantrue if nested shortcodes are enabled for $type

Whether a shortcode of type $type is supported by the Vamtam editor

is_supported(string $type) : boolean

Parameters

$type

string

shortcode type

Returns

booleantrue if a shortcode of type $type is supported by the Vamtam editor

Maps the list of supported shortcodes to $this->accepting and $this->supported (i.e.

known_shortcodes() 

splits the original list in two)

Constructs a new node

new_block(string $type, \object $parent) : object

Parameters

$type

string

node type

$parent

\object

reference to the new node's parent node

Returns

objectnewly constructed node

Initial cleanup of the content

prepare() : string

Returns

stringcleaned up content

Trims unrecognized shortcodes and arbitrary text and puts it in a text node

trim_text_nodes(int $pos) : int

Parameters

$pos

int

parser position

Returns

intparser position after trimming the text