Ghosts Syntax Highlighter

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Ghosts Syntax Highlighter

    ok so i was building a syntax highlighter for my site/project that would mod the post/data before it hit the database so when a post was made only the correct parts of that post was highlighted within a codebox.

    i came into an issue with the /** commented out text */ section of this as where it would comment the post out. but if a certain keyword from the php name array was in the commented out text it would then change to its respected color.

    now ive had many suggestions to fixing this but all have failed when ive attempted it.

    so im gonna let this out so anyone that wants to attempt to fix it or try and solve it can.


    i should also add i have added a line of data inside the file for testing purposes to see the outcome and display the Demo of problem.
    i use the line of text for the testing/build of the script.

    Demo of fill working AND problem


    File:
    Attached Files
    Last edited by Ghost; 07.08.12, 02:57.
    <?php
    include ('Ghost');
    if ($Post == true) {
    echo '

    sigpic
    alt='coding-talk.com!!' />';
    echo 'Sharing Is Caring!';
    } else {
    echo '

    alt='the username GHOST has been comprimised!' />';
    echo 'OMG SOMEBODY HELP ME!!';
    }
    ?>

    #2
    Test it with quotemeta(). ;)
    <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

    Comment


      #3
      Originally posted by arnage View Post
      Test it with quotemeta(). ;)
      oops accidently deleted the demo, (back up and running now)

      and thank you, will look into the function.

      edited
      sadly just like preg_quote this just added \ next to chars like $, it didnt however stop preg_replace or str_replace
      from find the word it was looking for. so it just ended up looking like.

      \<span style="color:#0000FF;">$Variable</span>
      bypassing the \ and still finding its mark.

      also it didnt help much against none special symbols. for example: words from inside the arrays still get caught too.

      /** some normal text then <span style="color:#008000;"><b>preg_replace</b></span> **/
      would appear.
      Last edited by Ghost; 31.07.12, 23:09.
      <?php
      include ('Ghost');
      if ($Post == true) {
      echo '

      sigpic
      alt='coding-talk.com!!' />';
      echo 'Sharing Is Caring!';
      } else {
      echo '

      alt='the username GHOST has been comprimised!' />';
      echo 'OMG SOMEBODY HELP ME!!';
      }
      ?>

      Comment


        #4
        ho , we can solve it ,wait

        Comment


          #5
          Aha. Try to add something like this in snippet.

          PHP Code:
          if (in_array($one$two)) continue; 
          ... to skip those predefined words.
          <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

          Comment


            #6
            Originally posted by arnage View Post
            Aha. Try to add something like this in snippet.

            PHP Code:
            if (in_array($one$two)) continue; 
            ... to skip those predefined words.
            will look into it. thanks
            but this file now is starting to be a pain in my ass lol.
            thats why i put it up on forums ;)
            <?php
            include ('Ghost');
            if ($Post == true) {
            echo '

            sigpic
            alt='coding-talk.com!!' />';
            echo 'Sharing Is Caring!';
            } else {
            echo '

            alt='the username GHOST has been comprimised!' />';
            echo 'OMG SOMEBODY HELP ME!!';
            }
            ?>

            Comment


              #7
              Exactly why we should bounce ideas and try to make it right, you only to test those ideas only because you are most familiar with it, just if its not too much enoying to you.
              <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

              Comment


                #8
                Originally posted by arnage View Post
                Exactly why we should bounce ideas and try to make it right, you only to test those ideas only because you are most familiar with it, just if its not too much enoying to you.
                thats cool mate. although its not hard to see whats going on in the file.

                top of file is all the arrays, and bottom half consists of 3 checks.

                a 3 box check.
                a 2 box check
                a 1 box check.

                and in each box check theres some preg_match_all, preg_replace, str_replace functions. thats basically it.
                <?php
                include ('Ghost');
                if ($Post == true) {
                echo '

                sigpic
                alt='coding-talk.com!!' />';
                echo 'Sharing Is Caring!';
                } else {
                echo '

                alt='the username GHOST has been comprimised!' />';
                echo 'OMG SOMEBODY HELP ME!!';
                }
                ?>

                Comment

                Working...
                X