Dave on Facebook

Dave's profile on LinkedIn
DavesWeb visitors really liked:
Country Place Cookbook
Tomato Sauce Recipe
Bloody AwfulBelow AverageNothing SpecialGoodPretty Damn Good
My Status
Fabulous Snow!
Bloody AwfulBelow AverageNothing SpecialGoodPretty Damn Good
My Status
Thankful for Signs of Spring!
Bloody AwfulBelow AverageNothing SpecialGoodPretty Damn Good
Country Place Cookbook
Grandmother Snare's Iced Tea
Bloody AwfulBelow AverageNothing SpecialGoodPretty Damn Good
Gallery
Can Am Eyes
Bloody AwfulBelow AverageNothing SpecialGoodPretty Damn Good
Top Viewed items on DavesWeb:
My Status
Balsamic Vinaigarette Watermelon - 38,091 views
My Status
Cool car - 26,530 views
Gallery
Can Am Eyes - 25,967 views

No Live Blogging, Sorry - 16,716 views
My Status
Ads Sneaked Onto DavesWeb Part 2 of 2 - 16,252 views
Recently Viewed Items on DavesWeb:
TechQuest
Prettifying Code Snippets on Web Pages
Trailhead
Lovely December Afternoon in Tuscon, Arizona
TechQuest
Taking Embedded Javascript (EJS) For A Test Drive
TechQuest
Simple JavaScript: Add/Hide Html Elements
Main
This Evening's Haul
TechQuest: Welcome to TechQuest.
Prettifying Code Snippets on Web Pages
I've done a number of posts recently where I was showing how to do various little coding tricks. I figured out pretty early that if I just included code snippets in my html, this tricked browsers which somethings, I guess, thought it was script and didn't display it the way I expected. So I just included screenshots. Arrgh! Not helpful at all if I intended for folks to cut and paste the code for their own use.
Uploaded Image

I figured I could do a bunch of CSS and JavaScript coding and make it display the way I wanted. It seemed like a lot of work for a few code snippets. Then I discovered Google JavaScript Code Prettifier
It begins with a link to the JavaScript code Google shares for free. You can insert this link anywhere in your html document. It doesn't have to go in the head.
Then, for html or script, you need to replace the tag brackets with lesser-than and greater-than tags, so you don't confuse the browser.
Here is an example with some C-sharp code:
public static string ReadFile(string fileName)
{
    string returnString;
    using (var strReader = new StreamReader(fileName))
    {
        returnString = strReader.ReadToEnd();
        strReader.Close();
    }
    return returnString;
}

Prettifier takes care of the color coding. There are several styles you can use by adding some code to your css. Very nice. Check it out. And look for future posts of mine which contain code to be Prettified!
985 views.
No users have rated this item yet.