Y-Code parser
A parser for a customized markup language used on http://y-ch.at/
This PHP-based Y-code to HTML converter is based on a PHP port of my
will_scan_string gem.
I'm not a PHP developer. The code therefore contains some nasty hacks.
Requirements
These scripts will not work in PHP 5.2 or below and are only tested in PHP 5.3.6 and PHP 5.3.8, but should work in older versions of 5.3.
Installation
Download and copy regexp_traits.php, util.php, will_scan_string.php and
ycode.php to any folder you like.
Include ycode.php in your PHP script to use the y2html function to convert
your Y-code string to HTML.
Example, assuming you stored the PHP files in the folder ycode/:
require_once("ycode/ycode.php");
print y2html("^1Hello ^4world!");Also, for coloring to work, you need to add something like this to your CSS:
.color, .color0, .color8, .color9 { color: inherit; }
.color0 { color: inherit; }
.color1 { color: red; }
.color2 { color: green; }
.color3 { color: #ffcc00; }
.color4 { color: blue; }
.color5 { color: #00ffff; }
.color6 { color: purple; }
.color7 { color: #ffffff; }Run test/_all.php to test if the parser is working properly.
Y-Code Syntax
http://www.google.com/Will be converted to a clickable link with text[www.google.com].^1red^0Will be converted to a red-colored wordred.^0'till^9switches colors. You can modify the CSS classcolor0'tillcolor9to change the colors.http://www.youtube.com/watch?v=FErzTCzR5N4Will be converted with an embedded youtube video.- Any URL ending with
.jpg,.pngor.gifwill be converted to an embedded image. [rauw]text[/rauw]Will be converted to a bunch of DIVs and SPANs. Is used like a spoiler-tag on y-ch.at, but this package lacks the required Javascript code to make it work.~~~~\r\nName:\r\nMessage\r\n~~~~Will be converted to a quote._bold_Will be converted to the wordboldin bold text.// tobyhinloopenWill be converted to a link touser_by_username.php?username=tobyhinloopenwith the texttobyhinloopen.- Newlines will be converted to
<br />'s. - HTML entities will be escaped.