Jump to content

[SOLVED] Code Tags


proggR

Recommended Posts

Does anybody know how the code tags work? How do they get parsed and formatted with the colors like they do? I want to include something to the same effect onto my website eventually but I'll also be using other languages so I'll likely need more than one parser.

Anyway, if anyone knows it would be really helpful.

 

<?php
echo "How does it know?!";
?>

Link to comment
Share on other sites

Basically, regular expressions are used to detect certain characters/tags in text and gets the value in between them. Depending on which tag is used, the HTML is appropriately formatted. This also helps prevent XSS, and Injections too, by not allowing the user to directly enter HTML tags.

Link to comment
Share on other sites

Oh I understand that part of it. I was just wondering how the code tags themself are formatted. I understand that bold tags with []would put bold tags with <> around the text and an image tag with [] would format it with the <>. But what tells the tags how to format variables and functions and strings the way that it does, wigh the different colors. I could easily format my code in the font thats used and in the box with a separate colored background. But how does it know to make "echo" green and the string red? Does it compare each and every word with a list?

Link to comment
Share on other sites

Thanks much, thats exactly what I was looking for.

Do you know if there is anything like that for other languages like Java or C that would format them in a similar way? I know I've seen them formatted so there must be something.

 

And just as a Pee Ess:

I must admit, I'm fairly new to PHP. Two months ago I hadn't even looked at it. Everyday that I work with it, though, I'm more and more impressed with the amount of options and accessibility.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.