Download for PHP  R515 (beta)
Welcome » Info pages » Contribute » Integrate
Expand

Input document

.

Upload document:

Integrate

Taking advantage of UverseWiki text formatting is as simple as it can be – the framework has no dependencies besides PHP 5 and mbstring and only requires you to copy its files somewhere.

The most basic usage is just this:

Example 1.php
PHP
require 'uversewiki.php';
$s 'A **wiki** text.';
$doc UWikiDocument::TryParsing($s'wacko');
if (
$doc) { echo $doc->ToHTML(); }

«wacko» is the name of markup module that provides wiki support for our formatting. The above example will use default settings, i.e. loaded from UWikiRootPath/config/ but you can pass your own instance of UWikiSettings:

Example 2.php
PHP
require 'uversewiki.php';

$settings = new UWikiSettings;
$settings->LoadFrom('uwiki_config');
$settings->LoadMarkup('wacko');

$s 'A **wiki** text.';
$doc UWikiDocument::TryParsing($s$settings);
if (
$doc) { echo $doc->ToHTML(); }

When you use static parsing (TryParsing() method of UWikiDocument) exceptions are silented and null is returned when any occurs. However, to have more details and control over the process construct an instance of UWikiDocument and call its instance method Parse() instead:

Example 3.php
PHP
require 'uversewiki.php';

try {
  
$doc = new UWikiDocument('A **wiki** text.');
  
$doc->settings->LoadFrom('uwiki_config');
  
$doc->settings->LoadMarkup('wacko');
  
$doc->Parse();

  echo 
$doc->ToHTML();
} catch (
EUverseWiki $e) {
  echo 
'Error parsing or rendering the document!',
       
' Class 'get_class($e),
       
', message: '.$e->getMessage();
}

EUverseWiki is a common parent class for all UverseWiki exceptions.

Need help?

As of today the project has very sparse documentation and no API reference. However, you can expect our full support via the forum – just start a new topic there (either in English or Russian) and we will help you out.

Languages