Class Texy
Texy! – Convert plain text to XHTML format using {@link process()}.
$texy = new Texy();
$html = $texy->process($text);
- TexyObject
-
Texy
Copyright: Copyright (c) 2004, 2010 David Grudl
Package: Texy
Located at /texy.php
public
|
#
__construct(
)
|
public
void
|
#
setOutputMode(
int
$mode
)
Set HTML/XHTML output mode (overwrites self::$allowedTags) Set HTML/XHTML output mode (overwrites self::$allowedTags) Parameters$mode int |
public
int
|
#
getOutputMode(
)
Get HTML/XHTML output mode Get HTML/XHTML output mode |
protected
|
#
loadModules(
)
Create array of all used modules ($this->modules). Create array of all used modules ($this->modules). This array can be changed by overriding this method (by subclasses) |
final public
|
#
registerLinePattern(
$handler,
$pattern,
$name,
$againTest = NULL
)
|
final public
|
#
registerBlockPattern(
$handler,
$pattern,
$name
)
|
final public
|
#
registerPostLine(
$handler,
$name
)
|
public
string
|
#
process(
string
$text,
bool
$singleLine = false
)
Converts document in Texy! to (X)HTML code. Converts document in Texy! to (X)HTML code. Parameters$text string input text$singleLine bool is single line?Returnsstring output HTML code
|
public
string
|
#
processLine(
string
$text
)
Converts single line in Texy! to (X)HTML code. Converts single line in Texy! to (X)HTML code. Parameters$text string input textReturnsstring output HTML code
|
public
string
|
#
processTypo(
string
$text
)
Makes only typographic corrections. Makes only typographic corrections. Parameters$text string input text (in encoding defined by Texy::$encoding)Returnsstring output text (in UTF-8)
|
public
string
|
#
toText(
)
Converts DOM structure to pure text. Converts DOM structure to pure text. |
final public
string
|
#
stringToHtml(
$s
)
Converts internal string representation to final HTML code in UTF-8. Converts internal string representation to final HTML code in UTF-8. |
final public
string
|
#
stringToText(
$s
)
Converts internal string representation to final HTML code in UTF-8. Converts internal string representation to final HTML code in UTF-8. |
final public
void
|
#
addHandler(
string
$event,
callback
$callback
)
Add new event handler. Add new event handler. Parameters$event string event name$callback callback |
final public
mixed
|
#
invokeAroundHandlers(
string
$event,
TexyParser
$parser,
array
$args
)
Invoke registered around-handlers. Invoke registered around-handlers. Parameters$event string event name$parser TexyParser actual parser object$args array arguments passed into handler |
final public
void
|
#
invokeHandlers(
string
$event,
array
$args
)
Invoke registered after-handlers. Invoke registered after-handlers. Parameters$event string event name$args array arguments passed into handler |
final public static
string
|
#
freezeSpaces(
string
$s
)
Translate all white spaces (\t \n \r space) to meta-spaces \x01-\x04. Translate all white spaces (\t \n \r space) to meta-spaces \x01-\x04. which are ignored by TexyHtmlOutputModule routine Parameters$s string |
final public static
string
|
#
unfreezeSpaces(
string
$s
)
Reverts meta-spaces back to normal spaces. Reverts meta-spaces back to normal spaces. Parameters$s string |
final public static
string
|
#
normalize(
string
$s
)
Removes special controls characters and normalizes line endings and spaces. Removes special controls characters and normalizes line endings and spaces. Parameters$s string |
final public static
string
|
#
webalize(
string
$s,
string
$charlist = NULL
)
Converts to web safe characters [a-z0–9-] text. Converts to web safe characters [a-z0–9-] text. Parameters$s string$charlist string |
final public static
string
|
#
escapeHtml(
string
$s
)
Texy! version of htmlSpecialChars (much faster than htmlSpecialChars!). Texy! version of htmlSpecialChars (much faster than htmlSpecialChars!). note: " is not encoded! Parameters$s string |
final public static
string
|
#
unescapeHtml(
string
$s
)
Texy! version of html_entity_decode (always UTF-8, much faster than original!). Texy! version of html_entity_decode (always UTF-8, much faster than original!). Parameters$s string |
final public static
string
|
#
outdent(
string
$s
)
Outdents text block. Outdents text block. Parameters$s string |
final public
string
|
#
protect(
string
$child,
int
$contentType
)
Generate unique mark – useful for freezing (folding) some substrings. Generate unique mark – useful for freezing (folding) some substrings. Parameters$child string any string to froze$contentType int Texy::CONTENT_* constantReturnsstring internal mark
|
final public
|
#
unProtect(
$html
)
|
final public
bool
|
#
checkURL(
string
$URL,
string
$type
)
Filters bad URLs. Filters bad URLs. Parameters$URL string user URL$type string type: a-anchor, i-image, c-cite |
final public static
bool
|
#
isRelative(
string
$URL
)
Is given URL relative? Is given URL relative? Parameters$URL string URL |
final public static
string
|
#
prependRoot(
string
$URL,
string
$root
)
Prepends root to URL, if possible. Prepends root to URL, if possible. Parameters$URL string URL$root string root |
final public
|
#
getLinePatterns(
)
|
final public
|
#
getBlockPatterns(
)
|
final public
|
#
getDOM(
)
|
final public
|
#
free(
)
PHP garbage collector helper. PHP garbage collector helper. |
final public
|
#
__clone(
)
|
Methods Inherited From TexyObject
getClass(), getReflection(), __call(), __callStatic(), extensionMethod(), __get(), __set(), __isset(), __unset()
ALL |
true # |
NONE |
false # |
VERSION |
'2.1' # |
REVISION |
'9338a11 released on 2010-05-20' # |
CONTENT_MARKUP |
'' # |
CONTENT_REPLACED |
'' # |
CONTENT_TEXTUAL |
'' # |
CONTENT_BLOCK |
'' # |
FILTER_ANCHOR |
'anchor' # |
FILTER_IMAGE |
'image' # |
XML |
2 # |
HTML4_TRANSITIONAL |
0 # |
HTML4_STRICT |
1 # |
HTML5 |
4 # |
XHTML1_TRANSITIONAL |
2 # |
XHTML1_STRICT |
3 # |
XHTML5 |
6 # |
string
|
$encoding | 'utf-8' |
input & output text encoding # |
array
|
$allowed | array (
) |
Texy! syntax configuration # |
TRUE|FALSE|array
|
$allowedTags | NULL |
Allowed HTML tags # |
TRUE|FALSE|array
|
$allowedClasses | true |
Allowed classes # |
TRUE|FALSE|array
|
$allowedStyles | true |
Allowed inline CSS style # |
int
|
$tabWidth | 8 |
TAB width (for converting tabs to spaces) # |
boolean
|
$obfuscateEmail | true |
Do obfuscate e-mail addresses? # |
array
|
$urlSchemeFilters | NULL |
regexps to check URL schemes # |
bool
|
$mergeLines | true |
Paragraph merging mode # |
array
|
$summary | array ( 'images' => array ( ), 'links' => array ( ), 'preload' => array ( ), ) |
Parsing summary # |
string
|
$styleSheet | '' |
Generated stylesheet # |
array
|
$alignClasses | array ( 'left' => NULL, 'right' => NULL, 'center' => NULL, 'justify' => NULL, 'top' => NULL, 'middle' => NULL, 'bottom' => NULL, ) |
CSS classes for align modifiers # |
bool
|
$removeSoftHyphens | true |
remove soft hyphens (SHY)? # |
static
mixed
|
$advertisingNotice | 'once' |
# |
string
|
$nontextParagraph | 'div' |
# |
TexyScriptModule
|
$scriptModule | NULL |
# |
TexyParagraphModule
|
$paragraphModule | NULL |
# |
TexyHtmlModule
|
$htmlModule | NULL |
# |
TexyImageModule
|
$imageModule | NULL |
# |
TexyLinkModule
|
$linkModule | NULL |
# |
TexyPhraseModule
|
$phraseModule | NULL |
# |
TexyEmoticonModule
|
$emoticonModule | NULL |
# |
TexyBlockModule
|
$blockModule | NULL |
# |
TexyHeadingModule
|
$headingModule | NULL |
# |
TexyHorizLineModule
|
$horizLineModule | NULL |
# |
TexyBlockQuoteModule
|
$blockQuoteModule | NULL |
# |
TexyListModule
|
$listModule | NULL |
# |
TexyTableModule
|
$tableModule | NULL |
# |
TexyFigureModule
|
$figureModule | NULL |
# |
TexyTypographyModule
|
$typographyModule | NULL |
# |
TexyLongWordsModule
|
$longWordsModule | NULL |
# |
TexyHtmlOutputModule
|
$htmlOutputModule | NULL |
# |
array
|
$_classes | NULL |
for internal usage # |
|
$_styles | NULL |
# |
array
|
$dtd | NULL |
DTD descriptor. # |
static
|
$strictDTD | NULL |
DEPRECATED # |
|
$cleaner | NULL |
# |
|
$xhtml | NULL |
# |