Documantation and Test Sandbox.
You are not logged in.
Pages: 1
This thread highlights the new parser features.
Textile extensions.
Code syntax highlighting.
Error reporting.
Enhanced tags.
New tags.
Enhanced smilies.
Enhanced image handling.
Offline
You can use the following textile shortcuts when composing a post:
Phrase elements: This is regular text and _this is emphasized_ and *this is strong* and @this is inline code@. And you can do super^script^ and you can do sub~script~ as well as -deleting- text and +inserting+ text. Bulleted and numbered lists: * Item one. * Item two. # Number one. # Number two.
When you press preview, it looks like this:
Phrase elements:
This is regular text and this is emphasized and this is strong and this is inline code. And you can do superscript and you can do subscript as well asdeletingtext and inserting text.
Bulleted and numbered lists:
Item one.
Item two.
Number one.
Number two.
The textile markup lives for only a brief moment before the pre-parser converts it to bbcode and places it in the textarea input box (the Textile markup is not stored in the database.):
Phrase elements: This is regular text and [i]this is emphasized[/i] and [b]this is strong[/b] and [tt]this is inline code[/tt]. And you can do super[sup]script[/sup] and you can do sub[sub]script[/sub] as well as [del]deleting[/del] text and [ins]inserting[/ins] text. Bulleted and numbered lists: [list] [*]Item one.[/*] [*]Item two.[/*] [/list] [list=1] [*]Number one.[/*] [*]Number two.[/*] [/list]
Offline
You can write a simple CODE tag with no attribute which looks like so:
[code]This is some simple code[/code]
You can add a title message to the code block by adding an attribute to the CODE tag like so:
[code=This is a code block title.]This is some code with a message attribute.[/code]
You can specify a computer language as the first word of the attribute (such as "php"), and the message will have color syntax highlighting applied like so:
<?php ...edited...
//
// Helper preg_replace_callback function for smilies processing.
//
function _do_smilies_callback($matches) {
global $g;
return $g['smilies'][$matches[0]]['html'];
}
//
// Parse message text
//
function parse_message($text, $hide_smilies) {
global $g, $pun_config, $pun_user;
$g['in_signature'] = FALSE;
// Disable images via the $bbcd['in_post'] flag if globally disabled.
if ($pun_config['p_message_img_tag'] !== '1' || $pun_user['show_img'] !== '1')
if (isset($g['bbcd']['img'])) $g['bbcd']['img']['in_post'] = FALSE;
return parse_bbcode($text, $hide_smilies);
}
//
// Parse signature text
//
function parse_signature($text) {
global $g, $pun_config, $pun_user;
$g['in_signature'] = TRUE;
// Disable images via the $bbcd['in_sig'] flag if globally disabled.
if ($pun_config['p_sig_img_tag'] !== '1' || $pun_user['show_img_sig'] !== '1')
if (isset($g['bbcd']['img'])) $g['bbcd']['img']['in_sig'] = FALSE;
return parse_bbcode($text);
}
?>The above PHP code is colorized using the open source "SyntaxHighlighter" Javascript scripts. There are quite a few syntaxes supported including: applescript, as3, bash, coldfusion, c, cpp, csharp, css, delphi, diff, erlang, groovy, java, javafx, js, jscript, perl, php, plain, powershell, python, ruby, sass, scala, sql, vb and 'xml'.
There is an additional dynamic syntax highlighting script for Perl Compatible Regular Expressions (DynamicRegexHighlighter). This script provides mouseover effects which highlight nested grouping brackets. Here is the main regex from the new parser:
'% # re_bbcode Rev:20110220_1200
# First, match opening tag of syntax: "[TAGNAME (= ("\')ATTRIBUTE("\') )]";
\[ # Match opening bracket of outermost opening TAGNAME tag.
(?>(b|code|color|colour|del|email|em|h|img|ins|i|table|tr|th|td|list|\*|quote|sub|sup|s|tt|url|u|vimeo|youtube|err|dbug)\s*+) # $1:
(?> # Atomically group remainder of opening tag.
(?: # Optional attribute.
(=)\s*+ # $2: = Optional attribute\'s equals sign delimiter, ws.
(?: # Group for 1-line attribute value alternatives.
\'([^\'\r\n\\\\]*+(?:\\\\.[^\'\r\n\\\\]*+)*+)\' # Either $3: == single quoted,
| "([^"\r\n\\\\]*+(?:\\\\.[^"\r\n\\\\]*+)*+)" # or $4: == double quoted,
| ( [^[\]\r\n]*+ # or $5: == un-or-any-quoted. "normal*" == non-"[]"
(?: # Begin "(special normal*)*" "Unrolling-the-loop" construct.
\[[^[\]\r\n]*+\] # Allow matching [square brackets] 1 level deep. "special".
[^[\]\r\n]*+ # More "normal*" any non-"[]", non-newline characters.
)*+ # End "(special normal*)*" "Unrolling-the-loop" construct.
) # End $5: Un-or-any-quoted attribute value.
) # End group of attribute values alternatives.
\s*+ # Optional whitespace following quoted values.
)? # End optional attribute group.
\] # Match closing bracket of outermost opening TAGNAME tag.
) # End atomic group with opening tag remainder.
# Second, match the contents of the tag.
( # $6: Non-trimmed contents of TAGNAME tag.
(?> # Atomic group for contents alternatives.
[^\[]++ # Option 1: Match non-tag chars (starting with non-"[").
(?: # Begin "(special normal*)*" "Unrolling-the-loop" construct.
(?!\[/?+\1[\]=\s])\[ # "special" = "[" if not start of [TAGNAME*] or [/TAGNAME].
[^\[]*+ # More "normal*".
)*+ # Zero or more "special normal*"s allowed for option 1.
| (?: # or Option 2: Match non-tag chars (starting with "[").
(?!\[/?+\1[\]=\s])\[ # "special" = "[" if not start of [TAGNAME*] or [/TAGNAME].
[^\[]*+ # More "normal*".
)++ # One or more "special normal*"s required for option 2.
| (?R) # Or option 3: recursively match nested [TAGNAME]..[/TAGNAME].
)*+ # One of these three options as many times as necessary.
) # End $6: Non-trimmed contents of TAGNAME tag.
# Finally, match the closing tag.
\[/\1\s*+\] # Match outermost closing [/ TAGNAME ]
%ix'Offline
When attempting to post a message having BBCode syntax errors, a message preview is presented with the erroneous tags highlighted in red. Placing the mouse cursor over these red tags reveals helpful tooltip error messages. Here is an example which attempts to demonstrate every error recognized by the parser:
Error 1. This error does not generate an ERR tag.
Error 2. [b=xyz]This is bold content[/b]
Error 3. [list=xyz]stuf inside a list[/list]
Error 4s. [color=[b]]Put a bbcode open tag inside an attribute[/color]
Error 4b. [color=[/b]]Put a bbcode close tag inside an attribute[/color]
Error 5. [color]These tags require an attribute value[/color]
Error 6. link nested link text text
Error 7. link nested link text text
Error 8. link [quote]nested link text[/quote] text
Error 9. [*]This ain't gonna happen.[/*]
Error 10a.[img]xyzcorp@gizko[/img]
Error 10b.[url=xyzcorp@gizko]Link text[/url]
Error 11. [color=#FFxF]This is color xyz[/color]
Error 12. [youtube]This is not valid youtube content![/youtube]
Error 13. cannot reproduce this error.
Error 14. cannot reproduce this error.
Error 15. [img]http://www.jmrware.com/[/img]
Error 16. [img]http://jmrware.com/no-can-do.txt[/img]
Error 17. cannot reproduce this error.
Error 18. [/b].
Error 19. [i].
And you CAN SET YOUR OWN ERROR MESSAGES!
Offline
These are all the tags currently recognized by FluxBB 1.4.3:
This is a plain quote with no attribute.
This is a quote with a "quote attribute" attribute.
This line has bold text.
This line has italic text.
This line has underlined text.
This line has strike text.
This line has deleted text.
This line has inserted text.
This line has emphasized text.
This line has colored text.
This line has coloured text.
This line has http://jmrware.com a no-attribute URL.
This line has an attribute URL.
This line has jmr@example.com a no-attribute email.
This line has an attribute email.
Default bulleted list: no-attribute
one
two
Bulleted list: attribute='*'
one
two
Numeric list: attribute='1'
one
two
Alpha list: attribute='a'
one
two
This is code
Offline
Quote tags are now, by default, linkified back to the original. This behavior is controlled via the new: "Linkify QUOTE citation" parser option. When ON, a quoted post links back to the original like so:
This thread highlights the new parser features.
Textile extensions.
Code syntax highlighting.
Error reporting.
Enhanced tags.
New tags.
Enhanced smilies.
Enhanced image handling.
The graphical display of images within quotes is controlled via new parser admin config option: "Display QUOTE images". When this option is off, then images within quotes are NOT show graphically, but rather as text hyperlinks to the original.
This is an image: {image} inside a quote.
The COLOR (and COLOUR) tags now allow specifying both the forground and background colors. To set both, specify the foreground color first followed by the background color second separated by a semi-colon like so: color=#000;#FFF or color=#FFCC00;green or color=white;purple or color=purple;white. Note also that the color value can be one of the recognized CSS color names (English): maroon, red, orange, yellow, olive, purple, fuchsia, white, lime, green, navy, blue, aqua, teal, black, silver, or gray.
The CODE tag allows an attribute which may contain a computer language specified as the first word. Syntax highlighting is applied for known languages.
#include <stdio.h>
void main(void) {
printf("Hello, world.");
}During pre-parsing, the remote image files of IMGs tags are checked. The remote image is queried to verfy that its Content-Type is "image" and its size is less than the parser option: "max_size". If the "valid_imgs" option is set to yes, then images with dimensions greater than the default are scaled down to fit within the default box.
Offline
TT - "Teletype" inline CODE tag. This line has [tt] - "Teletype" inline CODE where anything goes [i]even[/i] [b]tags[/b] (just like the [code] block code.{/code] tag).[/tt].
SUP - Super-script tag. This line has the SUP tag for superscript.
SUB - Sub-script tag. This line has the SUB tag for subscript.
ERR - Error tag. This is used to identify bad BBcode markup. The offending tags are wrapped in the ERR tags like so: [BADTAG]Bad tag markup[/BADTAG]
DBUG - Debug tag. This block tag provides a place to write debug information. For example:
This is some debug content.
Video: YOUTUBE & VIMEO - Embedded video player.
youtube: and vimeo: .
Basically, these and any other tags you would like to add (or remove) are available. Although most useful codes are already provided by default, adding a new one is as easy as editing the bbcd_source.php and adding a new member to the $bbcd global array. Tags can be removed by deleting or commenting them out from this file.
Lets say you want: "V" to represent html element "VAR" (i.e. The parser will convert: "[v]$variable[/v]", into: "<var>$variable</var>". Implementing this is easy. Edit: include/bbcd_source.php and add the following member to the $bbcd array.
'v' => array(
'html_name' => 'var'
),Go to the Parser admin panel and click: "Reset". This re-compiles the source BBCode data file into the runtime cache file.
You're done. That's all there is to it.
But lets say you also want to be able to specify an optional attribute with this tag that is transformed into a tooltip (i.e. html TITLE atttribute message that appears when moused over). This involves writing format conversion strings (which use a simplified printf-like syntax). The %a_str% and %c_str% tokens are replaced with the actual attribute and contents of the tag. Here are the format strings we'll use for our enhanced var tag:
'v' => array(
'html_name' => 'var',
'handlers' => array(
'ATTRIB' => array(
'format' =>
'<var title="%a_str%">%c_str%</var>'
),
'NO_ATTRIB' => array(
'format' =>
'<var>%c_str%</var>'
)
)
),
The NO_ATTRIB handler is used when there is no attribute provided and the ATTRIB handler is used when an attribute is present. There are other properties that can be set when specifying a new tag. Read the $bbcd documentation for more.
Offline
The new parser pre-compiles the smiley data and generates all the HTML markup ahead of time. Previously this work was (unecessarily) being performed during real time parsing. Also, all smiley image files are verified at compile time and are checked for file type and size.
Smilies can consist of an image having any size and aspect ratio, and all smiley images are scaled to fit inside a 15x15 pixel box. The original image aspect ratio is preserved.
Smilies are forced to fit within a box (which defaults to 15x15 pixels), but this box may be scaled up by a percentage specified in the parser admin panel, resulting in smilies being displayed larger. (15 pixels is too small to see on many of today's hi-res monitors.)
Smilies are managed and may be uploaded via the parser admin panel. The uploading code is enabled only when the PHP settings allow this. The filesize is checked against the avatar filesize and the file content-type is verified to be of type: "image".
Offline
The IMG tag now allows specifying a width and height for displaying remote images. The width and height may be specified independently or together. When specified, the parser interprets these values as a constraining box, into which the image must fit. These width and height values may be placed anywhere in the attribute but are typically placed at the end of the attribute separated with a semicolon or space. These values are stripped from the attribute and are not included in the alt text. Here is an example with one image being displayed within three different box sizes:
[img=This is alternate text;100x100]http://jmrware.com/articles/2001/phyn/InspoLaunchFull.jpg[/img] [img=This is alternate text;200x200]http://jmrware.com/articles/2001/phyn/InspoLaunchFull.jpg[/img] [img=This is alternate text;300x300]http://jmrware.com/articles/2001/phyn/InspoLaunchFull.jpg[/img]
If the server settings allow PHP to open remote files (i.e. ini_get('allow_url_fopen') == TRUE), then the "Validate remote IMG" parser config option becomes available and may be turned on. When on, this option causes the parser to check each remote image file specified in an IMG tag for file size, file content-type and pixel dimensions.
If the remote file size (bytes) is larger than the parser config option: "Maximum IMG filesize", then the IMG tag is automatically converted to a URL tag link during pre-parsing and the image is not displayed graphically but instead appears on the forum as a text link to the image (large images dramatically increase page load time).
If the remote image pixel dimensions are larger than the "Default media XY" parser option, then the image is scaled down to fit and the width and height information is embedded into the IMG tag's attribute (it is created if it doesn't already exist). Otherwise if the remote image does naturally fit within the default box, then no width/height specs are placed in the attribute and the browser displays the image full size.
If the parser config option: "Make IMG clickable" is on, then IMG tags are wrapped inside a URL link to the remote image (unless the IMG tag is inside URL link text - doing so would be invalid markup).
If the parser config option: "Display IMG in QUOTE" is off (default), then images within quotes are not displayed graphically, but are instead displayed as a text link to the remote image (unless the IMG tag is within a URL, in which case the bare image url is displayed between curly braces). The link text is a language specific message otherwise (i.e. "Image link").
The old do_clickable() function has been replaced with a new linkify() function (which resides in the functions.php file). This new function recognizes links to image files (which end in GIF, JPG, JPEG or PNG) and creates an IMG tag rather than a URL tag. (The image url is also validated before it is linkified.)
Offline
Pages: 1