Android Century
  • Home
  • Android Zone
    • Android Apps
    • Android Games
    • Apps APk Files
    • Games Apk Files
    • Apps Hack Tricks
  • Reviews
  • Fantasy Zone
    • Entertainment
    • Quotes and Status
    • Life Style
    • Home Made Tips
    • Hair Care
    • Skin Care
    • Fantasy Tips
  • Tricks
    • Free Recharge
    • Free Internet
    • shopping Cashback
    • Recharge Cashback
  • Tech
  • Mobiles
  • Gadgets
  • News
  • How To's
  • Software
Breaking
Error Loading Feed!

Featured post

How to Take Great Photos With Apple's iPhone X

Recent Posts

Labels

  • Android Apk Files
  • Android Apps
  • Android Games
  • Apps Apk Files
  • Entertainment
  • Fantasy Tips
  • Gadgets
  • Hair Care
  • HomeMade Tips
  • How To's
  • News
  • Quotes
  • Quotes & Status
  • Recharge Cashback
  • Recharge Promo Codes
  • Shopping Cashback
  • Technology
  • skin care
Home / How To's / How to add Syntax highlighting in Website with using Syntax highlighter or Pretiffy

How to add Syntax highlighting in Website with using Syntax highlighter or Pretiffy

Latest Govt. Jobs 12:46:00 How To's Edit
Image result for Add Syntax highlighting in Website using Syntax highlighter or PrettifySyntax highlighters are mostly used by bloggers to shares codes with their readers. Though they have options to opt out from this piece of coding but they prefer it. Why, because if you are serious about your post then you must take your blog appearance in account as well and also the comfort you provide to you readers. It not only makes your blog looks great but it indirectly tells your readers that the author that is you is confident about its codes and his blogging career.
They also provide the clearer visual for the actual blog post and the codes that you have shared with them, and provide way to easily distinguish between the text and the code.

There are Three (A & B) different Highlighter code that made by different developer that could be used for free. I’ll be discussing three basic methods from which you can choose your desired ones. Also in the end of the post I will be comparing the major difference between these three methods so can choose wisely which Syntax Highlighter code is best for you.

The Implementation of the following code is pretty much the same, all you to do is add CSS (for their appearance in A, B & C) and JavaScript (A & B for code recognition).
Method A: 
Pretiffy.
This Syntax Highlighter code is developed by one of the Google employee and is pretty famous among blogger. This is Syntax Highlighter code is been used in this Blog. In this Syntax technique we would be adding both CSS and JavaScript.

1: Add the Following CSS above ]]<b:/skin>
/* Pretty printing styles. Used with prettify.js. */
/* Vim sunburst theme by David Leibovic */
pre .str, code .str { color: #65B042; } /* string  - green */
pre .kwd, code .kwd { color: #E28964; } /* keyword - dark pink */
pre .com, code .com { color: #AEAEAE; font-style: italic; } /* comment - gray */
pre .typ, code .typ { color: #89bdff; } /* type - light blue */
pre .lit, code .lit { color: #3387CC; } /* literal - blue */
pre .pun, code .pun { color: #fff; } /* punctuation - white */
pre .pln, code .pln { color: #fff; } /* plaintext - white */
pre .tag, code .tag { color: #89bdff; } /* html/xml tag    - light blue */
pre .atn, code .atn { color: #bdb76b; } /* html/xml attribute name  - khaki */
pre .atv, code .atv { color: #65B042; } /* html/xml attribute value - green */
pre .dec, code .dec { color: #3387CC; } /* decimal - blue */

pre.prettyprint, code.prettyprint {
        background-color: #000;
        -moz-border-radius: 8px;
        -webkit-border-radius: 8px;
        -o-border-radius: 8px;
        -ms-border-radius: 8px;
        -khtml-border-radius: 8px;
        border-radius: 8px;
}

pre.prettyprint {
        width: 85% !important;
        margin: 1em auto;
        white-space: pre-wrap;
      background:#111;
 font-family:Monaco,Consolas,monospace;
 font-size:15px;
 line-height:1.5;
 -moz-border-radius:8px;
 -webkit-border-radius:8px;
 -o-border-radius:8px;
 -ms-border-radius:8px;
 -khtml-border-radius:8px;
 border-radius:8px;
 width:95%;
 white-space:pre-wrap
}


/* Specify class=linenums on a pre to get line numbering */
ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE; } /* IE indents via margin-left */
li.L0, li.L1, li.L2, li.L3,
li.L5, li.L6, li.L7, li.L8
{ list-style-type: decimal !important }
/* Alternate shading for lines */
li.L1,li.L3,li.L5,li.L7,li.L9 { background: none repeat scroll 0% 0% rgba(6, 6, 6, 1) !important;}

@media print {
  pre .str, code .str { color: #060; }
  pre .kwd, code .kwd { color: #006; font-weight: bold; }
  pre .com, code .com { color: #600; font-style: italic; }
  pre .typ, code .typ { color: #404; font-weight: bold; }
  pre .lit, code .lit { color: #044; }
  pre .pun, code .pun { color: #440; }
  pre .pln, code .pln { color: #000; }
  pre .tag, code .tag { color: #006; font-weight: bold; }
  pre .atn, code .atn { color: #404; }
  pre .atv, code .atv { color: #060; }
}

pre {
    border-radius: 5px;
    transition: #3A6EA5 200ms linear 0s;
    background: none repeat scroll 0px 0px #EEE;
    font: 12px/1.5 Monaco,"Courier New",Courier,monospace !important;
    white-space: pre-wrap;
    word-wrap: break-word;
}
This above code is bit edited by me it differs from original creator. If you want to try different skin for you Syntax Highlighter code go to this Page.

2: Now add the following JavaScript above
</head> 
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>

Now all you have to add your raw code inside pre tag while posting your article in HTML environment.
<pre class="prettyprint linenums">
Paste parsed your code here
</pre>

Here linenums is used to display line numbers. For more info go to readme page.
NO DEMO since we are using Prettify.

Method B: 
Syntax Highlighter by Alex Gorbatchev.

This is also quite popular among blogger because there are different CSS available for different programming language. And it also provides excellent configuration of the appearance of the code that to be highlighted. This as above highlighting method includes both CSS and JavaScript.
Here in this post we will be using XML code to highlight it.

1: Now add the following codes just above </head >
<link href='http://agorbatchev.typepad.com/pub/sh/3_0_83/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> 
<link href='http://agorbatchev.typepad.com/pub/sh/3_0_83/styles/shCore.css' rel='stylesheet' type='text/css'/> 
<script src='http://agorbatchev.typepad.com/pub/sh/3_0_83/scripts/shCore.js' type='text/javascript'/>  
<script src='http://agorbatchev.typepad.com/pub/sh/3_0_83/scripts/shBrushXml.js' type='text/javascript'/>

See more themes here and replace with your favorite theme link. 

Here last link is the brush for XML, change this link of this brush by changing its name from shBrushXml.js to shBrushCpp.js in case you want to highlight C++ code in your blog. If you want to highlight others codes then check out this more Brushes for different programming language.

Also note that an XML Brush name/aliase is “xml”. We will use this code to call brush for highlight XML code.

2: Now add the following code above </body>
<script language='javascript'> 
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
</script>

3: Now to applying this to your code place them between the following codes while posting in HTML environment.
<pre class="brush: xml">
Paste Your parsed Code Here
</pre>

Now you can insert numbers of features into it like, highlighting some particular lines and alternate lines. Check more configuration like highlighting here . 
DEMO :

Method C: 
Custom Pre tag
There are people who doesn’t want such complex Highlighting code that may possibly slows their webpage speed, for such user there is way to highlight these code with very less coding. This following CSS is customized for my blog you may change its appearance according to your need if you want to.
Simply add this CSS inside skin tag i.e. just above ]]<b/skin>
pre {
    background: none repeat scroll 0px 0px #EEE;
    font: 12px/1.5 Monaco,"Courier New",Courier,monospace !important;
    white-space: pre-wrap;
    word-wrap: break-word;
background-color: #ececec;
 overflow: auto;
 padding: 18px;
width:85%;
border-left:5px solid #5d5d5d;
margin:0 auto;
}

pre:hover{
background-color:#f8f8f8;
}

@media print {
pre{
background-color:#f8f8f8;
border:none !important;
padding:5px !important;
}
}

Now while posting your article change the editing environment to html and enclose your code within pre tag, i.e. like in following example. 
<pre>
Paste parsed you’re here
</pre>

DEMO :
Note you have to parse the code that you want to highlight so it appears correctly. This is necessary for all the methods that have been discussed here. For parsing the code go to this Page and parse your code. Make sure you Bookmarks this page for future use and references.

Our recommendation : Prettify, its Does its work without any Glitches and without slowing down the webpages. So what do you think about this post do you find it helpful, if you what any help regarding this blog post or have any suggestion, drop your comments below.
Share on Facebook Share on Twitter Share on Google Plus

RELATED POSTS


How To Get Free Recharge And Money ...

How to Sync Your Contacts Between A...

How to Know a Wi-Fi Network Is Fast...
How to add Syntax highlighting in Website with using Syntax highlighter or Pretiffy How to add Syntax highlighting in Website with using Syntax highlighter or Pretiffy Reviewed by Latest Govt. Jobs on 12:46:00 Rating: 5

1 comments:

  1. Pinky Sownia22 April 2020 at 05:47

    I have been looking for ways to do this for two days and I stumbled on your blog. I'm glad I found this blog through Google. Thanks only for this great blog post. It was really very helpful and to the point. Keep sharing useful information.

    ReplyDelete
    Replies
      Reply
Add comment
Load more...

Newer Post Older Post Home
Subscribe to: Post Comments ( Atom )

Search This Blog

TEST BOOK FOR GOVT ENTRANCE TEST

TEST BOOK FOR GOVT ENTRANCE TEST
Find All Latest book for preparation of SSC,RAILWAYBANK PO,RBI,BANK CLERK,GATE ME,GATE CE are available here in less prices, to check out the books click here

Translate

  • Popular Post
  • Random posts
  • Category

Popular Posts

  • Teen Patti Offer 2018: Refer and Earn Flipkart Vouchers Free
    Teen Patti Offer 2018: Refer and Earn Flipkart Vouchers Free
    Teen Patti Refer & Earn Offer:  Hey Guys! Today I make an article about Teen Patti Referral ...
  • KingRoot 4.8.1 (136) APK Latest Version Download
    Download KingRoot Latest Version 4.8.1 In Tools by Developer KingRoot Studio ( 4.x / 5  average ...
  • 11 things you should understand approximately iOS 11
    Apple introduced the following version of its running system for the iPhone and iPad, iOS eleven ...
  • How to Upload Your Music Library to Google Play Music
    Google Play Music offers an unlimited music streaming subscription paired with YouTube Red ...
  • How to Disable Your Mac’s Touchpad When Another Mouse Is Connected
    Laptop trackpads can be annoying. Your palm hits them while you’re typing, moving your cursor ...
  • How to Gain Root Access of An Android Device via KingoRoot Software
    What Does Root Access Mean? Gaining root access of Android is the process of modifying the ...

Random Posts

  •  VSDC Free Video Editor Download of the day
    VSDC Free Video Editor Download of the day
    09.03.2017 - 0 Comments
    VSDC Free Video Editor Imagine a video editor that enabled you to create projects in Full…
  • Panasonic KX-HN6002EW 2017 review
    Panasonic KX-HN6002EW 2017 review
    10.03.2017 - 0 Comments
    Panasonic VERDICT As an expandable smart home solution with numerous optional sensors, this starter…
  • Ofcom rules that BT will have to start charging its customers less
    Ofcom rules that BT will have to start charging its customers less
    28.02.2017 - 0 Comments
    Are you with BT for your landline service? In that case, prepare yourself for…

Labels

Android Apk Files Android Apps Android Games Apps Apk Files Apps Hack Tricks Entertainment Free Internet Freecharge Gadgets Games Apk Files How To's Laptops Guide Mobiles Reviews Technology Viral's android zone free recharge

Entertainment

Tricks

Popular Posts

  • Teen Patti Offer 2018: Refer and Earn Flipkart Vouchers Free
    Teen Patti Offer 2018: Refer and Earn Flipkart Vouchers Free
    Teen Patti Refer & ...
  • Researchers trick 'CEO' email scammer into giving up identity
    Businesses ...
  • How to Gain Root Access of An Android Device via KingoRoot Software
    What Does Root ...
  • Tinyowl Freecharge Offer – Get 15% Cashback + extra 25% cashback using Freecharge [Ultimatez Tricks]
    Tinyowl Freecharge ...
  • How to Disable Your Mac’s Touchpad When Another Mouse Is Connected
    Laptop ...
  • Infocus Vision 3 review
    What happens when ...
  • EVGA redesigns its graphics cards following overheating concerns
    Following a ...

Random Posts

Most Popular

  • Teen Patti Offer 2018: Refer and Earn Flipkart Vouchers Free
    Teen Patti Offer 2018: Refer and Earn Flipkart Vouchers Free
    Teen Patti Refer & ...
  • SAMSUNG GALAXY J7 (2016) REVIEWS
    SAMSUNG GALAXY J7 (2016) REVIEWS
    SAMSUNG GALAXY J ...
  • Top 5 Best SmartPhones under 7000 Rs (March 2017)
    Looking for the ...
  • Apple, IBM, Cisco are huge because of Indians, do not deny them H-1B visa: RBI Governor Urjit Patel
    ...
  • SAMSUNG GALAXY J7 (2016) Specifications
    SAMSUNG GALAXY J ...
  • BlackBerry Teases Marshmallow Beta Testing for Priv by Next Week
    Blackberry ...
  • LG Q6 Review
    LG Q6 Review
    2017 is ...

Contact Form

Name

Email *

Message *

Offers Zone

Created By Android Century Distributed by Android Century
  • Home
  • About us
  • Contact us
  • Privacy policy
  • Terms of use
  • Advertise here
Subscribe Via Email Subscribe To Android Century By Email And Get Free Updates. ;-)


Your email address is safe with us!