Hello, I am creating a project, and I need to be able to use a regex(or if something else is preferable?)
Basically, I need to convert a PHPish markup code page so that the "non-code" is converted into "code." For instance:
Orginal:
<?code
echo 'some text';
?>
<head>
</head>
<body>
</body>
<?code
echo '</html>';
?>
Converted:
<?code
echo '<html>';
echo '
<head>
</head>
<body>
</body>';
echo '</html>';
?>
How could this work while also taking quotes into account? (like <?code $var='<?code stuff ?>';?>
Also, if someone provided me with something to detect included files, (to replace with something that first "prepossesses" the file then includes it) (where the includes are similar to PHP)
Is this even possible with Regex? I know your not suppose to try to parse HTML with regex, but this isn't trying to parse it, it's really being quite dumb to how the markup and everything is..
Also, this project will actually be implemented in Ruby(the preprocessor that is), so if there is something Ruby has that would aid in this, then have at it.
I know the code looks very similar to PHP, but thats because it is, but it will not be implemented in PHP and the "code" used won't actually be PHP, but it will use a <?
type mechanism for containing code in markup.
Edit: also note that the language inside the markup can for all practical purposes be Ruby. So it can contain quotes and comments that have the closing code tag.