Parsoid
A bidirectional parser between wikitext and HTML5
Loading...
Searching...
No Matches
Wikimedia\Parsoid\Html2Wt\WikitextEscapeHandlers Class Reference

Public Member Functions

 __construct (Env $env, ?string $extName)
 
 isFirstContentNode (Node $node)
 
 thHandler (Node $thNode, SerializerState $state, string $text, array $opts)
 
 mediaOptionHandler (SerializerState $state, string $text)
 
 wikilinkHandler (SerializerState $state, string $text)
 
 aHandler (SerializerState $state, string $text)
 
 tdHandler (Node $tdNode, bool $inWideTD, SerializerState $state, string $text, array $opts)
 
 tokenizeStr (string $str, bool $sol)
 Tokenize string and pop EOFTk.
 
 textCanParseAsLink (Node $node, SerializerState $state, string $text)
 
 escapedText (SerializerState $state, bool $sol, string $origText, bool $fullWrap=false, bool $dontWrapIfUnnecessary=false)
 This function attempts to wrap smallest escapable units into nowikis (which can potentially add multiple nowiki pairs in a single string).
 
 escapeWikitext (SerializerState $state, string $text, array $opts)
 
 escapeTplArgWT (string $arg, array $opts)
 General strategy:
 
 escapeLinkContent (SerializerState $state, string $str, bool $solState, Node $node, bool $isMedia)
 See also escapeLinkTarget in LinkHandler.php.
 

Member Function Documentation

◆ escapedText()

Wikimedia\Parsoid\Html2Wt\WikitextEscapeHandlers::escapedText ( SerializerState $state,
bool $sol,
string $origText,
bool $fullWrap = false,
bool $dontWrapIfUnnecessary = false )

This function attempts to wrap smallest escapable units into nowikis (which can potentially add multiple nowiki pairs in a single string).

The idea here is that since this should all be text, anything that tokenizes to another construct needs to be wrapped.

Full-wrapping is enabled if the string is being escaped within context-specific handlers where the tokenization context might be different from what we use in this code.

Parameters
SerializerState$state
bool$sol
string$origText
bool$fullWrap
bool$dontWrapIfUnnecessary
Returns
string

◆ escapeLinkContent()

Wikimedia\Parsoid\Html2Wt\WikitextEscapeHandlers::escapeLinkContent ( SerializerState $state,
string $str,
bool $solState,
Node $node,
bool $isMedia )

See also escapeLinkTarget in LinkHandler.php.

Parameters
SerializerState$state
string$str
bool$solState
Node$node
bool$isMedia
Returns
string

◆ escapeTplArgWT()

Wikimedia\Parsoid\Html2Wt\WikitextEscapeHandlers::escapeTplArgWT ( string $arg,
array $opts )

General strategy:

Tokenize the arg wikitext. Anything that parses as tags are good and we need not bother with those. Check for harmful characters [[]]{{}} or additionally = in positional parameters and escape those fragments since these characters could change semantics of the entire template transclusion.

This function makes a couple of assumptions:

  1. The tokenizer sets tsr on all non-string tokens.
  2. The tsr on TagTk and EndTagTk corresponds to the width of the opening and closing wikitext tags and not the entire DOM range they span in the end.
Parameters
string$arg
array$opts[ 'serializeAsNamed' => bool, 'numPositionalArgs' => int, 'argPositionalIndex' => int, 'type' => string, 'numArgs' => int, 'argIndex' => int ]
Returns
array

◆ escapeWikitext()

Wikimedia\Parsoid\Html2Wt\WikitextEscapeHandlers::escapeWikitext ( SerializerState $state,
string $text,
array $opts )
Parameters
SerializerState$state
string$text
array$opts[ 'node' => Node, 'inMultilineMode' => ?bool, 'isLastChild' => ?bool ]
Returns
string

◆ tdHandler()

Wikimedia\Parsoid\Html2Wt\WikitextEscapeHandlers::tdHandler ( Node $tdNode,
bool $inWideTD,
SerializerState $state,
string $text,
array $opts )
Parameters
Node$tdNode
bool$inWideTD
SerializerState$state
string$text
array$opts[ 'node' => ?Node ]
Returns
bool

◆ thHandler()

Wikimedia\Parsoid\Html2Wt\WikitextEscapeHandlers::thHandler ( Node $thNode,
SerializerState $state,
string $text,
array $opts )
Parameters
Node$thNode
SerializerState$state
string$text
array$opts[ 'node' => Node ]
Returns
bool

◆ tokenizeStr()

Wikimedia\Parsoid\Html2Wt\WikitextEscapeHandlers::tokenizeStr ( string $str,
bool $sol )

Tokenize string and pop EOFTk.

Parameters
string$str
bool$sol
Returns
array

The documentation for this class was generated from the following file: