We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,318 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Showing code on a website

How do you show code on a website? Right now I define a bunch of CSS styles called Comment, Preprocessor, Keyword, etcetera. Then make a two column table, make the left column line numbers and and the right column each row has a line of code. Then I manually go through the code assigning CSS styles where appropriate. The problem is that this is tedious, especially for long pieces of code and it is not portable so if I need to change things it takes a long time. I am very new to website programming and have no idea where to start with this. Any help?

3
Contributors
5
Replies
1 Week
Discussion Span
1 Year Ago
Last Updated
6
Views
Question
Answered
Labdabeta
Practically a Master Poster
620 posts since Feb 2011
Reputation Points: 27
Solved Threads: 31
Skill Endorsements: 1

Can I ask why you want to show code on a website?

simplypixie
Practically a Master Poster
642 posts since Oct 2010
Reputation Points: 157
Solved Threads: 118
Skill Endorsements: 5

Because I was challenged by a friend to make a C++ tutorial website and I am determined to win my challenge ;). Also how can I have hidden content (so you press a button and all of a sudden extra text appears.

Labdabeta
Practically a Master Poster
620 posts since Feb 2011
Reputation Points: 27
Solved Threads: 31
Skill Endorsements: 1

Unfortunately I don't think I can help but I think you mean to display code like you would on this forum, in code tags, and I don't know how to do that (mainly because I have needed to do it so haven't looked into how it is done).

With regard to hidden content which shows on the click of a button that would need a mix of CSS and JavaScript - many tutorials on the web.

Sorry to have not been more help.

simplypixie
Practically a Master Poster
642 posts since Oct 2010
Reputation Points: 157
Solved Threads: 118
Skill Endorsements: 5

Ok, I guess I will stick to my tables of manually coloured syntax :( Thank you anyways.

Labdabeta
Practically a Master Poster
620 posts since Feb 2011
Reputation Points: 27
Solved Threads: 31
Skill Endorsements: 1
Question Answered as of 1 Year Ago by simplypixie

Were you looking for a syntax highlighter ? There are many more than the one I linked. (I know this was solved, but it may help others.)

pritaeas
Posting Prodigy
Moderator
9,533 posts since Jul 2006
Reputation Points: 1,194
Solved Threads: 1,494
Skill Endorsements: 98

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0748 seconds using 2.68MB