JavaScript Editor Ajax software     Free javascripts 



Main Page

markup language allows the copywriter to break into HTML for particularly complex cases by using
an “{HTML}” tag.
This solution is employed later in the example e-commerce site, but try a quick example of its use now.
Implementing a Custom Markup Translator
1.
Create a new file named
custom_markup.inc.php
in your
seophp/include
folder, and type
this code in:
<?php
function custom_markup_translate($str)
{
// array with regular expressions that match custom tags
$search = array(
‘#\{bold}(.*?)\{/bold}#is’,
‘#\{italic}(.*?)\{/italic}#is’,
‘#\{underline}(.*?)\{/underline}#is’,
‘#\{heading}(.*?)\{/heading}#is’,
‘#\{subheading}(.*?)\{/subheading}#is’,
‘#\{link:(.*?)}(.*?)\{/link}#is’,
‘#\{elink:(.*?)}(.*?)\{/elink}#is’,
‘#\{unordered-list}(.*?)\{/unordered-list}\s*#is’,
‘#\{ordered-list}(.*?)\{/ordered-list}\s*#is’,
‘#\\s*{list-element}(.*?)\{/list-element}\s*#is’,
‘#\{picture:(.*?)}#is’,
‘#\t#‘,
‘#\{comment}(.*?)\{/comment}#is’
);
// array with HTML replacements
$replace = array(
‘<b>\\1</b>’,
‘<i>\\1</i>’,
‘<u>\\1</u>’,
‘<h1 class=some_class>\\1</h1>’,
‘<h2 class=some_other_class>\\1</h2>’,
‘<a href=\‘\\1\‘>\\2</a>’,
‘<a href=\‘\\1\‘ target=”_blank”>\\2</a>’,
‘<ul>\\1</ul>’,
‘<ol>\\1</ol>’,
‘<li>\\1</li>’,
‘<img src=”\\1” border=”0”>’,
‘’,
‘’
);
// perform the replacement
$step_1 = preg_replace($search, $replace, $str);
$step_2 = preg_split(‘#(\{HTML\}.*?\{/HTML\})#is’, $step_1, -1,
PREG_SPLIT_DELIM_CAPTURE);
$return = ‘’;
146
Chapter 6: SE-Friendly HTML and JavaScript
c06.qxd:c06 10:55 146


JavaScript Editor Ajax software     Free javascripts