Ajax software
Free javascripts
↑
Main Page
$translated = custom_markup_translate($markup);
echo $translated;
}
else
{
// display error message
echo “Couldn’t open $file_name!”;
}
?>
</body>
</html>
4.
Load
http://seophp.example.com/test_markup.php
, and expect to get the results shown
in Figure 6-14.
Figure 6-14
This was a simple example, but we’re sure you can intuit how useful this system can be when building a
more complex content management system. This little script currently knows how to handle these custom
markup tags, whose significance is obvious:
{bold}
,
{italic}
,
{underline}
,
{heading}
,
{subhead-
ing}
,
{link}
,
{elink}
(this is a link that opens a new window),
{unordered-list}
,
{ordered-list}
,
{list-element}
,
{picture}
, and
{comment}
.
The markup file,
markup.txt
, doesn’t contain any HTML elements, but custom markup elements. How
-
ever, with the help of a simple (but quite long) custom markup library, you’re replacing on-the-fly all the
custom markup elements with standard HTML tags.
The
custom_markup_translate()
function consists mainly of a number of regular expression replace-
ments, which transform the custom markup code to HTML. We’re leaving understanding this function
for you as an exercise.
148
Chapter 6: SE-Friendly HTML and JavaScript
c06.qxd:c06 10:55 148
Ajax software
Free javascripts
→