Parsoid
A bidirectional parser between wikitext and HTML5
Parsoid Namespace Reference

This is a demonstration of content model handling in extensions for Parsoid. More...

Namespaces

 Html2Wt
 Serializes language variant markup, like `-{ ...
 
 Utils
 This file contains general utilities for: (a) querying token properties and token types (b) manipulating tokens, individually and as collections.
 
 Wt2Html
 Front-end/Wrapper for a particular tree builder, in this case the parser/tree builder from RemexHtml.
 

Classes

class  ClientError
 Exception thrown on invalid client requests. More...
 
class  ConstantLanguageGuesser
 A simple LanguageGuesser that returns the same "source language" for every node. More...
 
class  ContentModelHandler
 
class  ConversionTraverser
 
class  CrhConverter
 
class  DataParsoid
 Parsoid data for a DOM node. More...
 
class  EnConverter
 
class  InternalException
 Parsoid internal error that we don't know how to recover from. More...
 
class  KuConverter
 
class  Language
 
class  LanguageConverter
 Base class for language variant conversion. More...
 
class  LanguageCrh
 
class  LanguageEn
 
class  LanguageGuesser
 An oracle that gives you a predicted "source language" for every node in a DOM, which is used when converting the result back to the source language during round-tripping. More...
 
class  LanguageKu
 
class  LanguageSr
 
class  LanguageZh
 
class  MachineLanguageGuesser
 Use a { ReplacementMachine} to predict the best "source language" for every node in a DOM. More...
 
class  PageBundle
 PORT-FIXME: This is just a placeholder for data that was previously passed to entrypoint in JavaScript. More...
 
class  Parsoid
 
class  ResourceLimitExceededException
 Parsoid resource limit exception. More...
 
class  Selser
 PORT-FIXME: This is just a placeholder for data that was previously passed to entrypoint in JavaScript. More...
 
class  SrConverter
 
class  WikitextContentModelHandler
 
class  ZhConverter
 
class  ZhReplacementMachine
 

Functions

 docFragToString ( $docFrag, $force)
 
 LocationData ( $wiki, $title, $meta, $reqId, $userAgent)
 
 ParsoidLogData ( $logType, $logObject, $locationData)
 
 ParsoidLogger ( $env)
 

Variables

 $ParsoidExtApi = $module->parent->require( './extapi.js' )->versionCheck( '^0.10.0' )
 
 $temp0
 
 $DOMDataUtils = $temp0::DOMDataUtils
 
 $DOMUtils
 
 $Promise
 
 $addMetaData
 
 $JSONExt
 
 $PARSE_ERROR_HTML
 
 $validityCache = new Map()
 
 $languageNameCache = new Map()
 
$module exports Language = $Language
 
$module exports LanguageConverter = $LanguageConverter
 
$module exports = $LanguageCrh
 
 $LogData
 
 $JSUtils = require( '../utils/jsutils.js' )::JSUtils
 
 $Logger
 
 $prettyLogTypeMap
 
 $Util = require './Util.js'::Util
 
 $Diff = []
 
 $diffTokens
 

Detailed Description

This is a demonstration of content model handling in extensions for Parsoid.

Diff tools.

Chinese conversion code.

Serbian (Српски / Srpski) specific code.

Kurdish conversion code.

English ( / Pig Latin) conversion code.

Crimean Tatar (Qırımtatarca) conversion code.

A bidirectional Language Converter, capable of round-tripping variant conversion.

Base class for Language objects.

It implements the "json" content model, to allow editing JSON data structures using Visual Editor. It represents the JSON structure as a nested table. ext/JSON

Language conversion is as DOMPostProcessor pass, run over the Parsoid-format HTML output, which may have embedded language converter rules. We first assign a (guessed) source variant to each DOM node, which will be used when round-tripping the result back to the original source variant. Then for each applicable text node in the DOM, we first "bracket" the text, splitting it into cleanly round-trippable segments and lossy/unclean segments. For the lossy segments we add additional metadata to the output to record the original source variant text to allow round-tripping (and variant-aware editing).

Like in the PHP implementation, each individual language has a dynamically-loaded subclass of Language, which may also have a LanguageConverter subclass to load appropriate ReplacementMachines and do other language-specific customizations.

Variable Documentation

◆ $addMetaData

Parsoid\$addMetaData
Initial value:
= $temp0->
addMetaData

◆ $diffTokens

Parsoid\$diffTokens
Initial value:
= function ( $oldString, $newString, $tokenize ) use ( &$simpleDiff ) {
if ( $oldString === $newString ) {
return [ [ '=', [ $newString ] ] ];
} else {
return simpleDiff::diff( $tokenize( $oldString ), $tokenize( $newString ) );
}
}

◆ $DOMUtils

Parsoid\$DOMUtils
Initial value:
= $temp0::
DOMUtils

◆ $JSONExt

Parsoid\$JSONExt
Initial value:
= function () {
$this->config = [
'contentmodels' => [
'json' => $this
]
];
}

◆ $LogData

Parsoid\$LogData
Initial value:
= function ( $logType, $logObject ) {
$this->logType = $logType;
$this->logObject = $logObject;
$this->_error = new Error();
$this->_cache = [];
}

◆ $Logger

Parsoid\$Logger
Initial value:
= function ( $opts ) {
if ( !$opts ) { $opts = []; }
$this->_opts = $opts;
$this->_logRequestQueue = [];
$this->_backends = new Map();
$this->_testAllRE = new RegExp( '/^$/' );
$this->_samplers = [];
$this->_samplersRE = new RegExp( '/^$/' );
$this->_samplersCache = new Map();
}

◆ $PARSE_ERROR_HTML

Parsoid\$PARSE_ERROR_HTML
Initial value:
=
'<!DOCTYPE html><html>'
. '<body>'
. "<table data-mw='{\"errors\":[{\"key\":\"bad-json\"}]}' typeof=\"mw:Error\">"
. '</body>'

◆ $prettyLogTypeMap

Parsoid\$prettyLogTypeMap
Initial value:
= [
'debug' => '[DEBUG]'

◆ $Promise

Parsoid\$Promise
Initial value:
= $temp0::
Promise

◆ $temp0

Parsoid\$temp0
Initial value:
=
$ParsoidExtApi