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
  • How to Take Great Photos With Apple's iPhone X
  • Samsung Galaxy S9+ Review
  • Asus VivoBook 15 (X510UA) Review
  • Xiaomi Redmi 5 with 18:9 display
  • Vivo V9 with dual rear cameras
  • Xiaomi Redmi 5 launch
  • Vodafone partners with Tecno to offer Rs 2200 cashback
  • LG G7 with iPhone X-like notch
  • Oppo F7 India launch confirmed
  • Alcatel 1x with Android Oreo (Go edition) announced in India
  • Huawei P20, P20 Pro, P20 Lite price
  • Xiaomi MIUI 9 global stable ROM rolling out for all smartphones
  • Nokia 9 to sport iPhone X-like notch
  • Samsung Galaxy S9 passes scratch
  • Huawei Y9 2018 with four cameras, 4000mAh battery launched
  • OnePlus 5T gets Android 8.1 Oreo in open beta 4
  • Samsung Galaxy Note 9 won’t get under-display fingerprint scanner
  • Oppo F7, Mi Mix 2S, LG G7 and more
  • Oppo F7 with iPhone X-style notch to launch
  • Motorola could cancel Moto X5, layoffs hit Chicago office

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 Internet on Idea An...

How to Use DroidVPN App For Free In...

How to HACK Google Play Music App
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 ...
  • Taotronics TT-BH22 Headphones Review
    We make it a addiction to now not look up pricing of a product sooner than reviewing and if ...
  • Reliance Jio to offer sharp tariff discounts for customers signing up by March-end
    Reliance Industries' Jio unit will charge a tariff for its services from April, but will offer ...
  • Pentagon strongly condemns North Korea missile test
    The Pentagon on Monday strongly condemned North Korea’s latest missile test, adding that the ...
  • Here new HP launches 'OMEN' gaming portfolio in India
    Entering the growing field of gaming with a bang, printing and personal computer major  HP ...
  • Fitbit Zip 2017 review
    Fitbit PROS: Clever, accurate tracking Expandable online service Integration with 3rd ...

Random Posts

  • CES 2017 Wrap-up: A look at the best, futuristic gadgets from the show
    CES 2017 Wrap-up: A look at the best, futuristic gadgets from the show
    04.02.2017 - 0 Comments
    The past week was a busy one for the tech world. The 5oth Consumer Electronics Show (or CES), held in Las…
  • IIT Kanpur to installation centre for cybersecurity
    IIT Kanpur to installation centre for cybersecurity
    04.04.2017 - 0 Comments
    Indian Institute of Technology (IIT) Kanpur has received a grant of Rs 14.43 crore from…
  • Coolpad Cool Play 6 first look
    Coolpad Cool Play 6 first look
    21.08.2017 - 0 Comments
    Coolpad Cool play 6 first impressions: Here are the top features of the new dual rear camera…
  • Is It Good To Wash Your Hair Daily?
    Is It Good To Wash Your Hair Daily?
    23.05.2016 - 0 Comments
    You would want to keep your hair healthy and radiant, don’t you? And what is the first step you take to…
  • How to Prevent Hair Loss Naturally (Stop Hair Fall with Herbal Plants)
    How to Prevent Hair Loss Naturally (Stop Hair Fall with Herbal Plants)
    29.04.2016 - 0 Comments
    Prevent hair loss is really important since it is every person’s crowning glory. That is why we always want…

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 & ...
  • Taotronics TT-BH22 Headphones Review
    We make it a ...
  • Pentagon strongly condemns North Korea missile test
    The Pentagon on ...
  • Reliance Jio to offer sharp tariff discounts for customers signing up by March-end
    Reliance Industries' Jio unit will charge a tariff for its services from April, but will offer ...
  • Bank wallets growing faster than e-wallets
    In the  bank ...
  • Fitbit Flex 2017 review
    Fitbit PROS ...
  • You may now ship money and get paid returned in Gmail on Android
    In the ...

Random Posts

  • Oppo sacks chinese worker over Indian flag row
    Oppo sacks chinese worker over Indian flag row
    30.03.2017 - 0 Comments
    Chinese handset maker Oppo said it has sacked an employee who "discarded the Indian…
  • Frenzied Indians take to the app market to adapt to the impending GST regime
    Frenzied Indians take to the app market to adapt to the impending GST regime
    24.02.2017 - 0 Comments
    Frenzied individuals and organisations are turning to the flourishing app market to make their way around…
  • Blu Life Max  Review
    Blu Life Max Review
    12.02.2017 - 0 Comments
    Blu VERDICT Blu's new budget Life Max phone is cheaper than a lot of the competition while offering…
  • How to switch Facebook profiles
    How to switch Facebook profiles
    18.02.2018 - 0 Comments
    Do you have multiple Facebook accounts? Or do you share your computer/laptop with someone and both of you…
  • Fitbit Blaze Review [GoAndroidAuthority.Com]
    Fitbit Blaze Review [GoAndroidAuthority.Com]
    28.03.2016 - 0 Comments
    Introduction Companies that make fitness trackers have tried to emulate Fitbit’s success, but…

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!