Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Member
    Join Date
    Aug 2006
    Posts
    67
    Member #
    13752
    Hi there.

    I was wandering if there was an easy way to insert example code into a html page?

    For example, on this site you would use
    Code:
     code tags
    or
    PHP Code:
     php tags 
    for code examples.

    Does html have similar inbuilt tags?

    Thanks.

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Code:
    <code></code>
    works for inline code.
    Code:
    <pre></pre>
    is for pre-formatted text (i.e., it respects whitespace). There's no way to syntax highlight PHP code and such directly in HTML, though if you look around there are several syntax highlighting solutions, both client-side (Javascript-based) and server-side (Ruby-based, PHP-based, Java-based, and others).

  4. #3
    Member
    Join Date
    Aug 2006
    Posts
    67
    Member #
    13752
    hi.
    im sure if highlighting the text is what i am looking to do.
    I am looking to insert the example code on my page, only without the need to use lots of escape characters. I have tried using <pre> only it does not display properly. Is it perhaps better to simply convert the entire code into a image?

    Also...
    Do i need to escape the hash synbol. i.e # ?


    Thanks.

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    It's definitely not better to convert to an image :-P

    What's wrong with pre?

  6. #5
    Member
    Join Date
    Aug 2006
    Posts
    67
    Member #
    13752
    im not sure why <pre> doent work. For example...

    If i do this...
    Code:
    <pre>
    <table border="2" cellspacing="0" cellpadding="5">
    <CFOUTPUT>
    <tr>
    <td>Total Number of Transactions:</td><td>#qryRecordCount.RecordCount#</td>
    <td>Total Value of Transactions:</td><td>#qryTotalValue.TotalValue#</td>
    <td>Total VAT Payable:</td><td>#qryTotalVAT.TotalVATPayable#</td>
    </tr>
    </CFOUTPUT>
    </table>
    </pre>
    It simply tries to display the table as opposed to the code. i am using <pre> in the right way?

  7. #6
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Ah. No, that is a limitation of HTML. Instead of < and >, you'll have to use &lt; and &gt;. Alternatively, I'm guessing you could write some sort of ColdFusion `tag' that would take it in and do the appropriate substituation for you (or there may even be such a tag built in).

  8. #7
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    http://www.webmasterworld.com/forum21/10776.htm

    Simply put convert < and > to &lt; and &gt; respectively.

  9. #8
    Member
    Join Date
    Aug 2006
    Posts
    67
    Member #
    13752
    ok thanks for your help. i guess ill have to go through all my code add the escape characters.

    There's much of it too! :-)

    wish me luck!

  10. #9
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Again, I'd look for a way to have ColdFusion automate the conversion for you...

  11. #10
    Member
    Join Date
    Aug 2006
    Posts
    67
    Member #
    13752
    unfortunately my server doesnt support coldfusion.

    cheers anyway.


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:06 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com